From f5538c8febc5f28ef08e30fe98b8b91c8fe1e525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Tue, 15 Jan 2019 16:50:40 +0000 Subject: [PATCH 5/5] Avoid broken C-M-i cycling in icomplete-mode (bug#34077) If there is only one propective candidate and it happens to be a directory then (1) C-M-i causes the prospects to be updated to the subfiles of the completed directory, otherwise (2) the prospects are merely rotated. It is very hard to tell if (1) or (2) happened because the rotated prospects may look identical to the updated prospects. Therefore, in icomplete-mode, it is preferable to do (1) always, to avoid iconsistencies with the presentation of prospects in this mode. There are already facilities in place to rotate the prospects list. * lisp/icomplete.el (icomplete-minibuffer-map): Bind C-M-i to icomplete-force-complete. (icomplete-force-complete): New command. --- lisp/icomplete.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 6d77c0649a..80357af4ad 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -145,13 +145,25 @@ icomplete-post-command-hook (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) map) "Keymap used by `icomplete-mode' in the minibuffer.") +(defun icomplete-force-complete () + "Complete the minibuffer. +Like `minibuffer-force-complete', but don't cycle." + (interactive) + ;; FIXME: it _could_ make sense to cycle in certain situations, by + ;; analyzing the current thing and the thing to cycle to for + ;; instance. Unfortunately that can't be done until a _very nasty + ;; hack_ in `minibuffer-force-complete' is removed. That hack uses + ;; transient maps and prevents two consecutive calls to + ;; `icomplete-force-complete'. + (minibuffer-force-complete nil nil t)) + (defun icomplete-force-complete-and-exit () "Complete the minibuffer and exit. Use the first of the matches if there are any displayed, and use -- 2.19.2