Function: dynamic-completion-mode
dynamic-completion-mode is an autoloaded, interactive and
byte-compiled function defined in completion.el.gz.
Signature
(dynamic-completion-mode &optional ARG)
Documentation
Toggle dynamic word-completion on or off.
When this minor mode is turned on, typing \M-RET or \C-RET
invokes the command complete, which completes the word or
symbol at point using the record of words/symbols you used
previously and the previously-inserted completions. Typing
a word or moving point across it constitutes "using" the
word.
By default, the database of all the dynamic completions that
were inserted by M-x complete (complete) is saved on the file specified
by save-completions-file-name when you exit Emacs, and will
be loaded from that file when this mode is enabled in a future
Emacs session.
The following important options control the various aspects of
this mode: enable-completion, save-completions-flag, and
save-completions-retention-time. Few other less important
options can be found in the completion group.
This is a global minor mode. If called interactively, toggle the
Dynamic-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 \=dynamic-completion-mode)'.
The mode's hook is called both when the mode is enabled and when it is disabled.
Probably introduced at or before Emacs version 20.4.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/completion.el.gz
;;;###autoload
(define-minor-mode dynamic-completion-mode
"Toggle dynamic word-completion on or off.
When this minor mode is turned on, typing \\`M-RET' or \\`C-RET'
invokes the command `complete', which completes the word or
symbol at point using the record of words/symbols you used
previously and the previously-inserted completions. Typing
a word or moving point across it constitutes \"using\" the
word.
By default, the database of all the dynamic completions that
were inserted by \\[complete] is saved on the file specified
by `save-completions-file-name' when you exit Emacs, and will
be loaded from that file when this mode is enabled in a future
Emacs session.
The following important options control the various aspects of
this mode: `enable-completion', `save-completions-flag', and
`save-completions-retention-time'. Few other less important
options can be found in the `completion' group."
:global t
;; This is always good, not specific to dynamic-completion-mode.
(define-key function-key-map [C-return] [?\C-\r])
(dolist (x `((find-file-hook . ,#'completion-find-file-hook)
(pre-command-hook . ,#'completion-before-command)
;; Save completions when killing Emacs.
(kill-emacs-hook . ,#'kill-emacs-save-completions)
(post-self-insert-hook . ,#'completion--post-self-insert)
;; Install the appropriate mode tables.
(lisp-mode-hook . ,#'completion-lisp-mode-hook)
(c-mode-hook . ,#'completion-c-mode-hook)
(fortran-mode-hook . ,#'completion-setup-fortran-mode)))
(if dynamic-completion-mode
(add-hook (car x) (cdr x))
(remove-hook (car x) (cdr x))))
;; "Complete" Key Keybindings. We don't want to use a minor-mode
;; map because these have too high a priority. We could/should
;; probably change the interpretation of minor-mode-map-alist such
;; that a map has lower precedence if the symbol is not buffer-local.
(while completion-saved-bindings
(let ((binding (pop completion-saved-bindings)))
(global-set-key (car binding) (cdr binding))))
(when dynamic-completion-mode
(dolist (binding
'(("\M-\r" . complete)
([?\C-\r] . complete)
;; Tests -
;; (add-completion "cumberland")
;; (add-completion "cumberbund")
;; cum
;; Cumber
;; cumbering
;; cumb
;; Patches to standard keymaps insert completions
([remap kill-region] . completion-kill-region)))
(push (cons (car binding) (lookup-key global-map (car binding)))
completion-saved-bindings)
(global-set-key (car binding) (cdr binding)))
;; Tests --
;; foobarbiz
;; foobar
;; fooquux
;; fooper
(completion-initialize)))