]> git.eshelyaron.com Git - emacs.git/commitdiff
Remove minibuffer up-to-one-word completion
authorEshel Yaron <me@eshelyaron.com>
Fri, 9 Feb 2024 10:15:24 +0000 (11:15 +0100)
committerEshel Yaron <me@eshelyaron.com>
Fri, 9 Feb 2024 10:25:20 +0000 (11:25 +0100)
Deprecate 'minibuffer-complete-word', and cease binding 'SPC' during
minibuffer completion altogether.

* lisp/minibuffer.el (minibuffer-complete-word): Turn it into an
obsolete alias of 'minibuffer-complete'.
(minibuffer-confirm-exit-commands): Remove 'minibuffer-complete-word'.
(completion--try-word-completion): Drop it.
(minibuffer-local-completion-map): Cease binding 'SPC'.
(minibuffer-local-filename-completion-map)
(completion-pcm-complete-word-inserts-delimiters): Deprecate.
(completion-pcm--string->pattern, completing-read-default): Simplify.

* doc/emacs/custom.texi (Minibuffer Maps)
* doc/emacs/mini.texi (Completion Commands)
* doc/lispref/help.texi (Keys in Documentation)
* doc/lispref/minibuf.texi (Completion Commands)
* lisp/emulation/viper-ex.el (viper-complete-filename-or-exit)
* lisp/gnus/mm-decode.el (mm-viewer-completion-map)
* lisp/man.el (Man-completion-table)
* lisp/menu-bar.el (map)
* test/lisp/help-tests.el (help-tests--test-keymap)
(help-tests-substitute-command-keys/keymaps): Adjust.

* etc/NEWS: Announce.

doc/emacs/custom.texi
doc/emacs/mini.texi
doc/lispref/help.texi
doc/lispref/minibuf.texi
etc/NEWS
lisp/emulation/viper-ex.el
lisp/gnus/mm-decode.el
lisp/man.el
lisp/menu-bar.el
lisp/minibuffer.el
test/lisp/help-tests.el

index 4725af0ee5fea431f8501d5bdd6088d8ab591d17..e047782e1500442fd70c0d9951fe46347b87b364 100644 (file)
@@ -1794,7 +1794,6 @@ circumstances.
 @vindex minibuffer-local-ns-map
 @vindex minibuffer-local-completion-map
 @vindex minibuffer-local-must-match-map
-@vindex minibuffer-local-filename-completion-map
   The minibuffer has its own set of local keymaps; they contain various
 completion and exit commands.
 
@@ -1809,10 +1808,6 @@ just like @key{RET}.
 @item
 @code{minibuffer-local-must-match-map} is for strict completion and
 for cautious completion.
-@item
-@code{minibuffer-local-filename-completion-map} is like the two
-previous ones, but specifically for file name completion.
-It does not bind @key{SPC}.
 @end itemize
 
 By default, @key{TAB}, @key{SPC} and @key{?} do completion in
index 89f563ac17a09ad6918fad7066640a5654a27b65..efc26bad226d7f274af051b10296aab9f57285d4 100644 (file)
@@ -349,10 +349,6 @@ when completion is allowed.
 Complete the text in the minibuffer as much as possible; if unable to
 complete, display a list of possible completions
 (@code{minibuffer-complete}).
-@item @key{SPC}
-Complete up to one word from the minibuffer text before point
-(@code{minibuffer-complete-word}).  This command is not available for
-arguments that often include spaces, such as file names.
 @item @key{RET}
 Submit the text in the minibuffer as the argument, possibly completing
 first (@code{minibuffer-complete-and-exit}).  @xref{Completion Exit}.
@@ -397,15 +393,6 @@ match the existing minibuffer text, and attempts to complete as much
 as it can.  @xref{Completion Styles}, for how completion alternatives
 are chosen.
 
-@kindex SPC @r{(completion)}
-@findex minibuffer-complete-word
-  @key{SPC} (@code{minibuffer-complete-word}) completes like
-@key{TAB}, but only up to the next hyphen or space.  If you have
-@samp{auto-f} in the minibuffer and type @key{SPC}, it finds that the
-completion is @samp{auto-fill-mode}, but it only inserts @samp{ill-},
-giving @samp{auto-fill-}.  Another @key{SPC} at this point completes
-all the way to @samp{auto-fill-mode}.
-
 @kindex RET @r{(completion)}
 @findex minibuffer-complete-and-exit
   @key{RET} (@code{minibuffer-complete-and-exit}) submits the text in
index a76bac011b70705dedda552aaab306ea680cf8e5..ba106e5e93b243ade0374f6e3fa5e1d07158e02b 100644 (file)
@@ -422,7 +422,6 @@ specifies a key binding that the command does not actually have.
 @end group
 
 ?               minibuffer-completion-help
-SPC             minibuffer-complete-word
 TAB             minibuffer-complete
 C-j             minibuffer-complete-and-exit
 RET             minibuffer-complete-and-exit
index 86fe44b90dc519bfacab25a7dd3d961c0c061f2b..96143f4126ea1387b549b3f25a9d044342a11d4b 100644 (file)
@@ -1320,13 +1320,6 @@ The confirmation is requested if the user attempts to exit the
 minibuffer immediately after calling any command in this list.
 @end defvar
 
-@deffn Command minibuffer-complete-word
-This function completes the minibuffer contents by at most a single
-word.  Even if the minibuffer contents have only one completion,
-@code{minibuffer-complete-word} does not add any characters beyond the
-first character that is not a word constituent.  @xref{Syntax Tables}.
-@end deffn
-
 @deffn Command minibuffer-complete
 This function completes the minibuffer contents as far as possible.
 @end deffn
@@ -1462,9 +1455,6 @@ keymap makes the following bindings:
 @item @kbd{?}
 @code{minibuffer-completion-help}
 
-@item @key{SPC}
-@code{minibuffer-complete-word}
-
 @item @key{TAB}
 @code{minibuffer-complete}
 
@@ -1528,13 +1518,6 @@ bindings:
 and uses @code{minibuffer-local-completion-map} as its parent keymap.
 @end defvar
 
-@defvar minibuffer-local-filename-completion-map
-This is a sparse keymap that simply unbinds @key{SPC}; because
-filenames can contain spaces.  The function @code{read-file-name}
-combines this keymap with either @code{minibuffer-local-completion-map}
-or @code{minibuffer-local-must-match-map}.
-@end defvar
-
 @defvar minibuffer-beginning-of-buffer-movement
 If non-@code{nil}, the @kbd{M-<} command will move to the end of the
 prompt if point is after the end of the prompt.  If point is at or
index 661267a015025ba52cb9d7d7c9160b36ff67707b..4741b69b5641416fb6b70b8d71ff03d67400046f 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -768,6 +768,12 @@ the file with the whole history of the session.  The default is nil.
 
 ** Minibuffer and Completions
 
+*** 'SPC' in the minibuffer now inserts a space.
+'SPC' no longer completes by word in the minibuffer.  To have 'SPC'
+perform minibuffer completion, add the following form to your init file:
+
+  (keymap-set minibuffer-local-completion-map "SPC" #'minibuffer-complete)
+
 *** New commands 'previous-line-completion' and 'next-line-completion'.
 Bound to '<up>' and '<down>' arrow keys, respectively, they navigate
 the "*Completions*" buffer vertically by lines, wrapping at the
index 11e00aef33dbe0c668f98a8a3d92b6ad072b292c..d585f9499e2e4b992221ecd5d9ce684e9be105a9 100644 (file)
@@ -1071,7 +1071,7 @@ reversed."
         (insert " "))
        (t
         (setq ex-cmdfile nil)
-        (minibuffer-complete-word))))
+        (minibuffer-complete))))
 
 (defun viper-handle-! ()
   (interactive)
index f91755e967b67a5f22994bb31b69b7fec554dde1..defc9cceb4a3610c448d563a0e229cf6220b27c7 100644 (file)
@@ -538,7 +538,6 @@ result of the verification."
 (defvar mm-viewer-completion-map
   (let ((map (make-sparse-keymap 'mm-viewer-completion-map)))
     (set-keymap-parent map minibuffer-local-completion-map)
-    ;; Should we bind other key to minibuffer-complete-word?
     (define-key map " " 'self-insert-command)
     map)
   "Keymap for input viewer with completion.")
index d96396483d393ec74b13aec5479f07acb59267fb..6f5a8094aa3594c0eed753d44ad125565db4fd72 100644 (file)
@@ -980,7 +980,7 @@ foo(sec)[, bar(sec) [, ...]] [other stuff] - description"
    ;; require-match anyway, there's not point being clever.
    ;;((eq action 'lambda) (not (string-match "([^)]*\\'" string)))
    ((equal string "-k")
-    ;; Let SPC (minibuffer-complete-word) insert the space.
+    ;; Let SPC insert the space.
     (complete-with-action action '("-k ") string pred))
    (t
     (let ((table (cdr Man-completion-cache))
index 05de0578bec19f541a553dbed86aa5784557a9fc..71dfe1cddec1c90ba42b9f9584326e523dd878f8 100644 (file)
@@ -2597,9 +2597,6 @@ It must accept a buffer as its only required argument.")
   (bindings--define-key map [menu-bar minibuf ?\?]
     '(menu-item "List Completions" minibuffer-completion-help
                :help "Display all possible completions"))
-  (bindings--define-key map [menu-bar minibuf space]
-    '(menu-item "Complete Word" minibuffer-complete-word
-               :help "Complete at most one word"))
   (bindings--define-key map [menu-bar minibuf tab]
     '(menu-item "Complete" minibuffer-complete
                :help "Complete as far as possible")))
index c1b407d09546c6cab80b62f5342e249c9004fd63..daee432b04d4f96c08dfda013d2082c1a86ffe0b 100644 (file)
@@ -1679,6 +1679,9 @@ scroll the window of possible completions."
                         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.
@@ -2074,8 +2077,7 @@ DONT-CYCLE tells the function not to setup cycling."
                    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.")
 
@@ -2178,109 +2180,6 @@ appear to be a match."
     ;; 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
@@ -3468,7 +3367,6 @@ The completion method is determined by `completion-at-point-functions'."
   "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
@@ -3487,10 +3385,10 @@ The completion method is determined by `completion-at-point-functions'."
   "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."
@@ -4404,14 +4302,13 @@ expression (not containing character ranges like `a-z')."
   :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.
@@ -4436,14 +4333,7 @@ or a symbol, see `completion-pcm--merge-completions'."
            (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
@@ -5271,23 +5161,13 @@ See `completing-read' for the meaning of the arguments."
                 (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
index f27fa979ef0adb02cfb8822b13379d7c97a4db02..a6b0a3ece813194c8b390fa61412a21ce4fde172 100644 (file)
   "TAB"           #'minibuffer-complete
   "C-j"           #'minibuffer-complete-and-exit
   "RET"           #'minibuffer-complete-and-exit
-  "SPC"           #'minibuffer-complete-word
   "?"             #'minibuffer-completion-help
   "C-<tab>"       #'file-cache-minibuffer-complete
   "<XF86Back>"    #'previous-history-element
@@ -158,7 +157,6 @@ C-g         abort-minibuffers
 TAB            minibuffer-complete
 C-j            minibuffer-complete-and-exit
 RET            minibuffer-complete-and-exit
-SPC            minibuffer-complete-word
 \\?            minibuffer-completion-help
 C-<tab>                file-cache-minibuffer-complete
 <XF86Back>     previous-history-element