diff options
| author | Drew Adams | 2017-07-28 10:47:20 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-07-28 10:47:20 +0300 |
| commit | 353dbbb6682e287fbe8936ca65277af709b90817 (patch) | |
| tree | f26f93032eadb5c99c569a70483a91e88189c144 | |
| parent | 955e0cbb32225a53ac8b5b8f2235fb251d83f49e (diff) | |
| download | emacs-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.
| -rw-r--r-- | doc/emacs/help.texi | 9 | ||||
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/apropos.el | 42 |
3 files changed, 57 insertions, 0 deletions
diff --git a/doc/emacs/help.texi b/doc/emacs/help.texi index fd6df1c7e53..460ced0d21c 100644 --- a/doc/emacs/help.texi +++ b/doc/emacs/help.texi | |||
| @@ -320,12 +320,21 @@ search for non-customizable variables too. | |||
| 320 | Search for variables. With a prefix argument, search for | 320 | Search for variables. With a prefix argument, search for |
| 321 | customizable variables only. | 321 | customizable variables only. |
| 322 | 322 | ||
| 323 | @item M-x apropos-local-variable | ||
| 324 | @findex apropos-local-variable | ||
| 325 | Search for buffer-local variables. | ||
| 326 | |||
| 323 | @item M-x apropos-value | 327 | @item M-x apropos-value |
| 324 | @findex apropos-value | 328 | @findex apropos-value |
| 325 | Search for variables whose values match the specified pattern. With a | 329 | Search for variables whose values match the specified pattern. With a |
| 326 | prefix argument, search also for functions with definitions matching | 330 | prefix argument, search also for functions with definitions matching |
| 327 | the pattern, and Lisp symbols with properties matching the pattern. | 331 | the pattern, and Lisp symbols with properties matching the pattern. |
| 328 | 332 | ||
| 333 | @item M-x apropos-local-value | ||
| 334 | @findex apropos-local-value | ||
| 335 | Search for buffer-local variables whose values match the specified | ||
| 336 | pattern. | ||
| 337 | |||
| 329 | @item C-h d | 338 | @item C-h d |
| 330 | @kindex C-h d | 339 | @kindex C-h d |
| 331 | @findex apropos-documentation | 340 | @findex apropos-documentation |
| @@ -590,6 +590,12 @@ different buffer while keeping point, mark, markers, and text | |||
| 590 | properties as intact as possible. | 590 | properties as intact as possible. |
| 591 | 591 | ||
| 592 | +++ | 592 | +++ |
| 593 | ** New commands 'apropos-local-variable' and 'apropos-local-value. | ||
| 594 | These are buffer-local versions of 'apropos-variable' and | ||
| 595 | 'apropos-value', respectively. They show buffer-local variables whose | ||
| 596 | names and values, respectively, match a given pattern. | ||
| 597 | |||
| 598 | +++ | ||
| 593 | ** More user control of reordering bidirectional text for display. | 599 | ** More user control of reordering bidirectional text for display. |
| 594 | The two new variables, 'bidi-paragraph-start-re' and | 600 | The two new variables, 'bidi-paragraph-start-re' and |
| 595 | 'bidi-paragraph-separate-re', allow customization of what exactly are | 601 | 'bidi-paragraph-separate-re', allow customization of what exactly are |
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. | ||
| 520 | Optional arg BUFFER (default: current buffer) is the buffer to check. | ||
| 521 | |||
| 522 | The output includes variables that are not yet set in BUFFER, but that | ||
| 523 | will 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. | ||
| 814 | This is like `apropos-value', but only for buffer-local variables. | ||
| 815 | Optional 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) |