unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Phil Sainty <psainty@orcon.net.nz>
To: 53935@debbugs.gnu.org
Subject: bug#53935: 27.2; [PATCH] ecomplete.el: Auto-select when there is only a single option
Date: Fri, 11 Feb 2022 15:47:14 +1300	[thread overview]
Message-ID: <1d908e97443d75dcb94e1e7c9fdcfb79@webmail.orcon.net.nz> (raw)

[-- 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))

             reply	other threads:[~2022-02-11  2:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11  2:47 Phil Sainty [this message]
2022-02-11  6:30 ` bug#53935: 27.2; [PATCH] ecomplete.el: Auto-select when there is only a single option 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1d908e97443d75dcb94e1e7c9fdcfb79@webmail.orcon.net.nz \
    --to=psainty@orcon.net.nz \
    --cc=53935@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).