Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a list of Emacs lisp non-interactive functions?

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))))
like image 504
Singletoned Avatar asked Mar 03 '09 09:03

Singletoned


People also ask

What is interactive in Emacs?

interactive is a special form in `C source code'. (interactive args) Specify a way of parsing arguments for interactive use of a function. For example, write (defun foo (arg) "Doc string" (interactive "p") ... use arg...) to make ARG be the prefix argument when `foo' is called as a command.

Is Emacs Lisp compiled or interpreted?

Emacs Lisp has a compiler that translates functions written in Lisp into a special representation called byte-code that can be executed more efficiently. The compiler replaces Lisp function definitions with byte-code. When a byte-code function is called, its definition is evaluated by the byte-code interpreter.

What does #' mean in Emacs Lisp?

#'... is short-hand for (function ...) which is simply a variant of '... / (quote ...) that also hints to the byte-compiler that it can compile the quoted form as a function.


1 Answers

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")))))
like image 51
Jouni K. Seppänen Avatar answered Oct 06 '22 00:10

Jouni K. Seppänen