2

I'm looking for a way to generate and insert header comment blocks above my functions in Emacs (in any mode), with the default contents of the comment automatically based on the function's signature (i.e. the correct number of @param place-holders).

Doxymacs is a nice candidate. But I prefer another way works without the necessary libs. Can anyone recommend some others ways for adding smart comments for functions in Emacs? Thanks.

Edit: Now I found this: http://nschum.de/src/emacs/doc-mode/, but it seems that it does not work well after I require it into my .emacs and add hook for js-mode. Doesn't it support js functions ?

phils
  • 71,335
  • 11
  • 153
  • 198
Boris
  • 555
  • 7
  • 22
  • 1
    Do you mean functions in elisp or functions you edit with Emacs? – Tim Landscheidt Mar 26 '12 at 21:11
  • I mean any functions in any program language. When I use eclipse, I type "/**" above the first line of a function definition, comments like: "/** \n *@desc\n *@param\n *@return\n **/" will auto generate. Moreover, the number of "param" will base on the function signature – Boris Mar 27 '12 at 01:44

2 Answers2

2

I don't know of any general-purpose approach.

Csharp-mode has a defun that is bound to / , which tries to generate comments appropriate for C#. The way it works: Every time you type a slash, it looks to see if it is the third slash in a row. (In C#, three slashes are used to denote comments that produce documentation). If it is the third slash, then it looks at the surrounding text and inserts a comment skeleton or fragment that is appropriate.

image

It is not generalized in any way to support javascript or other language syntaxes. But you might be able to build what you want, if you start with that.

here's the excerpt:

http://pastebin.com/ATCustgi

Cheeso
  • 189,189
  • 101
  • 473
  • 713
0

I've used doxymacs in the past and I've found it useful http://doxymacs.sourceforge.net/

perogiex
  • 505
  • 5
  • 10