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.