views:

285

answers:

6

How do I get a complete list of non-interactive functions that I can use in Emacs Lisp?

The interactive ones are easy enough to find in the help system, but I want a complete list of all the other functions I can use. For example concat, car, cdr, etc. (And preferably with documentation).

Thanks

Ed

Edit: Answered thanks to Jouni. I played around with his answer a bit, and got it to sort the results (using the results of his code to help me find the correct sorting function!)

(flet ((first-line (text)
                   (if text
                       (substring text 0 (string-match "\n" text))
                     "")))
  (let ((funclist (list)))
    (mapatoms 
     (lambda (x)
       (and (fboundp x)                     ; does x name a function?
            (not (commandp (symbol-function x))) ; is it non-interactive?
            (subrp (symbol-function x))          ; is it built-in?
            (add-to-list 'funclist 
                         (concat (symbol-name x) " - " (first-line (documentation x))
                                 "\n")))))
    (dolist (item (sort funclist 'string<))
      (insert item))))
+1  A: 

you could do worse than look at the website

dsm
I have done, quite a lot, but I can't seem to find a listing of functions. There is a page which is a listing of absolutely everything, but not one for functions. And I was hoping there would be something built into emacs.
Singletoned
A: 

Try the apropos command with an empty input.

starblue
That lists everything, and C-h f would be better from that point of view.
Singletoned
Sorry, it doesn't list everything. Turns out it doesn't include non-interactive commands at all.
Singletoned
Look at apropos.el and write your own then.
starblue
A: 

Nevermind. It turns out that C-h f (describe function) does include non-interactive functions, though I'd still be interested in finding a way of viewing/searching only the non-interactive ones (especially only the built in ones).

Singletoned
A: 

You could check the contents of obarray, though that contains all symbols, rather than "all functions".

Alternatively, the following may do the trick (will pull in parts of the CL compatability package):

(reduce (lambda (so-far next) (if (fboundp next) (cons next so-far) so-far)) obarray :initial-value nil)
Vatine
+4  A: 

Here's the basic idea - see the Emacs Lisp manual for any unclear concepts.

(flet ((first-line (text)
         (if text
             (substring text 0 (string-match "\n" text))
           "")))
  (mapatoms 
   (lambda (x)
     (and (fboundp x)                          ; does x name a function?
          (not (commandp (symbol-function x))) ; is it non-interactive?
          (subrp (symbol-function x))          ; is it built-in?
          (insert (symbol-name x) " - " (first-line (documentation x)) "\n")))))
Jouni K. Seppänen
Wow, that's brilliant. I learnt about ten new things just from that short piece of code. Thanks.
Singletoned
+1  A: 

Try apropos instead of apropos-command. That will give you all the functions, not just the interactive ones. C-h a is bound by default to the latter, but if you're doing a lot of elisp hacking, I recommend binding it to the former.

Ryan Thompson