tags:

views:

491

answers:

8

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?

+6  A: 

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

luapyad
That was most useful links I've seen here. Although background on those pages just killing me.
vava
Xah Lee is a talented programmer but he does have some pretty strange ideas about what is and isn't "proper". Just a little warning...
Joe Casadonte
Yeah, I would not take anything he says seriously.His article about the prostitutes he's slept with is pretty good, though.
jrockway
I found Xah's pages useful for about my first 6 months of elisp programming, then I realized his craziness overwhelms the starter-info. In the newsgroups, he's constantly badgering people to update the wiki for him, rewrite Emacs, change terminology to suit his own "in-depth" research, etc.
Michael Paulukonis
+5  A: 

The GNU Introduction to emacs lisp is certainly more approachable than the reference manual.

Greg Ball
Agreed. The OP needs to suck it up and read this. And then the reference.
jrockway
Does not answer the question at all -- why isn't there a manual like an index, instead of purely topical?
Michael Paulukonis
A: 

Don't feel too bad. I've been using Emacs since 1996 and I still don't know a lick of lisp...

dicroce
I think he is trying to learn, rather than being blissfully ignorant.
jrockway
+1  A: 
Alan
+4  A: 

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 ;)

polyglot
I don't know what to look for in the first place so that's not a solution
vava
I overlooked that you wanted a _list_ of functions. But really, the way to get started is start reading lisp code and see what you encounter most often. A lots of lisp is apparently understandable if you have other language experience; all you need is to look up the not self-explanatory functions.
polyglot
+3  A: 

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.

Joe Casadonte
+3  A: 

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-bing, defun*, and so on are all there, and they are very helpful.)

jrockway
While I agree with this approach, I just don't have time for that. What I want is to be able to write small functions to help me with my every day job, not to become expert in Common Lisp programming.
vava
You seem to have plenty of time to waste browsing this site. Cut anhour off that a day and read the Lisp manual instead. Then you'llhave the knowledge needed to solve any problem in Emacs Lisp, whichwill probably save plenty of your time over the years.
jrockway
No, I don't spent more then 10 minutes a day here. And then, there's so much more important stuff than reading huge boring manual without pictures :)
vava
No pictures. That's what I hate about man pages, they don't have pictures. Only some ascii diagrams and no tables.
RamyenHead
M-x elisp-index-search, C-h F, C-h V, C-h K. These are also useful along with the famous C-h v and C-h f.
RamyenHead
+1  A: 

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!

  • Any Lisp function or variable can declare an optional doc string.
  • Almost all standard command or function do declare a usefull doc string.
  • Emacs (like most Lisp systems) allows you to display the doc string of any function or variable (<f1> f and <f1> v) at any time.
  • When displayed, the doc string is browsable, meaning that you can click on symbols to see their doc string, or go to the source of the corresponding function or variable.
  • As soon as you evaluate any defun or defvar, its doc string is available through describe-function or describe-variable: this doc is alive!
Sébastien RoccaSerra