Reputation: 25371
I have been using Emacs for more than three years now but it still takes me days to write even small functions in Lisp. I've looked through GNU Emacs Lisp Reference Manual but it's huge and structured completely opposite from JavaDoc, not from functions to descriptions but the other way around.
What will make my life much easier is some sort of small JavaDoc like document with most commonly used Emacs internal functions and they quick description.
(point) - returns current position in buffer (save-excursion (p)) - saves current position in buffer before executing (p) and restores it afterward.
Does anyone know where I can find something like that?
Upvotes: 17
Views: 5318
Reputation: 3900
This site has some emacs lisp summary information that may be useful: http://xahlee.org/emacs/elisp.html.
In particularly, check out these links on that page: Basic Text-editing Functions, Emacs Lisp Idioms and Batch Text Processing
Upvotes: 12
Reputation: 7064
If you're willing to fork over money for a dead tree, I'd recommend
(source: oreilly.com)
Upvotes: 1
Reputation: 1
Download source code for Emacs. Go to src/ folder and type:
grep -r DEFUN *
You will get list of all primitive Lisp functions of Emacs.
Upvotes: 0
Reputation: 211
In XEmacs, and I believe in Emacs as well, pressing C-h f, then the tab key for tab completion, which at that point is all functions, will give you a list of functions the editor knows about.
You just use cursor keys and scroll to one you want to know about and press enter to see details.
If a list of functions, with further info available, is what you want, that will give it to you.
This list is all currently available functions, so if you have packages of lisp installed, it shows the functions those packages supply as well as native functions. In my copy of XEmacs, today, I have 6,586 functions in the list. Emacs will be similar.
The problem is that not all functions have names that make them context-meaningful (ie not all menu variables/functions have the word menu in them, so you will miss some things if you go by names only.
You can use the INFO pages (on the menu) to view them more topically arranged, and get to the same usage information.
Upvotes: 0
Reputation: 4804
In order to understand what's on, quite often it's useful having a look at the source code.
http://repo.or.cz/w/elbb.git/blob/HEAD:/code/Go-to-Emacs-Lisp-Definition.el
Upvotes: 2
Reputation: 42674
I think you are taking the wrong approach. When learning a programming language and set of libraries (collectively, "Emacs Lisp"), you need to approach it on both the micro and macro scale. Before you can start writing software, you need to know what tools you have available. That is what the Emacs Lisp manual aims to educate you on. You really need to sit down and read the whole thing. That way you know what features Emacs provides.
After you do that, you need "micro-level" information. There are
a number of sources that provide this. If you have a general idea of
what you need to do ("working with buffers"), then the Lisp reference
is a good place to figure out what you need to know. If you know that
there's a function that does what you want, but don't quite remember
the name, then M-x apropos
(C-u C-h a
) will help you search the
documentation. If you know what function you want to use, but don't
remember quite how it works, then M-x describe-function
(C-h f
)
will sort that out for you.
So anyway, the key is to learn Emacs Lisp, and then let Emacs help you with the details. A list of functions isn't going to teach you much.
(Oh, one more thing -- you should familiarize yourself with Common
Lisp. Most Emacs libraries use cl
, which are the useful CL
functions implemented in Emacs Lisp. loop
, destructuring-bind
,
defun*
, and so on are all there, and they are very helpful.)
Upvotes: 8
Reputation: 30701
Good suggestions from others -- Emacs help system is your friend. In addition:
http://www.emacswiki.org/emacs/Icicles_-_Progressive_Completion
http://www.emacswiki.org/emacs/Icicles_-_Nutshell_View#ChippingAway
Upvotes: 2
Reputation: 16859
I would add a couple of things:
M-x apropos
- searches functions and variables for whatever string you specify (e.g. directory). Note that this is slightly different than C-h a
, which only finds interactive functions
find a similar piece of code and copy it - you can learn an awful lot about how to do things by looking at what's already done. If you have a particular function you want to see examples of, one good way is to visit the main lisp source directory in dired (e.g. d:/product/emacs/lisp or /usr/share/lib/emacs/lisp) and do % g
which will grep through all files looking for whatever string you type. Open up that file and see what other people have done with it.
C-h f
and C-h v
- as someone else mentioned, you can open up source, position point over a function or variable and then get documentation on it.
Check out the Emacs wiki, which has a crap-load of Emacs lisp modules for you to peruse.
Upvotes: 10
Reputation: 17201
Have you tryed <f1> f
? It is bound to describe-function
. Example with point
:
point is a built-in function in C source code.
(point)
Return value of point, as an integer.
Beginning of buffer is position (point-min).
[back]
Like most Lisp systeme, Emacs has an integrated documentation tool!
<f1> f
and <f1> v
) at any time.defun
or defvar
, its doc string is available through describe-function
or describe-variable
: this doc is alive!Upvotes: 1
Reputation: 10155
Have you tried the build-in manual in emacs? Open any lisp buffer (or any buffer in lisp mode), move your point to any function or variable, and hit C-h f (for function) or C-h v (for variable). Emacs will give you a fairly concise description of the function/variable.
For example, the manual content for (save-excursion) is
save-excursion is a special form in `C source code'.
(save-excursion &rest BODY)
Save point, mark, and current buffer; execute BODY; restore those things.
Executes BODY just like `progn'.
The values of point, mark and the current buffer are restored
even in case of abnormal exit (throw or error).
The state of activation of the mark is also restored.
This construct does not save `deactivate-mark', and therefore
functions that change the buffer will still cause deactivation
of the mark at the end of the command. To prevent that, bind
`deactivate-mark' with `let'.
The good thing also is the build-in manual give you "link" to to the source code of the function and to other functions that might be related, which make it nice to browse around.
Of course you can't learn lisp this way, but for looking up documentation of function this is a nice starter. When you find the build-in manual not understandable (which sometimes does happen), then it's time for you to google the function ;)
Upvotes: 14
Reputation: 3811
The GNU Introduction to emacs lisp is certainly more approachable than the reference manual.
Upvotes: 11