aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Pluim2024-07-16 16:05:40 +0200
committerRobert Pluim2024-07-17 10:56:17 +0200
commita1f29998bf49c85c2eddc1201657639fdd494ef2 (patch)
tree53ead7892e3e508947427a2e66d583f46b1b4d85
parent5684fc5207e15adc2647a08bb9e6205fde112fa6 (diff)
downloademacs-a1f29998bf49c85c2eddc1201657639fdd494ef2.tar.gz
emacs-a1f29998bf49c85c2eddc1201657639fdd494ef2.zip
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.
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/emacs-lisp/find-func.el16
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.
30 30
31* Changes in Emacs 31.1 31* Changes in Emacs 31.1
32 32
33---
34** "find-func.el" commands now have history enabled.
35The 'find-function', 'find-library', 'find-face-definition', and
36'find-variable' commands now allow retrieving previous input using the
37usual minibuffer history commands. Each command has a separate history.
38
33 39
34* Editing Changes in Emacs 31.1 40* Editing Changes in Emacs 31.1
35 41
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."
323 (switch-to-buffer (find-file-noselect (find-library-name library))) 323 (switch-to-buffer (find-file-noselect (find-library-name library)))
324 (run-hooks 'find-function-after-hook))) 324 (run-hooks 'find-function-after-hook)))
325 325
326(defvar find-function--read-history-library nil)
327
326;;;###autoload 328;;;###autoload
327(defun read-library-name () 329(defun read-library-name ()
328 "Read and return a library name, defaulting to the one near point. 330 "Read and return a library name, defaulting to the one near point.
@@ -351,12 +353,14 @@ if non-nil)."
351 (when (and def (not (test-completion def table))) 353 (when (and def (not (test-completion def table)))
352 (setq def nil)) 354 (setq def nil))
353 (completing-read (format-prompt "Library name" def) 355 (completing-read (format-prompt "Library name" def)
354 table nil nil nil nil def)) 356 table nil nil nil
357 find-function--read-history-library def))
355 (let ((files (read-library-name--find-files dirs suffixes))) 358 (let ((files (read-library-name--find-files dirs suffixes)))
356 (when (and def (not (member def files))) 359 (when (and def (not (member def files)))
357 (setq def nil)) 360 (setq def nil))
358 (completing-read (format-prompt "Library name" def) 361 (completing-read (format-prompt "Library name" def)
359 files nil t nil nil def))))) 362 files nil t nil
363 find-function--read-history-library def)))))
360 364
361(defun read-library-name--find-files (dirs suffixes) 365(defun read-library-name--find-files (dirs suffixes)
362 "Return a list of all files in DIRS that match SUFFIXES." 366 "Return a list of all files in DIRS that match SUFFIXES."
@@ -575,6 +579,10 @@ is non-nil, signal an error instead."
575 (let ((func-lib (find-function-library function lisp-only t))) 579 (let ((func-lib (find-function-library function lisp-only t)))
576 (find-function-search-for-symbol (car func-lib) nil (cdr func-lib)))) 580 (find-function-search-for-symbol (car func-lib) nil (cdr func-lib))))
577 581
582(defvar find-function--read-history-function nil)
583(defvar find-function--read-history-variable nil)
584(defvar find-function--read-history-face nil)
585
578(defun find-function-read (&optional type) 586(defun find-function-read (&optional type)
579 "Read and return an interned symbol, defaulting to the one near point. 587 "Read and return an interned symbol, defaulting to the one near point.
580 588
@@ -597,7 +605,9 @@ otherwise uses `variable-at-point'."
597 (list (intern (completing-read 605 (list (intern (completing-read
598 (format-prompt "Find %s" symb prompt-type) 606 (format-prompt "Find %s" symb prompt-type)
599 obarray predicate 607 obarray predicate
600 'lambda nil nil (and symb (symbol-name symb))))))) 608 'lambda nil
609 (intern (format "find-function--read-history-%s" prompt-type))
610 (and symb (symbol-name symb)))))))
601 611
602(defun find-function-do-it (symbol type switch-fn) 612(defun find-function-do-it (symbol type switch-fn)
603 "Find Emacs Lisp SYMBOL in a buffer and display it. 613 "Find Emacs Lisp SYMBOL in a buffer and display it.