Commit b9add0a5 authored by João Távora's avatar João Távora

Force completion in icomplete with C-M-i, but don't cycle (bug#34077)

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.
parent 210e592e
Pipeline #602 failed with stage
in 60 minutes and 1 second
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment