Function: add-completion-to-tail-if-new
add-completion-to-tail-if-new is a byte-compiled function defined in
completion.el.gz.
Signature
(add-completion-to-tail-if-new STRING)
Documentation
If STRING is not in the database add it to appropriate prefix list.
STRING is added to the end of the appropriate prefix list with
num-uses = 0. The database is unchanged if it is there. STRING must be
longer than completion-prefix-min-length.
This must be very fast.
Returns the completion entry.
Source Code
;; Defined in /usr/src/emacs/lisp/completion.el.gz
;; WRITES
(defun add-completion-to-tail-if-new (string)
"If STRING is not in the database add it to appropriate prefix list.
STRING is added to the end of the appropriate prefix list with
num-uses = 0. The database is unchanged if it is there. STRING must be
longer than `completion-prefix-min-length'.
This must be very fast.
Returns the completion entry."
(or (find-exact-completion string)
;; not there
(let (;; create an entry
(entry (list (make-completion string)))
;; setup the prefix
(prefix-entry (find-cmpl-prefix-entry
(substring cmpl-db-downcase-string 0
completion-prefix-min-length))))
;; The next two forms should happen as a unit (atomically) but
;; no fatal errors should result if that is not the case.
(cond (prefix-entry
;; These two should be atomic, but nothing fatal will happen
;; if they're not.
(setcdr (cmpl-prefix-entry-tail prefix-entry) entry)
(set-cmpl-prefix-entry-tail prefix-entry entry))
(t
(set cmpl-db-prefix-symbol (make-cmpl-prefix-entry entry))))
;; set symbol
(set cmpl-db-symbol (car entry)))))