aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorDrew Adams2017-07-28 10:47:20 +0300
committerEli Zaretskii2017-07-28 10:47:20 +0300
commit353dbbb6682e287fbe8936ca65277af709b90817 (patch)
treef26f93032eadb5c99c569a70483a91e88189c144 /lisp
parent955e0cbb32225a53ac8b5b8f2235fb251d83f49e (diff)
downloademacs-353dbbb6682e287fbe8936ca65277af709b90817.tar.gz
emacs-353dbbb6682e287fbe8936ca65277af709b90817.zip
New commands 'apropos-local-variable', 'apropos-local-value'
* lisp/apropos.el (apropos-local-variable, apropos-local-value): New functions. (Bug#27424) * doc/emacs/help.texi (Apropos): Document 'apropos-local-variable' and 'apropos-local-value'. * etc/NEWS: Mention the new commands.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/apropos.el42
1 files changed, 42 insertions, 0 deletions
diff --git a/lisp/apropos.el b/lisp/apropos.el
index cbd9c71d3e3..86d9b514290 100644
--- a/lisp/apropos.el
+++ b/lisp/apropos.el
@@ -514,6 +514,19 @@ options only, i.e. behave like `apropos-user-option'."
514 (let ((apropos-do-all (if do-not-all nil t))) 514 (let ((apropos-do-all (if do-not-all nil t)))
515 (apropos-user-option pattern))) 515 (apropos-user-option pattern)))
516 516
517;;;###autoload
518(defun apropos-local-variable (pattern &optional buffer)
519 "Show buffer-local variables that match PATTERN.
520Optional arg BUFFER (default: current buffer) is the buffer to check.
521
522The output includes variables that are not yet set in BUFFER, but that
523will be buffer-local when set."
524 (interactive (list (apropos-read-pattern "buffer-local variable")))
525 (unless buffer (setq buffer (current-buffer)))
526 (apropos-command pattern nil (lambda (symbol)
527 (and (local-variable-if-set-p symbol)
528 (get symbol 'variable-documentation)))))
529
517;; For auld lang syne: 530;; For auld lang syne:
518;;;###autoload 531;;;###autoload
519(defalias 'command-apropos 'apropos-command) 532(defalias 'command-apropos 'apropos-command)
@@ -795,6 +808,35 @@ Returns list of symbols and values found."
795 (let ((apropos-multi-type do-all)) 808 (let ((apropos-multi-type do-all))
796 (apropos-print nil "\n----------------\n"))) 809 (apropos-print nil "\n----------------\n")))
797 810
811;;;###autoload
812(defun apropos-local-value (pattern &optional buffer)
813 "Show buffer-local variables whose values match PATTERN.
814This is like `apropos-value', but only for buffer-local variables.
815Optional arg BUFFER (default: current buffer) is the buffer to check."
816 (interactive (list (apropos-read-pattern "value of buffer-local variable")))
817 (unless buffer (setq buffer (current-buffer)))
818 (apropos-parse-pattern pattern)
819 (setq apropos-accumulator ())
820 (let ((var nil))
821 (mapatoms
822 (lambda (symb)
823 (unless (memq symb '(apropos-regexp apropos-pattern apropos-all-words-regexp
824 apropos-words apropos-all-words apropos-accumulator symb var))
825 (setq var (apropos-value-internal 'local-variable-if-set-p symb 'symbol-value)))
826 (when (and (fboundp 'apropos-false-hit-str) (apropos-false-hit-str var))
827 (setq var nil))
828 (when var
829 (setq apropos-accumulator (cons (list symb (apropos-score-str var) nil var)
830 apropos-accumulator))))))
831 (let ((apropos-multi-type nil))
832 (if (> emacs-major-version 20)
833 (apropos-print
834 nil "\n----------------\n"
835 (format "Buffer `%s' has the following local variables\nmatching %s`%s':"
836 (buffer-name buffer)
837 (if (consp pattern) "keywords " "")
838 pattern))
839 (apropos-print nil "\n----------------\n"))))
798 840
799;;;###autoload 841;;;###autoload
800(defun apropos-documentation (pattern &optional do-all) 842(defun apropos-documentation (pattern &optional do-all)