Emacs c-mode fill-paragraph with Doxygen Comments

I have a question that is very similar to Getting Emacs fill-paragraph to play well with javadoc comments , but I was not sure if I would get many answers in the annual topic.

Anyway, I have C code in which there are some Doxygen comments that look like this:

/** * Description * * @param[in,out] var1 : <Long description that needs to be wrapped.> * @param[in,out] var2 : <Description2> */ 

Now when I use Mq in emacs, I want the following:

 /** * Description * * @param[in,out] var1 : <Long description that needs * to be wrapped.> * @param[in,out] var2 : <Description2> */ 

But, current I get the following:

 /** * Description * * @param[in,out] var1 : <Long description that needs * to be wrapped.> @param[in,out] var2 : <Description2> */ 

After doing some research, it seemed to me that I needed to set the start-start variable in emacs to recognize "@param". I found another stack overflow question ( Getting Emacs fill-paragraph to play well with javadoc comments ) that had an example of regex. I modified it a bit to fit my requirements, and I tested it inside Search-> Regex Forward, and it prompted every @param sentence correctly.

I used the following regular expression "^\s-*\*\s-*\(@param\).*$"

So, I tried to set this regex as my start-item (with added \ required for elisp syntax) in my .emacs file. When I opened a new emacs window and tried out Mq, an error occurred. Is there something I'm missing? Is Mq different in c-mode? Should I check the .emacs file for what might cause the error here? Any help would be appreciated.

Thanks Ryan

+6
emacs doxygen
source share
1 answer

As for your question: β€œIs Mq used differently in c-mode?”, describe-key (bound to Ch k) is your friend. When visiting the buffer with the C file, enter Ch k Mq and it will tell you exactly what the Mq function is associated with. In this case, it is c-fill-paragraph , which ultimately uses paragraph-start , the variable you found in this other question.

I found that this regex, used as paragraph-start , will wrap lines and treat each @param as a new paragraph:

"^[ ]*\\(//+\\|\\**\\)[ ]*\\([ ]*$\\|@param\\)\\|^\f"

However, it will not retreat from the wrapped lines as you wish. This will make your example look like this:

 /** * Description * * @param[in,out] var1 : <Long description that needs * to be wrapped.> * @param[in,out] var2 : <Description2> */ 

I hope it still works better for you. Let me know if you find the indentation.

+3
source share

All Articles