unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#53935: 27.2; [PATCH] ecomplete.el: Auto-select when there is only a single option
@ 2022-02-11  2:47 Phil Sainty
  2022-02-11  6:30 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 9+ messages in thread
From: Phil Sainty @ 2022-02-11  2:47 UTC (permalink / raw)
  To: 53935

[-- Attachment #1: Type: text/plain, Size: 669 bytes --]

I tried out ecomplete for email address completion today(*),
and I found it slightly annoying that when there was only a
single match for the text, I still have to firstly type M-n
to access the completion 'list', and then RET to select the
only available option.

Would the attached patch be a reasonable enhancement?


-Phil

(*) On account of 
https://www.reddit.com/r/emacs/comments/sl33w6/ecomplete_the_emacs_contact_manager_you_were/



In GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw scroll 
bars)
  of 2021-07-12 built on phil-lp
Windowing system distributor 'The X.Org Foundation', version 
11.0.12008000
System Description: Ubuntu 18.04.6 LTS

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ecomplete-auto-select.patch --]
[-- Type: text/x-diff; name=ecomplete-auto-select.patch, Size: 1174 bytes --]

diff --git a/lisp/ecomplete.el b/lisp/ecomplete.el
index 260657e0f7..e011c3210e 100644
--- a/lisp/ecomplete.el
+++ b/lisp/ecomplete.el
@@ -80,6 +80,10 @@ ecomplete-sort-predicate
 		(function-item :tag "Sort by newness" ecomplete-newness)
 		(function :tag "Other")))
 
+(defcustom ecomplete-message-display-abbrev-auto-select t
+  "Whether `message-display-abbrev' should automatically select a sole option."
+  :type 'boolean)
+
 ;;; Internal variables.
 
 (defvar ecomplete-database nil)
@@ -174,6 +178,12 @@ ecomplete-display-matches
 	  (define-key local-map (kbd "<down>") next-func)
 	  (define-key local-map (kbd "M-p") prev-func)
 	  (define-key local-map (kbd "<up>") prev-func)
+          ;; Auto-select when there is only a single option.
+          (when ecomplete-message-display-abbrev-auto-select
+            (save-match-data
+              (when-let ((match (string-match "\\`\\(.+\\)\n" matches)))
+                (when (string= (match-string 0 matches) matches)
+                  (setq selected (match-string 1 matches))))))
 	  (let ((overriding-local-map local-map))
 	    (while (and (null selected)
 			(setq command (read-key-sequence highlight))

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-09-08 12:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-11  2:47 bug#53935: 27.2; [PATCH] ecomplete.el: Auto-select when there is only a single option Phil Sainty
2022-02-11  6:30 ` Lars Ingebrigtsen
2022-02-11  8:28   ` Phil Sainty
2022-02-11 10:24     ` Phil Sainty
2022-09-08 12:53       ` Lars Ingebrigtsen
2022-02-12  6:49     ` Lars Ingebrigtsen
2022-02-12 10:27       ` Phil Sainty
2022-02-13  8:14         ` Lars Ingebrigtsen
2022-02-13 17:24           ` bug#53935: [External] : " Drew Adams

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).