aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Távora2019-01-14 12:46:34 +0000
committerJoão Távora2019-01-14 19:05:20 +0000
commitcdb082322d4209c5104bc1a98b21bf3dd75e8f17 (patch)
treead84bf55dd85e6b932a77ffacf625512683c7804
parent80c3b9aebaf99da73d10a949f475c5778e843cf8 (diff)
downloademacs-cdb082322d4209c5104bc1a98b21bf3dd75e8f17.tar.gz
emacs-cdb082322d4209c5104bc1a98b21bf3dd75e8f17.zip
Fix icomplete's cycling when filename filtering kicks in
Fixes: bug#34070 * lisp/icomplete.el (icomplete--filtered-completions): New variable. (icomplete-forward-completions, icomplete-backward-completions): Use it. (icomplete-completions): Set it.
-rw-r--r--lisp/icomplete.el17
1 files changed, 12 insertions, 5 deletions
diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 8bed46cb3b3..82e2728487b 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -162,6 +162,9 @@ 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(defvar icomplete--filtered-completions nil
166 "If non-nil completions as filtered by `icomplete-completions'")
167
165(defun icomplete-forward-completions () 168(defun icomplete-forward-completions ()
166 "Step forward completions by one entry. 169 "Step forward completions by one entry.
167Second entry becomes the first and can be selected with 170Second entry becomes the first and can be selected with
@@ -169,7 +172,8 @@ Second entry becomes the first and can be selected with
169 (interactive) 172 (interactive)
170 (let* ((beg (icomplete--field-beg)) 173 (let* ((beg (icomplete--field-beg))
171 (end (icomplete--field-end)) 174 (end (icomplete--field-end))
172 (comps (completion-all-sorted-completions beg end)) 175 (comps (or icomplete--filtered-completions
176 (completion-all-sorted-completions beg end)))
173 (last (last comps))) 177 (last (last comps)))
174 (when comps 178 (when comps
175 (setcdr last (cons (car comps) (cdr last))) 179 (setcdr last (cons (car comps) (cdr last)))
@@ -182,7 +186,8 @@ Last entry becomes the first and can be selected with
182 (interactive) 186 (interactive)
183 (let* ((beg (icomplete--field-beg)) 187 (let* ((beg (icomplete--field-beg))
184 (end (icomplete--field-end)) 188 (end (icomplete--field-end))
185 (comps (completion-all-sorted-completions beg end)) 189 (comps (or icomplete--filtered-completions
190 (completion-all-sorted-completions beg end)))
186 (last-but-one (last comps 2)) 191 (last-but-one (last comps 2))
187 (last (cdr last-but-one))) 192 (last (cdr last-but-one)))
188 (when (consp last) ; At least two elements in comps 193 (when (consp last) ; At least two elements in comps
@@ -382,9 +387,11 @@ matches exist."
382 (progn ;;(debug (format "Candidates=%S field=%S" candidates name)) 387 (progn ;;(debug (format "Candidates=%S field=%S" candidates name))
383 (format " %sNo matches%s" open-bracket close-bracket)) 388 (format " %sNo matches%s" open-bracket close-bracket))
384 (if last (setcdr last nil)) 389 (if last (setcdr last nil))
385 (when (and minibuffer-completing-file-name 390 (if (and minibuffer-completing-file-name
386 icomplete-with-completion-tables) 391 icomplete-with-completion-tables)
387 (setq comps (completion-pcm--filename-try-filter comps))) 392 (setq comps (completion-pcm--filename-try-filter comps)
393 icomplete--filtered-completions comps)
394 (setq icomplete--filtered-completions nil))
388 (let* ((most-try 395 (let* ((most-try
389 (if (and base-size (> base-size 0)) 396 (if (and base-size (> base-size 0))
390 (completion-try-completion 397 (completion-try-completion