bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#34070: 27.0.50; icomplete-mode candidate cycling broken for C-x C-f


From: João Távora
Subject: bug#34070: 27.0.50; icomplete-mode candidate cycling broken for C-x C-f
Date: Mon, 14 Jan 2019 13:47:48 +0000

Hi maintainers,

   Emacs -Q
   M-x icomplete-mode
   C-x C-f
   C-.

Expected candidate list to rotate once to the left, immediately.
Instead if only rotates if I press C-. two additional times.  This is
because "."  and ".." are still taking part in the rotation under the
hood (but the user doesn't see them, by default, because of
completion-ignored-extensions).

Seems to have been introduced by

   commit 65797b1d75e9f608ffd50fd88be47a854b143bb1
   Author: Drew Adams <drew.adams@oracle.com>
   Date:   Thu Apr 28 19:31:43 2016 +0200
    
       Make icomplete respect `completion-ignored-extensions'
       
       * lisp/icomplete.el (icomplete-completions): Heed
       `completion-ignored-extensions' (bug#12939).

Naive patch attached that seems to fix it for me.

Here's another problem that might be related (should I open a new bug?)

   When using substring completion and navigating deeper in directories
   using successive C-M-i's (sometimes the directories don't make sense)
    
   Try it with:
    
     Emacs -Q
     M-: (add-to-list 'completion-styles 'substring)
     M-x icomplete-mode
     C-x C-f p a t h / t o / e m a c s /
     s r c C-M-i
    
   Expected to see the same as if I had typed "s r c /", instead I see
   "{src | lib-src}"

>From 7ec9a12f2e22b846c2635a045a8c1a13b4573eba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= <joaotavora@gmail.com>
Date: Mon, 14 Jan 2019 12:46:34 +0000
Subject: [PATCH] Fix icomplete's cycling when filename filtering kicks in

To reproduce:

   Emacs -Q
   M-x icomplete-mode
   C-x C-f
   C-.

Expected candidate list to rotate once to the left.  Instead if only
rotates if I press C-. twice more.  This is because "." and ".." are
still taking part in the rotation under the hood (but one doesn't see
them by default because of completion-ignored-extensions)

* lisp/icomplete.el (icomplete--filtered-completions): New variable.
(icomplete-forward-completions, icomplete-backward-completions):
Use it.
(icomplete-completions): Set it.
---
 lisp/icomplete.el | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 8bed46cb3b..82e2728487 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -162,6 +162,9 @@ icomplete-force-complete-and-exit
       (minibuffer-force-complete-and-exit)
     (minibuffer-complete-and-exit)))
 
+(defvar icomplete--filtered-completions nil
+  "If non-nil completions as filtered by `icomplete-completions'")
+
 (defun icomplete-forward-completions ()
   "Step forward completions by one entry.
 Second entry becomes the first and can be selected with
@@ -169,7 +172,8 @@ icomplete-forward-completions
   (interactive)
   (let* ((beg (icomplete--field-beg))
          (end (icomplete--field-end))
-         (comps (completion-all-sorted-completions beg end))
+         (comps (or icomplete--filtered-completions
+                    (completion-all-sorted-completions beg end)))
         (last (last comps)))
     (when comps
       (setcdr last (cons (car comps) (cdr last)))
@@ -182,7 +186,8 @@ icomplete-backward-completions
   (interactive)
   (let* ((beg (icomplete--field-beg))
          (end (icomplete--field-end))
-         (comps (completion-all-sorted-completions beg end))
+         (comps (or icomplete--filtered-completions
+                    (completion-all-sorted-completions beg end)))
         (last-but-one (last comps 2))
         (last (cdr last-but-one)))
     (when (consp last)               ; At least two elements in comps
@@ -382,9 +387,11 @@ icomplete-completions
        (progn ;;(debug (format "Candidates=%S field=%S" candidates name))
               (format " %sNo matches%s" open-bracket close-bracket))
       (if last (setcdr last nil))
-      (when (and minibuffer-completing-file-name
-                 icomplete-with-completion-tables)
-        (setq comps (completion-pcm--filename-try-filter comps)))
+      (if (and minibuffer-completing-file-name
+               icomplete-with-completion-tables)
+          (setq comps (completion-pcm--filename-try-filter comps)
+                icomplete--filtered-completions comps)
+        (setq icomplete--filtered-completions nil))
       (let* ((most-try
               (if (and base-size (> base-size 0))
                   (completion-try-completion
-- 
2.19.2


reply via email to

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