(defun minibuffer-completion-help (&optional start end)
"Display a list of possible completions of the current minibuffer contents."
(interactive)
- (message "Making completion list...")
- (let* ((start (or start (minibuffer--completion-prompt-end)))
+ (let* ((current (when-let ((win (get-buffer-window "*Completions*" 0)))
+ (get-text-property (window-point win) 'completion--string
+ (get-buffer "*Completions*"))))
+ (prev-next (when current
+ (with-current-buffer "*Completions*"
+ (save-excursion
+ (goto-char (point-min))
+ (text-property-search-forward 'completion--string current t)
+ (cons
+ (save-excursion
+ (when-let ((pm (text-property-search-backward 'completion--string current)))
+ (goto-char (prop-match-end pm))
+ (when-let ((pm (text-property-search-backward 'cursor-face nil)))
+ (goto-char (prop-match-beginning pm))
+ (get-text-property (point) 'completion--string))))
+ (save-excursion
+ (when-let ((pm (text-property-search-forward 'cursor-face nil t)))
+ (goto-char (prop-match-end pm))
+ (get-text-property (point) 'completion--string))))))))
+ (start (or start (minibuffer--completion-prompt-end)))
(end (or end (point-max)))
(string (buffer-substring start end))
(md (completion--field-metadata start))
(if (eq (car bounds) (length result))
'exact 'finished)))))))
- (display-completion-list completions group-fun)))))
+ (display-completion-list completions group-fun)
+ (with-current-buffer standard-output
+ (goto-char (point-min))
+ (when-let
+ ((pm
+ (or (and current (text-property-search-forward 'completion--string current t))
+ (when-let ((next (cdr prev-next)))
+ (text-property-search-forward 'completion--string next t))
+ (when-let ((prev (car prev-next)))
+ (text-property-search-forward 'completion--string prev t)))))
+ (goto-char (prop-match-beginning pm))
+ (setq pm (text-property-search-forward 'cursor-face))
+ (setq-local cursor-face-highlight-nonselected-window t)
+ (set-window-point (get-buffer-window) (prop-match-beginning pm))))))))
nil)))
nil))