]> git.eshelyaron.com Git - emacs.git/commitdiff
Add argument to reverse the meaning of ido-restrict-to-matches
authorNicolas Richard <youngfrog@members.fsf.org>
Tue, 30 Jun 2015 07:18:27 +0000 (09:18 +0200)
committerNicolas Richard <youngfrog@members.fsf.org>
Wed, 1 Jul 2015 22:57:07 +0000 (00:57 +0200)
* lisp/ido.el (ido-restrict-to-matches): Add an optional argument
to reverse the meaning (Bug#15631).

; * etc/NEWS: Mention the change.

etc/NEWS
lisp/ido.el

index 758d358f41cf9e4a3c432c25f8780972c56999f3..38a872dbe7a95faa1bc74c7bf6e70862240c16e7 100644 (file)
--- 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
 
index 5995fcd41e3ae4f8abc31c66ff0106ba3dcf8121..1f12fbfa9ee77ab6c9f969e10a00aa7a9fd7162e 100644 (file)
 ;;; 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)