functions-table and variables-table

TorgoX on 2006-07-17T08:45:13

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