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 "") next-func) (define-key local-map (kbd "M-p") prev-func) (define-key local-map (kbd "") 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))