Function: file-cache-minibuffer-complete
file-cache-minibuffer-complete is an autoloaded, interactive and
byte-compiled function defined in filecache.el.gz.
Signature
(file-cache-minibuffer-complete ARG)
Documentation
Complete a filename in the minibuffer using a preloaded cache.
Filecache does two kinds of substitution: it completes on names in
the cache, and, once it has found a unique name, it cycles through
the directories that the name is available in. With a prefix argument,
the name is considered already unique; only the second substitution
(directories) is done.
Probably introduced at or before Emacs version 20.3.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/filecache.el.gz
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Minibuffer functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The prefix argument works around a bug in the minibuffer completion.
;; The completion function doesn't distinguish between the states:
;;
;; "Multiple completions of name" (eg, Makefile, Makefile.in)
;; "Name available in multiple directories" (/tmp/Makefile, ~me/Makefile)
;;
;; The default is to do the former; a prefix arg forces the latter.
;;;###autoload
(defun file-cache-minibuffer-complete (arg)
"Complete a filename in the minibuffer using a preloaded cache.
Filecache does two kinds of substitution: it completes on names in
the cache, and, once it has found a unique name, it cycles through
the directories that the name is available in. With a prefix argument,
the name is considered already unique; only the second substitution
\(directories) is done."
(interactive "P")
(let* ((completion-ignore-case file-cache-completion-ignore-case)
(case-fold-search file-cache-case-fold-search)
(string (file-name-nondirectory (minibuffer-contents)))
(completion (completion-try-completion
string file-cache-alist nil 0)))
(cond
;; If it's the only match, replace the original contents
((or arg (eq completion t))
(file-cache-cycle string))
;; If it's the longest match, insert it
((consp completion)
(let ((newstring (car completion))
(newpoint (cdr completion)))
;; If we've already inserted a unique string, see if the user
;; wants to use that one
(if (and (string= string newstring)
(assoc-string string file-cache-alist
file-cache-ignore-case))
(if (and (eq last-command this-command)
(string= file-cache-last-completion newstring))
(file-cache-cycle newstring)
(minibuffer-message file-cache-non-unique-message)
(setq file-cache-last-completion string))
(setq file-cache-last-completion string)
(let* ((completion-list (completion-all-completions
newstring file-cache-alist nil newpoint))
(base-size (cdr (last completion-list))))
(when base-size
(setcdr (last completion-list) nil))
(if (> (length completion-list) 1)
(progn
(delete-region (- (point-max) (length string)) (point-max))
(insert newstring)
(with-output-to-temp-buffer file-cache-completions-buffer
(display-completion-list completion-list)
;; Add our own setup function to the Completions Buffer
(file-cache-completion-setup-function)))
(file-cache-cycle newstring))))))
;; No match
((eq completion nil)
(minibuffer-message file-cache-no-match-message)))))