Function: partial-completion-mode
partial-completion-mode is an interactive and byte-compiled function
defined in complete.el.gz.
Signature
(partial-completion-mode &optional ARG)
Documentation
Toggle Partial Completion mode.
This is a minor mode. If called interactively, toggle the
Partial-Completion mode mode. If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.
If called from Lisp, toggle the mode if ARG is toggle. Enable the
mode if ARG is nil, omitted, or is a positive number. Disable the
mode if ARG is a negative number.
To check whether the minor mode is enabled in the current buffer,
evaluate (default-value \=partial-completion-mode)'.
The mode's hook is called both when the mode is enabled and when it is disabled.
When Partial Completion mode is enabled, TAB (or M-TAB if PC-meta-flag is
nil) is enhanced so that if some string is divided into words and each word is
delimited by a character in PC-word-delimiters, partial words are completed
as much as possible and * characters are treated likewise in file names.
For example, M-x p-c-m expands to M-x partial-completion-mode since no other
command begins with that sequence of characters, and
C-x C-f (find-file) f_b.c TAB might complete to foo_bar.c if that file existed and no
other file in that directory begins with that sequence of characters.
Unless PC-disable-includes is non-nil, the <...> sequence is interpreted
specially in C-x C-f (find-file). For example,
C-x C-f (find-file) <sys/time.h> RET finds the file /usr/include/sys/time.h.
See also the variable PC-include-file-path(var)/PC-include-file-path(fun).
Partial Completion mode extends the meaning of completion-auto-help (which
see), so that if it is neither nil nor t, Emacs shows the *Completions*
buffer only on the second attempt to complete. That is, if TAB finds nothing
to complete, the first TAB just says "Next char not unique" and the
second TAB brings up the *Completions* buffer.
Probably introduced at or before Emacs version 20.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/obsolete/complete.el.gz
;;;###autoload
(define-minor-mode partial-completion-mode
"Toggle Partial Completion mode.
When Partial Completion mode is enabled, TAB (or M-TAB if `PC-meta-flag' is
nil) is enhanced so that if some string is divided into words and each word is
delimited by a character in `PC-word-delimiters', partial words are completed
as much as possible and `*' characters are treated likewise in file names.
For example, M-x p-c-m expands to M-x partial-completion-mode since no other
command begins with that sequence of characters, and
\\[find-file] f_b.c TAB might complete to foo_bar.c if that file existed and no
other file in that directory begins with that sequence of characters.
Unless `PC-disable-includes' is non-nil, the `<...>' sequence is interpreted
specially in \\[find-file]. For example,
\\[find-file] <sys/time.h> RET finds the file `/usr/include/sys/time.h'.
See also the variable `PC-include-file-path'.
Partial Completion mode extends the meaning of `completion-auto-help' (which
see), so that if it is neither nil nor t, Emacs shows the `*Completions*'
buffer only on the second attempt to complete. That is, if TAB finds nothing
to complete, the first TAB just says \"Next char not unique\" and the
second TAB brings up the `*Completions*' buffer."
:global t
;; Deal with key bindings...
(PC-bindings partial-completion-mode)
;; Deal with include file feature...
(cond ((not partial-completion-mode)
(remove-hook 'find-file-not-found-functions
#'PC-look-for-include-file))
((not PC-disable-includes)
(add-hook 'find-file-not-found-functions #'PC-look-for-include-file)))
;; Adjust the completion selection in *Completion* buffers to the way
;; we work. The default minibuffer completion code only completes the
;; text before point and leaves the text after point alone (new in
;; Emacs-22). In contrast we use the whole text and we even sometimes
;; move point to a place before EOB, to indicate the first position where
;; there's a difference, so when the user uses choose-completion, we have
;; to trick choose-completion into replacing the whole minibuffer text
;; rather than only the text before point. --Stef
(funcall
(if partial-completion-mode #'add-hook #'remove-hook)
'choose-completion-string-functions
(lambda (_choice buffer &rest _)
;; When completing M-: (lisp- ) with point before the ), it is
;; not appropriate to go to point-max (unlike the filename case).
(if (and (not PC-goto-end)
(minibufferp buffer))
(goto-char (point-max))
;; Need a similar hack for the non-minibuffer-case -- gm.
(when PC-do-completion-end
(goto-char PC-do-completion-end)
(setq PC-do-completion-end nil)))
(setq PC-goto-end nil)
nil))
;; Build the env-completion and mapping table.
(when (and partial-completion-mode (null PC-env-vars-alist))
(setq PC-env-vars-alist
(mapcar (lambda (string)
(let ((d (string-search "=" string)))
(cons (concat "$" (substring string 0 d))
(and d (substring string (1+ d))))))
process-environment))))