minibuffer-completion-table
minibuffer-completion-predicate))
+(define-obsolete-function-alias 'minibuffer-complete-word
+ 'minibuffer-complete "30.1")
+
(defun completion--in-region-1 (beg end)
;; If the previous command was not this,
;; mark the completion buffer obsolete.
map)))))))))
(defvar minibuffer-confirm-exit-commands
- '( completion-at-point minibuffer-complete
- minibuffer-complete-word)
+ '(completion-at-point minibuffer-complete)
"List of commands which cause an immediately following
`minibuffer-complete-and-exit' to ask for extra confirmation.")
;; Call do-completion, but ignore errors.
(funcall completion-function))))
-(defun completion--try-word-completion (string table predicate point md)
- (let ((comp (completion-try-completion string table predicate point md)))
- (if (not (consp comp))
- comp
-
- ;; If completion finds next char not unique,
- ;; consider adding a space or a hyphen.
- (when (= (length string) (length (car comp)))
- ;; Mark the added char with the `completion-word' property, so it
- ;; can be handled specially by completion styles such as
- ;; partial-completion.
- ;; We used to remove `partial-completion' from completion-styles
- ;; instead, but it was too blunt, leading to situations where SPC
- ;; was the only insertable char at point but minibuffer-complete-word
- ;; refused inserting it.
- (let ((exts (mapcar (lambda (str) (propertize str 'completion-try-word t))
- '(" " "-")))
- (before (substring string 0 point))
- (after (substring string point))
- tem)
- ;; If both " " and "-" lead to completions, prefer " " so SPC behaves
- ;; a bit more like a self-inserting key (bug#17375).
- (while (and exts (not (consp tem)))
- (setq tem (completion-try-completion
- (concat before (pop exts) after)
- table predicate (1+ point) md)))
- (if (consp tem) (setq comp tem))))
-
- ;; Completing a single word is actually more difficult than completing
- ;; as much as possible, because we first have to find the "current
- ;; position" in `completion' in order to find the end of the word
- ;; we're completing. Normally, `string' is a prefix of `completion',
- ;; which makes it trivial to find the position, but with fancier
- ;; completion (plus env-var expansion, ...) `completion' might not
- ;; look anything like `string' at all.
- (let* ((comppoint (cdr comp))
- (completion (car comp))
- (before (substring string 0 point))
- (combined (concat before "\n" completion)))
- ;; Find in completion the longest text that was right before point.
- (when (string-match "\\(.+\\)\n.*?\\1" combined)
- (let* ((prefix (match-string 1 before))
- ;; We used non-greedy match to make `rem' as long as possible.
- (rem (substring combined (match-end 0)))
- ;; Find in the remainder of completion the longest text
- ;; that was right after point.
- (after (substring string point))
- (suffix (if (string-match "\\`\\(.+\\).*\n.*\\1"
- (concat after "\n" rem))
- (match-string 1 after))))
- ;; The general idea is to try and guess what text was inserted
- ;; at point by the completion. Problem is: if we guess wrong,
- ;; we may end up treating as "added by completion" text that was
- ;; actually painfully typed by the user. So if we then cut
- ;; after the first word, we may throw away things the
- ;; user wrote. So let's try to be as conservative as possible:
- ;; only cut after the first word, if we're reasonably sure that
- ;; our guess is correct.
- ;; Note: a quick survey on emacs-devel seemed to indicate that
- ;; nobody actually cares about the "word-at-a-time" feature of
- ;; minibuffer-complete-word, whose real raison-d'ĂȘtre is that it
- ;; tries to add "-" or " ". One more reason to only cut after
- ;; the first word, if we're really sure we're right.
- (when (and (or suffix (zerop (length after)))
- (string-match (concat
- ;; Make submatch 1 as small as possible
- ;; to reduce the risk of cutting
- ;; valuable text.
- ".*" (regexp-quote prefix) "\\(.*?\\)"
- (if suffix (regexp-quote suffix) "\\'"))
- completion)
- ;; The new point in `completion' should also be just
- ;; before the suffix, otherwise something more complex
- ;; is going on, and we're not sure where we are.
- (eq (match-end 1) comppoint)
- ;; (match-beginning 1)..comppoint is now the stretch
- ;; of text in `completion' that was completed at point.
- (string-match "\\W" completion (match-beginning 1))
- ;; Is there really something to cut?
- (> comppoint (match-end 0)))
- ;; Cut after the first word.
- (let ((cutpos (match-end 0)))
- (setq completion (concat (substring completion 0 cutpos)
- (substring completion comppoint)))
- (setq comppoint cutpos)))))
-
- (cons completion comppoint)))))
-
-
-(defun minibuffer-complete-word ()
- "Complete the minibuffer contents at most a single word.
-After one word is completed as much as possible, a space or hyphen
-is added, provided that matches some possible completion.
-Return nil if there is no valid completion, else t."
- (interactive)
- (completion-in-region--single-word
- (minibuffer--completion-prompt-end) (point-max)))
-
-(defun completion-in-region--single-word (beg end)
- (pcase (completion--do-completion beg end #'completion--try-word-completion)
- (#b000 nil)
- (_ t)))
-
(defface completions-annotations '((t :inherit (italic shadow)))
"Face to use for annotations in the *Completions* buffer.
This face is only used if the strings used for completions
"C-o" #'minibuffer-cycle-completion
"C-l" #'minibuffer-restore-completion-input
"C-S-a" #'minibuffer-toggle-completion-ignore-case
- "SPC" #'minibuffer-complete-word
"?" #'minibuffer-completion-help
"<prior>" #'switch-to-completions
"M-v" #'switch-to-completions
"C-j" #'minibuffer-complete-and-exit)
(defvar-keymap minibuffer-local-filename-completion-map
- :doc "Local keymap for minibuffer input with completion for filenames.
-Gets combined either with `minibuffer-local-completion-map' or
-with `minibuffer-local-must-match-map'."
- "SPC" nil)
+ :doc "This variable is obsolete and no longer used.")
+
+(make-obsolete-variable 'minibuffer-local-filename-completion-map
+ nil "30.1")
(defvar-keymap minibuffer-local-ns-map
:doc "Local keymap for the minibuffer when spaces are not allowed."
:type 'string)
(defcustom completion-pcm-complete-word-inserts-delimiters nil
- "Treat the SPC or - inserted by `minibuffer-complete-word' as delimiters.
-Those chars are treated as delimiters if this variable is non-nil.
-I.e. if non-nil, M-x SPC will just insert a \"-\" in the minibuffer, whereas
-if nil, it will list all possible commands in *Completions* because none of
-the commands start with a \"-\" or a SPC."
+ "This variable is obsolete and has no effect."
:version "24.1"
:type 'boolean)
+(make-obsolete-variable 'completion-pcm-complete-word-inserts-delimiters
+ nil "30.1")
+
(defun completion-pcm--pattern-trivial-p (pattern)
(and (stringp (car pattern))
;; It can be followed by `point' and "" and still be trivial.
(p0 p)
(pending nil))
- (while (and (setq p (string-match completion-pcm--delim-wild-regex
- string p))
- (or completion-pcm-complete-word-inserts-delimiters
- ;; If the char was added by minibuffer-complete-word,
- ;; then don't treat it as a delimiter, otherwise
- ;; "M-x SPC" ends up inserting a "-" rather than listing
- ;; all completions.
- (not (get-text-property p 'completion-try-word string))))
+ (while (setq p (string-match completion-pcm--delim-wild-regex string p))
;; Usually, completion-pcm--delim-wild-regex matches a delimiter,
;; meaning that something can be added *before* it, but it can also
;; match a prefix and postfix, in which case something can be added
(1+ (cdr initial-input)))))
(let* ((base-keymap (if require-match
- minibuffer-local-must-match-map
+ minibuffer-local-must-match-map
minibuffer-local-completion-map))
- (keymap (if (memq minibuffer-completing-file-name '(nil lambda))
- base-keymap
- ;; Layer minibuffer-local-filename-completion-map
- ;; on top of the base map.
- (make-composed-keymap
- minibuffer-local-filename-completion-map
- ;; Set base-keymap as the parent, so that nil bindings
- ;; in minibuffer-local-filename-completion-map can
- ;; override bindings in base-keymap.
- base-keymap)))
(keymap (if minibuffer-visible-completions
(make-composed-keymap
(list minibuffer-visible-completions-map
- keymap))
- keymap))
+ base-keymap))
+ base-keymap))
(buffer (current-buffer))
(c-i-c completion-ignore-case)
(result