emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 4cd41ba: Support reverting Apropos buffers (bug#365


From: Basil L. Contovounesios
Subject: [Emacs-diffs] master 4cd41ba: Support reverting Apropos buffers (bug#36588)
Date: Sun, 4 Aug 2019 18:31:36 -0400 (EDT)

branch: master
commit 4cd41ba8def704ce3bd2f3806176815fd696fa57
Author: Basil L. Contovounesios <address@hidden>
Commit: Basil L. Contovounesios <address@hidden>

    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.
---
 lisp/apropos.el | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/lisp/apropos.el b/lisp/apropos.el
index 1b86f5b..79e5a15 100644
--- a/lisp/apropos.el
+++ b/lisp/apropos.el
@@ -212,6 +212,12 @@ docstring.  Each docstring is either nil or a string.")
 Each element is a list of words where the first word is the standard Emacs
 term, and the rest of the words are alternative terms.")
 
+(defvar apropos--current nil
+  "List of current Apropos function followed by its arguments.
+Used by `apropos--revert-buffer' to regenerate the current
+Apropos buffer.  Each Apropos command should ensure it is set
+before `apropos-mode' makes it buffer-local.")
+
 
 ;;; Button types used by apropos
 
@@ -472,10 +478,18 @@ This requires at least two keywords (unless only one was 
given)."
   "Return t if DOC is really matched by the current keywords."
   (apropos-true-hit doc apropos-all-words))
 
+(defun apropos--revert-buffer (_ignore-auto noconfirm)
+  "Regenerate current Apropos buffer using `apropos--current'.
+Intended as a value for `revert-buffer-function'."
+  (when (or noconfirm (yes-or-no-p "Revert apropos buffer? "))
+    (apply #'funcall apropos--current)))
+
 (define-derived-mode apropos-mode special-mode "Apropos"
   "Major mode for following hyperlinks in output of apropos commands.
 
-\\{apropos-mode-map}")
+\\{apropos-mode-map}"
+  (make-local-variable 'apropos--current)
+  (setq-local revert-buffer-function #'apropos--revert-buffer))
 
 (defvar apropos-multi-type t
   "If non-nil, this apropos query concerns multiple types.
@@ -550,6 +564,7 @@ while a list of strings is used as a word list."
                      (if (or current-prefix-arg apropos-do-all)
                          "command or function" "command"))
                     current-prefix-arg))
+  (setq apropos--current (list #'apropos-command pattern do-all var-predicate))
   (apropos-parse-pattern pattern)
   (let ((message
         (let ((standard-output (get-buffer-create "*Apropos*")))
@@ -628,6 +643,7 @@ consider all symbols (if they match PATTERN).
 Returns list of symbols and documentation found."
   (interactive (list (apropos-read-pattern "symbol")
                     current-prefix-arg))
+  (setq apropos--current (list #'apropos pattern do-all))
   (apropos-parse-pattern pattern)
   (apropos-symbols-internal
    (apropos-internal apropos-regexp
@@ -670,6 +686,7 @@ the output includes key-bindings of commands."
                          libs))
                   libs)))
      (list (completing-read "Describe library: " libs nil t))))
+  (setq apropos--current (list #'apropos-library file))
   (let ((symbols nil)
        ;; (autoloads nil)
        (provides nil)
@@ -776,6 +793,7 @@ names and values of properties.
 Returns list of symbols and values found."
   (interactive (list (apropos-read-pattern "value")
                     current-prefix-arg))
+  (setq apropos--current (list #'apropos-value pattern do-all))
   (apropos-parse-pattern pattern)
   (or do-all (setq do-all apropos-do-all))
   (setq apropos-accumulator ())
@@ -815,6 +833,7 @@ 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)))
+  (setq apropos--current (list #'apropos-local-value pattern buffer))
   (apropos-parse-pattern pattern)
   (setq apropos-accumulator  ())
   (let ((var             nil))
@@ -856,6 +875,7 @@ Returns list of symbols and documentation found."
   ;; output, but I cannot see that that is true.
   (interactive (list (apropos-read-pattern "documentation")
                     current-prefix-arg))
+  (setq apropos--current (list #'apropos-documentation pattern do-all))
   (apropos-parse-pattern pattern)
   (or do-all (setq do-all apropos-do-all))
   (setq apropos-accumulator () apropos-files-scanned ())



reply via email to

[Prev in Thread] Current Thread [Next in Thread]