(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
This commit is contained in:
Stefan Monnier 2022-03-06 10:14:42 -05:00
parent 68cdb95019
commit 93c2daa33d

View file

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