Function: ecomplete-add-item
ecomplete-add-item is a byte-compiled function defined in
ecomplete.el.gz.
Signature
(ecomplete-add-item TYPE KEY TEXT &optional FORCE)
Documentation
Add item TEXT of TYPE to the database, using KEY as the identifier.
By default, the longest version of TEXT will be preserved, but if FORCE is non-nil, use TEXT exactly as is.
Source Code
;; Defined in /usr/src/emacs/lisp/ecomplete.el.gz
(defun ecomplete-add-item (type key text &optional force)
"Add item TEXT of TYPE to the database, using KEY as the identifier.
By default, the longest version of TEXT will be preserved, but if
FORCE is non-nil, use TEXT exactly as is."
(unless ecomplete-database (ecomplete-setup))
(unless (and ecomplete-filter-regexp
(string-match-p ecomplete-filter-regexp key))
(let ((elems (assq type ecomplete-database))
(now (time-convert nil 'integer))
entry)
(unless elems
(push (setq elems (list type)) ecomplete-database))
(if (setq entry (assoc key (cdr elems)))
(pcase-let ((`(,_key ,count ,_time ,oldtext) entry))
(setcdr entry (list (1+ count) now
;; Preserve the "more complete" text.
(if (or force
(>= (length text) (length oldtext)))
text
oldtext))))
(nconc elems (list (list key 1 now text)))))))