From: João Távora Date: Wed, 23 Jan 2019 16:30:41 +0000 (+0000) Subject: Force completion in icomplete with C-M-i, but don't cycle (bug#34077) X-Git-Tag: emacs-27.0.90~3751 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b9add0a5a7eddcf80a189c478b39a5cb7a12befe;p=emacs.git 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. --- 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." (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