diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2022-03-06 10:14:42 -0500 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2022-03-06 10:14:42 -0500 |
commit | 93c2daa33d3aac7c61f322c9d21f3ccab7bdcd4a (patch) | |
tree | d18b654d814bc66f685ccb0790963cb101abf40a /lisp/ecomplete.el | |
parent | 68cdb95019a24024e6000ae75de6aa974d9b4a23 (diff) | |
download | emacs-93c2daa33d3aac7c61f322c9d21f3ccab7bdcd4a.tar.gz emacs-93c2daa33d3aac7c61f322c9d21f3ccab7bdcd4a.tar.bz2 emacs-93c2daa33d3aac7c61f322c9d21f3ccab7bdcd4a.zip |
(ecomplete-add-item): Preserve the more complete text
Avoid replacing "John Doe <john@doe.ch>" with "john@doe.ch".
* lisp/ecomplete.el (ecomplete-add-item): Keep the longest text
Diffstat (limited to 'lisp/ecomplete.el')
-rw-r--r-- | lisp/ecomplete.el | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lisp/ecomplete.el b/lisp/ecomplete.el index c39c6c2ff9c..d5f3fc77560 100644 --- a/lisp/ecomplete.el +++ b/lisp/ecomplete.el @@ -103,7 +103,11 @@ string that was matched." (unless elems (push (setq elems (list type)) ecomplete-database)) (if (setq entry (assoc key (cdr elems))) - (setcdr entry (list (1+ (cadr entry)) now text)) + (pcase-let ((`(,_key ,count ,_time ,oldtext) entry)) + (setcdr entry (list (1+ count) now + ;; Preserve the "more complete" text. + (if (>= (length text) (length oldtext)) + text oldtext)))) (nconc elems (list (list key 1 now text)))))) (defun ecomplete-get-item (type key) |