emacs-diffs
[Top][All Lists]
Advanced

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

master a1f29998bf4: Add history variables for find-func entry points


From: Robert Pluim
Subject: master a1f29998bf4: Add history variables for find-func entry points
Date: Wed, 17 Jul 2024 07:46:22 -0400 (EDT)

branch: master
commit a1f29998bf49c85c2eddc1201657639fdd494ef2
Author: Robert Pluim <rpluim@gmail.com>
Commit: Robert Pluim <rpluim@gmail.com>

    Add history variables for find-func entry points
    
    * lisp/emacs-lisp/find-func.el (find-function--read-history-library):
    New defvar.
    (read-library-name): Use it in 'completing-read' calls.
    (find-function--read-history-function,
    find-function--read-history-variable, find-function--read-history-face):
    New defvars.
    (find-function-read): Use them in 'completing-read' calls.
---
 etc/NEWS                     |  6 ++++++
 lisp/emacs-lisp/find-func.el | 16 +++++++++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index f10f9ae4d65..60bde2abb40 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -30,6 +30,12 @@ applies, and please also update docstrings as needed.
 
 * Changes in Emacs 31.1
 
+---
+** "find-func.el" commands now have history enabled.
+The 'find-function', 'find-library', 'find-face-definition', and
+'find-variable' commands now allow retrieving previous input using the
+usual minibuffer history commands.  Each command has a separate history.
+
 
 * Editing Changes in Emacs 31.1
 
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index ce783983b77..a320a00608d 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -323,6 +323,8 @@ customizing the candidate completions."
       (switch-to-buffer (find-file-noselect (find-library-name library)))
     (run-hooks 'find-function-after-hook)))
 
+(defvar find-function--read-history-library nil)
+
 ;;;###autoload
 (defun read-library-name ()
   "Read and return a library name, defaulting to the one near point.
@@ -351,12 +353,14 @@ if non-nil)."
           (when (and def (not (test-completion def table)))
             (setq def nil))
           (completing-read (format-prompt "Library name" def)
-                           table nil nil nil nil def))
+                           table nil nil nil
+                           find-function--read-history-library def))
       (let ((files (read-library-name--find-files dirs suffixes)))
         (when (and def (not (member def files)))
           (setq def nil))
         (completing-read (format-prompt "Library name" def)
-                         files nil t nil nil def)))))
+                         files nil t nil
+                         find-function--read-history-library def)))))
 
 (defun read-library-name--find-files (dirs suffixes)
   "Return a list of all files in DIRS that match SUFFIXES."
@@ -575,6 +579,10 @@ is non-nil, signal an error instead."
   (let ((func-lib (find-function-library function lisp-only t)))
     (find-function-search-for-symbol (car func-lib) nil (cdr func-lib))))
 
+(defvar find-function--read-history-function nil)
+(defvar find-function--read-history-variable nil)
+(defvar find-function--read-history-face nil)
+
 (defun find-function-read (&optional type)
   "Read and return an interned symbol, defaulting to the one near point.
 
@@ -597,7 +605,9 @@ otherwise uses `variable-at-point'."
     (list (intern (completing-read
                    (format-prompt "Find %s" symb prompt-type)
                    obarray predicate
-                   'lambda nil nil (and symb (symbol-name symb)))))))
+                   'lambda nil
+                   (intern (format "find-function--read-history-%s" 
prompt-type))
+                   (and symb (symbol-name symb)))))))
 
 (defun find-function-do-it (symbol type switch-fn)
   "Find Emacs Lisp SYMBOL in a buffer and display it.



reply via email to

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