aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Távora2019-01-23 16:30:41 +0000
committerJoão Távora2019-01-23 16:31:11 +0000
commitb9add0a5a7eddcf80a189c478b39a5cb7a12befe (patch)
tree0b11f55733c31a32a0cc5270520415c196308d61
parent210e592e55ade154c8d58bd467711fb69368f6cb (diff)
downloademacs-b9add0a5a7eddcf80a189c478b39a5cb7a12befe.tar.gz
emacs-b9add0a5a7eddcf80a189c478b39a5cb7a12befe.zip
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.
-rw-r--r--lisp/icomplete.el17
1 files changed, 16 insertions, 1 deletions
diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 6d77c0649ae..128fe6688bf 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -145,7 +145,7 @@ icompletion is occurring."
145 145
146(defvar icomplete-minibuffer-map 146(defvar icomplete-minibuffer-map
147 (let ((map (make-sparse-keymap))) 147 (let ((map (make-sparse-keymap)))
148 (define-key map [?\M-\t] 'minibuffer-force-complete) 148 (define-key map [?\M-\t] 'icomplete-force-complete)
149 (define-key map [?\C-j] 'icomplete-force-complete-and-exit) 149 (define-key map [?\C-j] 'icomplete-force-complete-and-exit)
150 (define-key map [?\C-.] 'icomplete-forward-completions) 150 (define-key map [?\C-.] 'icomplete-forward-completions)
151 (define-key map [?\C-,] 'icomplete-backward-completions) 151 (define-key map [?\C-,] 'icomplete-backward-completions)
@@ -162,6 +162,21 @@ the default otherwise."
162 (minibuffer-force-complete-and-exit) 162 (minibuffer-force-complete-and-exit)
163 (minibuffer-complete-and-exit))) 163 (minibuffer-complete-and-exit)))
164 164
165(defun icomplete-force-complete ()
166 "Complete the icomplete minibuffer."
167 (interactive)
168 (let ((retval (minibuffer-force-complete)))
169 ;; FIXME: What's this, you ask? To deal with a cycling corner
170 ;; case, `minibuffer-force-complete' will transiently replace the
171 ;; keybinding that this command was called with, but at least
172 ;; returns a function which we can call to disable that, since
173 ;; we're not at all interested in cycling here (bug#34077).
174 (when (and completion-cycling (functionp retval)) (funcall retval)))
175 ;; Again, since we're not interested in cycling, we don't want
176 ;; prospects to be recalculted from a cache of rotated completions.
177 (setq completion-cycling nil)
178 (setq completion-all-sorted-completions nil))
179
165(defun icomplete-forward-completions () 180(defun icomplete-forward-completions ()
166 "Step forward completions by one entry. 181 "Step forward completions by one entry.
167Second entry becomes the first and can be selected with 182Second entry becomes the first and can be selected with