summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Richard <youngfrog@members.fsf.org>2015-06-30 09:18:27 +0200
committerNicolas Richard <youngfrog@members.fsf.org>2015-07-02 00:57:07 +0200
commit2f020e82195d6870b45d24d0c46af6d92b31deca (patch)
tree41e797202521bc313d58bea416b47472d93b213e
parent7d5a7a43f1f6630b269fa7f7dc13e9c80181a709 (diff)
downloademacs-2f020e82195d6870b45d24d0c46af6d92b31deca.tar.gz
Add argument to reverse the meaning of ido-restrict-to-matches
* lisp/ido.el (ido-restrict-to-matches): Add an optional argument to reverse the meaning (Bug#15631). ; * etc/NEWS: Mention the change.
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/ido.el17
2 files changed, 16 insertions, 4 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 758d358f41c..38a872dbe7a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -398,6 +398,9 @@ If you need your objects to be named, do it by inheriting from `eieio-named'.
*** New command `ido-bury-buffer-at-head' bound to C-S-b
Bury the buffer at the head of `ido-matches', analogous to how C-k
kills the buffer at head.
+*** A prefix argument to `ido-restrict-to-matches' will reverse its
+meaning, and the list is restricted to those elements that do not
+match the current input.
** Minibuffer
diff --git a/lisp/ido.el b/lisp/ido.el
index 5995fcd41e3..1f12fbfa9ee 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -322,6 +322,7 @@
;;; Code:
(defvar recentf-list)
+(require 'seq)
;;;; Options
@@ -3180,11 +3181,19 @@ for first matching file."
(if (> i 0)
(setq ido-cur-list (ido-chop ido-cur-list (nth i ido-matches)))))))
-(defun ido-restrict-to-matches ()
- "Set current item list to the currently matched items."
- (interactive)
+(defun ido-restrict-to-matches (&optional removep)
+ "Set current item list to the currently matched items.
+
+When argument REMOVEP is non-nil, the currently matched items are
+instead removed from the current item list."
+ (interactive "P")
(when ido-matches
- (setq ido-cur-list ido-matches
+ (setq ido-cur-list (if removep
+ ;; An important feature is to preserve the
+ ;; order of the elements.
+ (seq-difference ido-cur-list ido-matches)
+ ido-matches)
+ ido-matches ido-cur-list
ido-text-init ""
ido-rescan nil
ido-exit 'keep)