From 66a1501042e5d5022efee3029e58d6958c68b786 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Wed, 22 May 2024 22:26:46 +0200 Subject: [PATCH] find-func.el: Multi commands --- lisp/emacs-lisp/find-func.el | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index 411602ef166..ffcd3196259 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el @@ -307,6 +307,19 @@ TYPE should be nil to find a function, or `defvar' to find a variable." (error "Can't find source for %s" fun-or-var)) (cons (current-buffer) (match-beginning 0)))) +(defun display-library (library) + "Display the Emacs Lisp source of LIBRARY. + +Interactively, prompt for LIBRARY using the one at or near point. + +This function searches `find-library-source-path' if non-nil, and +`load-path' otherwise. + +See the `find-library-include-other-files' user option for +customizing the candidate completions." + (interactive (list (read-library-name))) + (display-buffer (find-file-noselect (find-library-name library)))) + ;;;###autoload (defun find-library (library) "Find the Emacs Lisp source of LIBRARY. @@ -323,6 +336,8 @@ customizing the candidate completions." (switch-to-buffer (find-file-noselect (find-library-name library))) (run-hooks 'find-function-after-hook))) +(put 'find-library 'minibuffer-action '(display-library . "find")) + ;;;###autoload (defun read-library-name () "Read and return a library name, defaulting to the one near point. @@ -379,6 +394,8 @@ See `find-library' for more details." (find-library-name library))) (run-hooks 'find-function-after-hook))) +(put 'find-library-other-window 'minibuffer-action 'find-library) + ;;;###autoload (defun find-library-other-frame (library) "Find the Emacs Lisp source of LIBRARY in another frame. @@ -390,6 +407,8 @@ See `find-library' for more details." (find-library-name library))) (run-hooks 'find-function-after-hook))) +(put 'find-library-other-frame 'minibuffer-action 'find-library) + ;;;###autoload (defun find-function-search-for-symbol (symbol type library) "Search for SYMBOL's definition of type TYPE in LIBRARY. @@ -593,11 +612,19 @@ otherwise uses `variable-at-point'." (prompt-type (cdr (assq type '((nil . "function") (defvar . "variable") (defface . "face"))))) + (action this-command) (enable-recursive-minibuffers t)) - (list (intern (completing-read - (format-prompt "Find %s" symb prompt-type) - obarray predicate - 'lambda nil nil (and symb (symbol-name symb))))))) + (list (intern + (minibuffer-with-setup-hook + (lambda () (setq minibuffer-completion-action + (cons (lambda (s) + (save-selected-window + (funcall action (intern s)))) + "find"))) + (completing-read + (format-prompt "Find %s" symb prompt-type) + obarray predicate + 'lambda nil nil (and symb (symbol-name symb)))))))) (defun find-function-do-it (symbol type switch-fn) "Find Emacs Lisp SYMBOL in a buffer and display it. -- 2.39.5