Created
May 21, 2011 00:23
-
-
Save vsbuffalo/984062 to your computer and use it in GitHub Desktop.
List all ESS variables in the current buffer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; From Michael Hannon and Vince Buffalo | |
(require 'cl) | |
(defun flatten (list) ; From `misc-fns.el'. | |
"Flatten LIST, returning a list with the atoms in LIST at any level. | |
Also works for a consp whose cdr is non-nil. | |
Borrowed from: http://www.emacswiki.org/emacs/lib-requires.el" | |
(cond ((null list) nil) | |
((atom list) list) | |
(t | |
(let ((old list) | |
(new ()) | |
item) | |
(while old | |
(if (atom old) ; From consp with non-nil cdr. | |
(setq item old | |
old nil) | |
(setq item (car old) | |
old (cdr old))) | |
;; Make item atomic. | |
(while (consp item) | |
(if (cdr item) | |
(setq old (cons (cdr item) old))) | |
(setq item (car item))) | |
(setq new (cons item new))) | |
(reverse new))))) | |
(defun make-sep () | |
(list (string ?\n) | |
(string ?\n) | |
(make-string 48 ?#) | |
(string ?\n) | |
(string ?\n))) | |
(defun print-var-desc(next-var) | |
(list (flatten (make-sep)) | |
(describe-variable next-var))) | |
(let (vars) | |
(do-symbols (s) (when (and (boundp s) (eq (string-match "ess-" (symbol-name s)) 0)) | |
(push s vars))) | |
(insert (format "%s" (flatten (mapcar (lambda (s) (print-var-desc s)) vars))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment