diff options
| author | Basil L. Contovounesios | 2019-07-11 15:11:35 +0100 |
|---|---|---|
| committer | Basil L. Contovounesios | 2019-08-05 01:19:51 +0300 |
| commit | 4cd41ba8def704ce3bd2f3806176815fd696fa57 (patch) | |
| tree | 5e6c8ed57041968abfb574132b8f0a6891c6286a | |
| parent | a5b796a8798a809044d847568e6472cc5eca077e (diff) | |
| download | emacs-4cd41ba8def704ce3bd2f3806176815fd696fa57.tar.gz emacs-4cd41ba8def704ce3bd2f3806176815fd696fa57.zip | |
Support reverting Apropos buffers (bug#36588)
* lisp/apropos.el (apropos--current): New variable akin to
help-xref-stack-item storing information for revert-buffer.
(apropos--revert-buffer): New function.
(apropos-mode): Use it as revert-buffer-function.
(apropos-command, apropos, apropos-library, apropos-value)
(apropos-local-value, apropos-documentation): Set apropos--current
in low-level commands, i.e., those which do not call other commands.
| -rw-r--r-- | lisp/apropos.el | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lisp/apropos.el b/lisp/apropos.el index 1b86f5bcde3..79e5a1518fe 100644 --- a/lisp/apropos.el +++ b/lisp/apropos.el | |||
| @@ -212,6 +212,12 @@ docstring. Each docstring is either nil or a string.") | |||
| 212 | Each element is a list of words where the first word is the standard Emacs | 212 | Each element is a list of words where the first word is the standard Emacs |
| 213 | term, and the rest of the words are alternative terms.") | 213 | term, and the rest of the words are alternative terms.") |
| 214 | 214 | ||
| 215 | (defvar apropos--current nil | ||
| 216 | "List of current Apropos function followed by its arguments. | ||
| 217 | Used by `apropos--revert-buffer' to regenerate the current | ||
| 218 | Apropos buffer. Each Apropos command should ensure it is set | ||
| 219 | before `apropos-mode' makes it buffer-local.") | ||
| 220 | |||
| 215 | 221 | ||
| 216 | ;;; Button types used by apropos | 222 | ;;; Button types used by apropos |
| 217 | 223 | ||
| @@ -472,10 +478,18 @@ This requires at least two keywords (unless only one was given)." | |||
| 472 | "Return t if DOC is really matched by the current keywords." | 478 | "Return t if DOC is really matched by the current keywords." |
| 473 | (apropos-true-hit doc apropos-all-words)) | 479 | (apropos-true-hit doc apropos-all-words)) |
| 474 | 480 | ||
| 481 | (defun apropos--revert-buffer (_ignore-auto noconfirm) | ||
| 482 | "Regenerate current Apropos buffer using `apropos--current'. | ||
| 483 | Intended as a value for `revert-buffer-function'." | ||
| 484 | (when (or noconfirm (yes-or-no-p "Revert apropos buffer? ")) | ||
| 485 | (apply #'funcall apropos--current))) | ||
| 486 | |||
| 475 | (define-derived-mode apropos-mode special-mode "Apropos" | 487 | (define-derived-mode apropos-mode special-mode "Apropos" |
| 476 | "Major mode for following hyperlinks in output of apropos commands. | 488 | "Major mode for following hyperlinks in output of apropos commands. |
| 477 | 489 | ||
| 478 | \\{apropos-mode-map}") | 490 | \\{apropos-mode-map}" |
| 491 | (make-local-variable 'apropos--current) | ||
| 492 | (setq-local revert-buffer-function #'apropos--revert-buffer)) | ||
| 479 | 493 | ||
| 480 | (defvar apropos-multi-type t | 494 | (defvar apropos-multi-type t |
| 481 | "If non-nil, this apropos query concerns multiple types. | 495 | "If non-nil, this apropos query concerns multiple types. |
| @@ -550,6 +564,7 @@ while a list of strings is used as a word list." | |||
| 550 | (if (or current-prefix-arg apropos-do-all) | 564 | (if (or current-prefix-arg apropos-do-all) |
| 551 | "command or function" "command")) | 565 | "command or function" "command")) |
| 552 | current-prefix-arg)) | 566 | current-prefix-arg)) |
| 567 | (setq apropos--current (list #'apropos-command pattern do-all var-predicate)) | ||
| 553 | (apropos-parse-pattern pattern) | 568 | (apropos-parse-pattern pattern) |
| 554 | (let ((message | 569 | (let ((message |
| 555 | (let ((standard-output (get-buffer-create "*Apropos*"))) | 570 | (let ((standard-output (get-buffer-create "*Apropos*"))) |
| @@ -628,6 +643,7 @@ consider all symbols (if they match PATTERN). | |||
| 628 | Returns list of symbols and documentation found." | 643 | Returns list of symbols and documentation found." |
| 629 | (interactive (list (apropos-read-pattern "symbol") | 644 | (interactive (list (apropos-read-pattern "symbol") |
| 630 | current-prefix-arg)) | 645 | current-prefix-arg)) |
| 646 | (setq apropos--current (list #'apropos pattern do-all)) | ||
| 631 | (apropos-parse-pattern pattern) | 647 | (apropos-parse-pattern pattern) |
| 632 | (apropos-symbols-internal | 648 | (apropos-symbols-internal |
| 633 | (apropos-internal apropos-regexp | 649 | (apropos-internal apropos-regexp |
| @@ -670,6 +686,7 @@ the output includes key-bindings of commands." | |||
| 670 | libs)) | 686 | libs)) |
| 671 | libs))) | 687 | libs))) |
| 672 | (list (completing-read "Describe library: " libs nil t)))) | 688 | (list (completing-read "Describe library: " libs nil t)))) |
| 689 | (setq apropos--current (list #'apropos-library file)) | ||
| 673 | (let ((symbols nil) | 690 | (let ((symbols nil) |
| 674 | ;; (autoloads nil) | 691 | ;; (autoloads nil) |
| 675 | (provides nil) | 692 | (provides nil) |
| @@ -776,6 +793,7 @@ names and values of properties. | |||
| 776 | Returns list of symbols and values found." | 793 | Returns list of symbols and values found." |
| 777 | (interactive (list (apropos-read-pattern "value") | 794 | (interactive (list (apropos-read-pattern "value") |
| 778 | current-prefix-arg)) | 795 | current-prefix-arg)) |
| 796 | (setq apropos--current (list #'apropos-value pattern do-all)) | ||
| 779 | (apropos-parse-pattern pattern) | 797 | (apropos-parse-pattern pattern) |
| 780 | (or do-all (setq do-all apropos-do-all)) | 798 | (or do-all (setq do-all apropos-do-all)) |
| 781 | (setq apropos-accumulator ()) | 799 | (setq apropos-accumulator ()) |
| @@ -815,6 +833,7 @@ This is like `apropos-value', but only for buffer-local variables. | |||
| 815 | Optional arg BUFFER (default: current buffer) is the buffer to check." | 833 | Optional arg BUFFER (default: current buffer) is the buffer to check." |
| 816 | (interactive (list (apropos-read-pattern "value of buffer-local variable"))) | 834 | (interactive (list (apropos-read-pattern "value of buffer-local variable"))) |
| 817 | (unless buffer (setq buffer (current-buffer))) | 835 | (unless buffer (setq buffer (current-buffer))) |
| 836 | (setq apropos--current (list #'apropos-local-value pattern buffer)) | ||
| 818 | (apropos-parse-pattern pattern) | 837 | (apropos-parse-pattern pattern) |
| 819 | (setq apropos-accumulator ()) | 838 | (setq apropos-accumulator ()) |
| 820 | (let ((var nil)) | 839 | (let ((var nil)) |
| @@ -856,6 +875,7 @@ Returns list of symbols and documentation found." | |||
| 856 | ;; output, but I cannot see that that is true. | 875 | ;; output, but I cannot see that that is true. |
| 857 | (interactive (list (apropos-read-pattern "documentation") | 876 | (interactive (list (apropos-read-pattern "documentation") |
| 858 | current-prefix-arg)) | 877 | current-prefix-arg)) |
| 878 | (setq apropos--current (list #'apropos-documentation pattern do-all)) | ||
| 859 | (apropos-parse-pattern pattern) | 879 | (apropos-parse-pattern pattern) |
| 860 | (or do-all (setq do-all apropos-do-all)) | 880 | (or do-all (setq do-all apropos-do-all)) |
| 861 | (setq apropos-accumulator () apropos-files-scanned ()) | 881 | (setq apropos-accumulator () apropos-files-scanned ()) |