emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master b9add0a 2/2: Force completion in icomplete with C-M


From: João Távora
Subject: [Emacs-diffs] master b9add0a 2/2: Force completion in icomplete with C-M-i, but don't cycle (bug#34077)
Date: Wed, 23 Jan 2019 11:33:45 -0500 (EST)

branch: master
commit b9add0a5a7eddcf80a189c478b39a5cb7a12befe
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>

    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.
---
 lisp/icomplete.el | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 6d77c06..128fe66 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]