]> git.eshelyaron.com Git - emacs.git/commitdiff
Force completion in icomplete with C-M-i, but don't cycle (bug#34077)
authorJoão Távora <joaotavora@gmail.com>
Wed, 23 Jan 2019 16:30:41 +0000 (16:30 +0000)
committerJoão Távora <joaotavora@gmail.com>
Wed, 23 Jan 2019 16:31:11 +0000 (16:31 +0000)
Cycling after forcing a completion with C-M-i in icomplete can be
confusing, as it leaves rotated prospects in the minibuffer.  In C-x
C-f, for example it is very difficult to understand if the prospects
refer to subdirectories of the directory being completed to, which
happens naturally when the completion is unique; or if they are a
cycled version of prospects that match the new completion pattern, in
case the completion happens to still match other items.

To resolve this confusion, never cycle with C-M-i in icomplete:
non-ambiguous cycling can be achieved with C-. and C-,

The former behaviour can still be restored with:

(define-key icomplete-minibuffer-map (kbd "C-M-i") 'minibuffer-force-complete)

* lisp/icomplete.el (icomplete-force-complete): New command.
(icomplete-minibuffer-map): Bind C-M-i to icomplete-force-complete.

lisp/icomplete.el

index 6d77c0649ae22e3e24170c8ff1d9fe3283f912a4..128fe6688bff80fab77304a36940f735ec860a34 100644 (file)
@@ -145,7 +145,7 @@ icompletion is occurring."
 
 (defvar icomplete-minibuffer-map
   (let ((map (make-sparse-keymap)))
-    (define-key map [?\M-\t] 'minibuffer-force-complete)
+    (define-key map [?\M-\t] 'icomplete-force-complete)
     (define-key map [?\C-j]  'icomplete-force-complete-and-exit)
     (define-key map [?\C-.]  'icomplete-forward-completions)
     (define-key map [?\C-,]  'icomplete-backward-completions)
@@ -162,6 +162,21 @@ the default otherwise."
       (minibuffer-force-complete-and-exit)
     (minibuffer-complete-and-exit)))
 
+(defun icomplete-force-complete ()
+  "Complete the icomplete minibuffer."
+  (interactive)
+  (let ((retval (minibuffer-force-complete)))
+    ;; FIXME: What's this, you ask?  To deal with a cycling corner
+    ;; case, `minibuffer-force-complete' will transiently replace the
+    ;; keybinding that this command was called with, but at least
+    ;; returns a function which we can call to disable that, since
+    ;; we're not at all interested in cycling here (bug#34077).
+    (when (and completion-cycling (functionp retval)) (funcall retval)))
+  ;; Again, since we're not interested in cycling, we don't want
+  ;; prospects to be recalculted from a cache of rotated completions.
+  (setq completion-cycling nil)
+  (setq completion-all-sorted-completions nil))
+
 (defun icomplete-forward-completions ()
   "Step forward completions by one entry.
 Second entry becomes the first and can be selected with