diff options
author | Drew Adams <drew.adams@oracle.com> | 2017-07-28 10:47:20 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2017-07-28 10:47:20 +0300 |
commit | 353dbbb6682e287fbe8936ca65277af709b90817 (patch) | |
tree | f26f93032eadb5c99c569a70483a91e88189c144 /lisp/apropos.el | |
parent | 955e0cbb32225a53ac8b5b8f2235fb251d83f49e (diff) | |
download | emacs-353dbbb6682e287fbe8936ca65277af709b90817.tar.gz |
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/apropos.el')
-rw-r--r-- | lisp/apropos.el | 42 |
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'." (let ((apropos-do-all (if do-not-all nil t))) (apropos-user-option pattern))) +;;;###autoload +(defun apropos-local-variable (pattern &optional buffer) + "Show buffer-local variables that match PATTERN. +Optional arg BUFFER (default: current buffer) is the buffer to check. + +The output includes variables that are not yet set in BUFFER, but that +will be buffer-local when set." + (interactive (list (apropos-read-pattern "buffer-local variable"))) + (unless buffer (setq buffer (current-buffer))) + (apropos-command pattern nil (lambda (symbol) + (and (local-variable-if-set-p symbol) + (get symbol 'variable-documentation))))) + ;; For auld lang syne: ;;;###autoload (defalias 'command-apropos 'apropos-command) @@ -795,6 +808,35 @@ Returns list of symbols and values found." (let ((apropos-multi-type do-all)) (apropos-print nil "\n----------------\n"))) +;;;###autoload +(defun apropos-local-value (pattern &optional buffer) + "Show buffer-local variables whose values match PATTERN. +This is like `apropos-value', but only for buffer-local variables. +Optional arg BUFFER (default: current buffer) is the buffer to check." + (interactive (list (apropos-read-pattern "value of buffer-local variable"))) + (unless buffer (setq buffer (current-buffer))) + (apropos-parse-pattern pattern) + (setq apropos-accumulator ()) + (let ((var nil)) + (mapatoms + (lambda (symb) + (unless (memq symb '(apropos-regexp apropos-pattern apropos-all-words-regexp + apropos-words apropos-all-words apropos-accumulator symb var)) + (setq var (apropos-value-internal 'local-variable-if-set-p symb 'symbol-value))) + (when (and (fboundp 'apropos-false-hit-str) (apropos-false-hit-str var)) + (setq var nil)) + (when var + (setq apropos-accumulator (cons (list symb (apropos-score-str var) nil var) + apropos-accumulator)))))) + (let ((apropos-multi-type nil)) + (if (> emacs-major-version 20) + (apropos-print + nil "\n----------------\n" + (format "Buffer `%s' has the following local variables\nmatching %s`%s':" + (buffer-name buffer) + (if (consp pattern) "keywords " "") + pattern)) + (apropos-print nil "\n----------------\n")))) ;;;###autoload (defun apropos-documentation (pattern &optional do-all) |