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.
Related
I just finished the Emacs Lisp intro and am getting my feet wet with customization. I've browsed the Emacs FAQ, the Emacs W32 FAQ, and perused the fine manual for drag and drop information. I am using GNU Emacs 24.5.1 for Windows without Cygwin (etc.).
I would like to update the default drag and drop behavior to open such files in read only mode. Through C-h f I've identified the dnd functions. In particular, dnd-open-file may be relevant. By C-h k and then dragging a file into Emacs, I've identified the function w32-drag-n-drop. Also, within the Reference Manual is a section on drag-and-drop which specifies x-dnd-types-alist.
How do I identify which of these items, if any, needs to be modified?
What is a safe way to modify its behavior?
I cannot find documentation on x-dnd-types-alist. Is it a function? A variable?
Is there a resource I've overlooked which I should be looking at?
Partial answers of a general nature - I can't help with your dnd problems,
but I hope these suggestions will be of some use.
Q2. It's a good idea to have a minimal init file, containing whatever is necessary to initialize an environment for testing. You can them invoke emacs like this:
emacs -q -l /path/to/minimal/init/file
bypassing your initialization file (-q) and loading the minimal init file instead. Then if something blows up, you just kill this emacs instance, and start again (possibly with a modified init file).
Q3. It's a variable (as are all alists). An alist (short for association list) is a list of key-value pairs. You can get the docstring of any variable with
C-h v VARNAME RET
e.g.
C-h v x-dnd-types-alist RET
Q4. If all else fails, the source is available...
I have several .org files, and I'd like to be able to create links between them using an ID. I am using DOIs as unique identifiers. I can link within a file by using properties:
* Paper 1
:PROPERTIES:
:CUSTOM_ID: 10.1088/0953-8984/23/21/213001
:END:
* Paper 2
:PROPERTIES:
:CUSTOM_ID: 10.1038/nphys2935
See also [[#10.1088/0953-8984/23/21/213001]]
Is there a way to make the custom_id global, so I can reference it from another file?
I think that org-id is what I need to go further, but I've found the documentation a little confusing. I tried adding the following lines in my .emacs
;; Use global IDs
(require 'org-id)
(setq org-id-link-to-org-use-id use-existing)
;; Update ID file .org-id-locations on startup
(org-id-update-id-locations)
but the file .emacs.d/.org-id-locations only has nil.
It seems like global links won't be automatically generated (Assign IDs to every entry in Org-mode). I tried (with cursor on the heading) to use M-x org-id-get-create, but this does not seem to do anything.
EDIT: (Based on helpful comment)
Within one session, I can store and create links using M-x org-store-link while on the heading (Paper 1 in my example above). Then I can use M-x org-insert-link, and type the ID to insert the link. The link looks like [[id:10.1088/0953-8984/23/21/213001][Paper 1]]. But I am running into two problems: (1) I'd like the ids to be stored automatically. (2) The links don't work when I close and re-open the file.
EDIT: A related question:
https://emacs.stackexchange.com/questions/2186/have-org-modes-exported-html-use-custom-id-when-linking-to-sub-sections-in-toc
So here's the solution I came up with.
In my .emacs configuration, I have kept the same settings as in my question:
(require 'org-id)
(setq org-id-link-to-org-use-id use-existing)
;; Update ID file on startup
(org-id-update-id-locations)
The files need to be part of the agenda list (or added to the list of additional files using org-id-extra-files (See org-id documentation))
Use ID instead of CUSTOM_ID in the PROPERTIES drawer:
* Paper 1
:PROPERTIES:
:ID: 10.1088/0953-8984/23/21/213001
:END:
Each ID needs to be created (if necessary; in my case I already have them), and a link added to the ID file (links are stored in .emacs.d/.org-id-locations). This is done using org-id-get-create: with the cursor on the heading, call it using
M-x org-id-get-create
Link to an ID using [[id:10.1088/0953-8984/23/21/213001][Paper 1]].
I have to think a little bit more about when I'd like the ID to be created; I can automate the process by tying the ID storing to another function that I'll do to all the headings.
I use Emacs org-mode to organise my todo list. Recently I found under each todo item it automatically generates a property drawer containing a key ID and the corresponding value, something like this:
** TODO meeting XXX
SCHEDULED: <2014-07-12 Sat 14:00>
:PROPERTIES:
:ID: 46673B08-F9D9-4966-B70A-A2ADBC2ADE0E
:END:
Entered on [2014-07-08 Tue 20:40]
I have no idea how this property drawer is generated, and I did not have it before. If delete it, next time I start Emacs to read the file, it will come back again. What would I do?
Would you have used MobileOrg? If yes, that's the culprit (and that clutter is something more that keeps me away from using MobileOrg ATM).
Posting your configuration file would definitely help diagnose what's causing this. For some, this is the desired behavior of the org-id package, which is explained in Handling Links in the Org-mode Manual:
The library org-id.el must first be loaded, either through org-customize by enabling org-id in org-modules, or by adding (require 'org-id) in your .emacs.
An init.el / .emacs file that enables this functionality, might for example, include the following:
;; Use global IDs
(require 'org-id)
(setq org-id-link-to-org-use-id t)
;; Update ID file .org-id-locations on startup
(org-id-update-id-locations)
Additionally, you could check your .emacs.d directory to see if there is a .org-id-locations file, which is generated by the org-id package.
To disable this behavior, you should remove all org-id package related code from your configuration files.
It's likely that this behavior occurs every time you use (org-store-link), commonly bound to C-l l. You might also want to check out Assign IDs to every entry in Org-mode
So, way back in January, I went here:
http://emacsformacosx.com/
I downloaded Emacs and have been using it on my Mac and I like it. I've started trying to get into Elisp programming. To learn more, I'd like to look up some functions. So for instance I do:
C-h f
and then type "scroll-down"
This gives me the following text:
>scroll-down is an interactive built-in function in `window.c'.
>
>It is bound to <kp-prior>, <prior>, C-1, C-x C-1, M-v.
>
>(scroll-down &optional ARG)
>
>Scroll text of selected window down ARG lines.
>If ARG is omitted or nil, scroll down by a near full screen.
>A near full screen is `next-screen-context-lines' less than a full screen.
>Negative ARG means scroll upward.
>If ARG is the atom `-', scroll upward by nearly full screen.
>When calling from a program, supply as argument a number, nil, or `-'.
And the text "window.c" is a link. So I click on the link and I get:
find-function-C-source: The C source file window.c is not available
I'm getting this error a lot while doing a lot of different things. Where do I find the right path, and how do I tell Emacs what that path is?
I did just recently install some ELPA packages, so maybe one of them is causing some chaos?
The variable source-directory will point to the location where the C sources are. If you have a separately downloaded copy, you'll have to point this variable to that directory.
Most packagers don't include the sources, or split them off into a separate package. Install the sources (and maybe tweak an init script to tell Emacs where you put them, if it's not the default location. The pertinent variable is find-function-C-source-directory).
If you didn't manually build Emacs from the source code and patch the C source code, value of source-directory or find-function-C-source-directory would be wrong.
You can manually download Emacs source code, unpack it somewhere and set above two variables accordingly like following
(setq source-directory "/path/to/your-emacs-repo")
;; OR
(setq find-function-C-source-directory "/path/to/your-emacs-repo/src")
GNU Emacs source code and development is hosted on savannah.gnu.org. You can find all the tags here and download the one that matches your M-x emacs-version.
I am using emacs 23.3
I heard that emacs 23.3 include cedet by default
but how can I use them? how should I change my ".emacs" file for ..
function parameter hint
(when I type "malloc(" then parameter hint arise somewhere)
auto complete menu
(when there are variable "qwer", "qwert", and "qwerty" and when I type "qwe" then those 3 selectable hint arise somewhere)
when I edit c or cpp file?
(and.. any suggestion for cedet feature?)
Are you asking as someone using an old CEDET distribution, or someone new to CEDET? I'll assume the later.
First, you need to enable semantic with this in your .emacs:
(semantic-mode 1)
next, if your project is particularly large (more than 1 directory full of files) you will need to enable EDE.
(global-ede-mode 1)
and figure out what kind of project to use. Your project might be auto-detected if it is one of the common ones, otherwise you should create one of type ede-cpp-root to just wrap that directory, or try enabling the generic project types that use a Makefile, scons or cmap, or with:
(ede-enable-generic-projects)
Generic projects can sometimes get in the way, so they are disabled by default.
You would then need to enable the idle summary mode:
(global-semantic-idle-summary-mode 1)
Look in the Development menu for other options.