Subject: bug#33595: [PATCH] RE: bug#33595: 26; Have `try-completion' or `completion--done' run abnormal hook if sole completion

From: Eli Zaretskii <[email-masked]>
Date: Sat, 29 Dec 2018 10:08:25 +0200

> Date: Fri, 28 Dec 2018 10:56:08 -0800 (PST)
> From: Drew Adams <[email-masked]>
> 
> ping.
> 
> Would someone please consider committing this patch?  Thx.

Stefan, any comments?  If okay, I'd like to push this to master.

> diff -u minibuffer.el minibuffer-2018-12-03a-patched.el
> --- minibuffer.el	2018-12-03 09:23:45.858608200 -0800
> +++ minibuffer-2018-12-03a-patched.el	2018-12-03 09:27:17.862397300 -0800
> @@ -753,6 +753,10 @@
>  the second failed attempt to complete."
>    :type '(choice (const nil) (const t) (const lazy)))
>  
> +(defvar completion-sole-match-functions ()
> +  "Functions to be run when completion results in only one match.
> +Each function must accept that completion as its first arg.")
> +
>  (defconst completion-styles-alist
>    '((emacs21
>       completion-emacs21-try-completion completion-emacs21-all-completions
> @@ -1769,6 +1773,8 @@
>    (let* ((exit-fun (plist-get completion-extra-properties :exit-function))
>           (pre-msg (and exit-fun (current-message))))
>      (cl-assert (memq finished '(exact sole finished unknown)))
> +    (when (eq finished 'finished)
> +      (run-hook-with-args 'completion-sole-match-functions string))
>      (when exit-fun
>        (when (eq finished 'unknown)
>          (setq finished
> 
> 
> 
>