emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 93c2daa33d: (ecomplete-add-item): Preserve the more complete text


From: Stefan Monnier
Subject: master 93c2daa33d: (ecomplete-add-item): Preserve the more complete text
Date: Sun, 6 Mar 2022 10:14:50 -0500 (EST)

branch: master
commit 93c2daa33d3aac7c61f322c9d21f3ccab7bdcd4a
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    (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
---
 lisp/ecomplete.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/ecomplete.el b/lisp/ecomplete.el
index c39c6c2ff9..d5f3fc7756 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]