From: Eshel Yaron Date: Tue, 4 Mar 2025 15:06:04 +0000 (+0100) Subject: Add minibuffer action for 'shortdoc' X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2e8377648931572543f535420b662d4e2f08c875;p=emacs.git Add minibuffer action for 'shortdoc' --- diff --git a/lisp/emacs-lisp/shortdoc.el b/lisp/emacs-lisp/shortdoc.el index 77a4ec4f21c..06e0d3f1b0e 100644 --- a/lisp/emacs-lisp/shortdoc.el +++ b/lisp/emacs-lisp/shortdoc.el @@ -1610,21 +1610,32 @@ A FUNC form can have any number of `:no-eval' (or `:no-value'), If FUNCTION is non-nil, place point on the entry for FUNCTION (if any). If SAME-WINDOW, don't pop to a new window." (interactive (list (completing-read "Show summary for functions in: " - (mapcar #'car shortdoc--groups)))) + shortdoc--groups))) + (funcall (if same-window + #'pop-to-buffer-same-window + #'pop-to-buffer) + (shortdoc-display-group-1 group)) + (goto-char (point-min)) + (when function + (text-property-search-forward 'shortdoc-function function t) + (beginning-of-line))) + +(defun shortdoc-display-group-1 (group) (when (stringp group) (setq group (intern group))) (unless (assq group shortdoc--groups) (error "No such documentation group %s" group)) (let ((buf (get-buffer-create (format "*Shortdoc %s*" group)))) (shortdoc--insert-group-in-buffer group buf) - (funcall (if same-window - #'pop-to-buffer-same-window - #'pop-to-buffer) - buf)) - (goto-char (point-min)) - (when function - (text-property-search-forward 'shortdoc-function function t) - (beginning-of-line))) + buf)) + +(put 'shortdoc-display-group 'minibuffer-action + (cons (lambda (group) + (save-excursion + (when-let ((buf (shortdoc-display-group-1 group)) + (win (display-buffer buf))) + (set-window-point win (with-current-buffer buf (point-min)))))) + "show")) (defun shortdoc--insert-group-in-buffer (group &optional buf) "Insert a short documentation summary for functions in GROUP in buffer BUF.