I have a question that is very similar to Getting Emacs fill-paragraph to play nice with javadoc-like comments, but I wasn't sure if I would get many answers in a year old thread.
Anyhow, I have C code that has some Doxygen comments that look like the following:
/**
* Description
*
* #param[in,out] var1 : <Long description that needs to be wrapped.>
* #param[in,out] var2 : <Description2>
*/
Now, when I use M-q 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>
*/
Doing some research, it looked like I needed to set the paragraph-start variable in emacs to recognize the "#param." I found another question on stack overflow (Getting Emacs fill-paragraph to play nice with javadoc-like comments), that had a sample regular expression. I modified it a bit to fit my requirements, and I tested it inside of Search->Regex Forward, and it highlighted each #param sentence correctly.
I used the following regular expression "^\s-*\*\s-*\(#param\).*$"
So, I tried setting the given regular expression as my paragraph-start (with the added \'s required for the elisp syntax) in my .emacs file. When I opened a new emacs window and tried out the M-q, the same error was occurring. Is there something I am missing? Is M-q used differently in c-mode? Should I check my .emacs file for something that may be causing an error here? Any help would be appreciated.
Thanks,
Ryan
Regarding your question, "Is M-q used differently in c-mode?", describe-key (bound to C-h k) is your friend. While visiting the buffer with the C file, type C-h k M-q and it will tell you exactly what function M-q is bound to. In this case, it is c-fill-paragraph, which ultimately uses paragraph-start, the variable you found in that other question.
I found that this regular expression used as paragraph-start will wrap lines and treat each #param as a new paragraph:
"^[ ]*\\(//+\\|\\**\\)[ ]*\\([ ]*$\\|#param\\)\\|^\f"
However, it will not indent the wrappedlines as you want. It 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 figure out the indenting.
Related
Launch Emacs with emacs -q and write in org-mode:
#+BEGIN_SRC C
/*
* This is a comment line
*/
#+END_SRC
Press TAB inside the block. It becomes:
#+BEGIN_SRC C
/*
,* This is a comment line
,*/
#+END_SRC
Is there any way to get rid of this behevior?
This is a quoting mechanism to make sure that the asterisks are not interpreted as headline markers and throwing off Org mode's parser. See Literal Examples in the manual.
There is no way to turn it off and you shouldn't anyway because Org mode will be very confused otherwise. The commas do not affect the exporting of the document or the evaluation of a source block: they are properly stripped at the appropriate time.
At work I frequently deal with support issues that my company keeps track of in a web-based bug tracker.
Each issue has an URL that looks like https://mycompany.com/support/SUPPORT-12345, but of course I don't want to spell this out every time I mention a support issue in my Org-mode file. I would like set up Org-mode in such a way that the pattern SUPPORT-(\d+) is treated as a hyperlink to https://mycompany.com/support/SUPPORT-\1.
I would like to be able to place my cursor over the SUPPORT-2345, type C-c C-o, and have Emacs point my browser to https://mycompany.com/support/SUPPORT-2345. Ideally, SUPPORT-2345 would behave no different than a hyperlink.
Can Org-mode be configured in this way? If not, what is the best alternative?
You should be able to do this with org-link-abbrev-alist. For example, see the below for some I use. You can then put [[Support:1234]] in your Org-mode file and have it treated as the expanded link.
(setq org-link-abbrev-alist
'(
("DOI" . "http://dx.doi.org/")
("FreshDesk" . "https://xyz.freshdesk.com/support/tickets/")
("JIRA" . "https://jira.apps.monash.edu/browse/")
("Support" . "https://support.xyz.com/helpdesk/tickets/")
("ISBN" . "http://isbn.nu/")))
I don't know whether Org-mode have this feature, but there is a bug-reference-mode for it.
Here is sample org file:
;; Local Variables:
;; eval: (bug-reference-mode)
;; bug-reference-bug-regexp: "\\(\\(?:\\(?:SUPPORT\\|support\\)-\\)\\([0-9]+\\)\\)"
;; bug-reference-url-format: "https://mycompany.com/support/SUPPORT-%s"
;; End:
* SUPPORT-123
* support-1234
And you can move point on support-* and press C-c RET (bug-reference-push-button) to open it.
For more detail about Bug Reference, please refer to C-h r g Bug Reference
Is there a way to bulk-reverse the order of headings in Emacs org-mode?
I'd like to change this kind of list (but much bigger, not just two or three items, thus "bulk"):
* personal computer
* Windows
* Mac
* Linux
* StackExchange
* stackoverflow
* countries
* people
to this:
* people
* countries
* StackExchange
* stackoverflow
* personal computer
* Windows
* Mac
* Linux
Select the whole buffer and use M-x org-sort-entries RET F point RET
org-sort-entries sorts all items at a certain level in the tree. 'F' tells it that you want to sort in reverse order according to a function that you specify. Using the function point gives each entry a value corresponding to buffer position on which to sort.
To do the same thing from elisp, the equivalent function call is (org-sort-entries nil ?F 'point)
C-c ^ to invoke org-sort, which will Call org-sort-entries, org-table-sort-lines or org-sort-list accordingly.
Then you can either:
f point RET > RET
F point RET < RET
I don't know the org-sort-entries' api changed or what, when I followed #clatter's answer, it asked me for a compactor. So here is an answer basing on his.
Sure, M-S-<up> and M-S-<down> move subtrees up and down inside their common parent. There are a bunch of other similar commands as well; check out the info page for a list of them (M-x info "(org) Structure Editing").
Edit: Actually reversing the order of subheadings is not something you can do out of the box, I think. You might be able to do it by calling sort-subr with cleverly chosen arguments, however.
I was looking for a way to automatically generate doxygen comment blocks for functions in existing source files. While looking at the alternatives I saw a reference to an existing mechanism in SRecode that could generate the correct comments with srecode-document-insert-function-comment. After enabling the tag generation with M-x semantic-mode and SRecode with M-x srecode-minor-mode. Everything seemed to be working, the templates and tables seemed to detected the c-mode when using the SRecode debugging functions.
However, when I use the SRecode->Generate menu option, instead of a doxygen function comment, I get a plain comment as follows:
/** main --
*
*/
void main(int argc, char **argv)
I get nothing but the following messages with C-h e:
Adding srecode-insert-getset to srecode menu
Adding srecode-document-insert-comment to srecode menu
I've already tried it on other functions and tried debugging with edebug-defun but I could not make sense of the output.
Can someone suggest what other settings are necessary?
Additional details:
GNU Emacs 24.3.1 (i386-mingw-nt6.1.7601) of 2013-03-17 on MARVIN
Semantic 2.2
SRecode 1.2
Update 20131009:
retrying from different cursor positions (e.g. inside the function, on the start of the function name) produces the same results
calling from the menu or directly calling the function produces the same results
I have no special customizations in .emacs for either semantic or SRemote, and the modes are not enabled until I call them specifically as described above (Perhaps that's actually what's missing; is there some sort of global setting necessary?)
Update 20131012:
retried with a different PC (with different configuration) and with the -q startup option to ignore the .emacs file. In both cases, the output was the same.
Update 20131013:
I noticed the following in the *messages* buffer after running generate for the first time. Perhaps there's a hint in there.
Adding srecode-insert-getset to srecode menu
Adding srecode-document-insert-comment to srecode menu
Adding srecode-insert-getset to srecode menu
Adding srecode-document-insert-comment to srecode menu
Compiling template default.srt...
2 templates compiled for default
Templates default.srt has estimated priority of 80
Compiling template c.srt...
17 templates compiled for c-mode
Templates c.srt has estimated priority of 90
Compiling template c.srt...
14 templates compiled for c-mode
Templates c.srt has estimated priority of 90
Compiling template doc-default.srt...
7 templates compiled for default
Templates doc-default.srt has estimated priority of 80
Auto-saving...done
Looks like someone at some point moved doc-c.srt to doc-cpp.srt instead of copying it (this is emacs 24.3.1).
As a result srecode-document-insert-comment works (as you expect it to) only in c++-mode.
In order to enable it for c-mode create a file ~/.srecode/doc-c.srt with the following content and it should work fine.
;; doc-c.srt --- SRecode templates for "document" applications
;; Copyright (C) 2008-2013 Free Software Foundation, Inc.
;; Author: Eric M. Ludlam <eric#siege-engine.com>
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
set mode "c-mode"
set application "document"
context declaration
;;; Notes on the DOCUMENT templates.
;;
;; These templates recycle existing templates for doxygen in the
;; more general C template set.
template section-comment :indent :blank
"A comment separating major sections of a file."
----
{{>:declaration:doxygen-section-comment}}
----
template function-comment :tag :indent :blank
"A comment occurring in front of a function.
Recycle doxygen comment code from the more general template set."
----
{{>:declaration:doxygen-function}}
----
template variable-same-line-comment :tag
"A comment occurring after a variable declaration.
Recycle doxygen comment code from the more general template set."
----
{{>:declaration:doxygen-variable-same-line}}
----
;; These happen to be the same as in a classdecl.
template group-comment-start :blank :indent
"A comment occurring in front of a group of declarations.
Recycle doxygen comment code from the more general template set."
----
{{>:classdecl:doxygen-function-group-start}}
----
template group-comment-end :blank :indent
"A comment occurring at the end of a group of declarations.
Recycle doxygen comment code from the more general template set."
----
{{>:classdecl:doxygen-function-group-end}}
----
;; end
An alternative for doxygen comment generation would be doxymacs
You should be on the same line as function name, or inside function's definition - then, srecode-document-insert-comment (C-c / C) will insert correct comment. Here is result of this command on my CEDET installation (from bzr, although in 24.3.1 it should be the same):
/**
* #name main -
* #param argc - Number of arguments
* #param argv - Argument vector
* #return int
*/
int main(int argc, char **argv) {
return 0;
}
Your cursor should be before the opening parenthesis.
If you are inside the parameter list nothing will be inserted.
I make my notes in this order:
* FIRST
* SECOND
* THIRD
...
* LAST
what I want when I export to html or latex is the reverse order:
* LAST
...
* FIRST
so
is there any way or command to reverse the order in org file directly ?
is there any way to reverse the order while I export the org file to html/latex ?
either should be fine I think.
I don't think there is a predefined command you are looking for. You can implement it by yourself.
If it's a one-time task I would use emacs macro:
You show only top-level headlines. Then you go to the first headline and start macro C-x ( .
You select the line C-SPACE C-n and you type C-u M-x prepend-to-register . C-u deletes the line as well. You stop the macro C-x ) .
Now you repeat the macro for all top-level headlines M-0 C-x e .
And you insert the register C-x r i .
An alternative for evil users:
Fold all headlines (S-TAB) and go to the last one (G)
qq Record macro to register q
"Pddk Append current headline to register p and go a line up
q Save macro
#q and then X## with X being the number of remaining headlines
"pp Paste from register p