]> git.eshelyaron.com Git - emacs.git/commitdiff
Add minibuffer action for 'shortdoc'
authorEshel Yaron <me@eshelyaron.com>
Tue, 4 Mar 2025 15:06:04 +0000 (16:06 +0100)
committerEshel Yaron <me@eshelyaron.com>
Tue, 4 Mar 2025 15:06:19 +0000 (16:06 +0100)
lisp/emacs-lisp/shortdoc.el

index 77a4ec4f21c951e7104fff6d4ddd15c0a88ed1eb..06e0d3f1b0e6a64f80f617527811de58f5cdfa0d 100644 (file)
@@ -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.