Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

TorgoX (1933)

TorgoX
  sburkeNO@SPAMcpan.org
http://search.cpan.org/~sburke/

"Il est beau comme la retractilité des serres des oiseaux rapaces [...] et surtout, comme la rencontre fortuite sur une table de dissection d'une machine à coudre et d'un parapluie !" -- Lautréamont

Journal of TorgoX (1933)

Monday July 17, 2006
03:45 AM

functions-table and variables-table

[ #30312 ]
Dear Log,

Today's Elisp dalliance:

(defun functions-table ()
  "Make a list of all functions"
  (interactive)
  (symbols-report "*Functions*" 'fboundp))

(defun variables-table ()
  "Make a list of all variables"
  (interactive)
  (symbols-report "*Variables*" 'boundp))

(defalias 'function-table 'functions-table)
(defalias 'variable-table 'variables-table)

(byte-compile
(defun symbols-report (bufname pred)
  (switch-to-buffer bufname)
  (erase-buffer)
  (let (syms)
    (mapatoms
     ; ^^ for each symbol in obarray
     ;  (in no special order)
     (f_x
      (when (apply pred (list x))
    (setq syms (cons (symbol-to-string x) syms)))))
    (setq syms (sort syms 'string<))
    (dolist (sym syms)
      (insert (concat sym "\n")))))
)

I'm lazy and haven't made those thingies actually link to the describe-function or describe-variable screens for each.

Edit: Addendum:

(defmacro f_x (&rest Body)
  "Make these expressions a function with 'x' holding its one parameter"
  (list 'function (cons 'lambda (cons (cons 'x nil) Body))))