GNU bug report logs - #15631
24.3; ido : invert effect of ido-restrict-to-matches with prefix arg

Previous Next

Package: emacs;

Reported by: Nicolas Richard <theonewiththeevillook <at> yahoo.fr>

Date: Wed, 16 Oct 2013 14:55:02 UTC

Severity: wishlist

Tags: patch

Found in version 24.3

Done: Nicolas Richard <youngfrog <at> members.fsf.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 15631 in the body.
You can then email your comments to 15631 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#15631; Package emacs. (Wed, 16 Oct 2013 14:55:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Nicolas Richard <theonewiththeevillook <at> yahoo.fr>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 16 Oct 2013 14:55:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Richard <theonewiththeevillook <at> yahoo.fr>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3; ido : invert effect of ido-restrict-to-matches with prefix arg
Date: Wed, 16 Oct 2013 16:54:24 +0200
Hello

The function `ido-restrict-to-matches' is used within ido to restrict
focus on currently matched items. It was asked on #emacs to have a
function with the opposite effect : restrict focus on unmatched items.

I found it was useful for me and came up with this solution (adding an
optional argument to the existing function) :

diff --git a/lisp/ido.el b/lisp/ido.el
index cda4021..31aa303 100644
*** a/lisp/ido.el
--- b/lisp/ido.el
***************
*** 3133,3143 ****
        (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)
    (when ido-matches
!     (setq ido-cur-list ido-matches
  	  ido-text-init ""
  	  ido-rescan nil
  	  ido-exit 'keep)
--- 3133,3155 ----
        (if (> i 0)
  	  (setq ido-cur-list (ido-chop ido-cur-list (nth i ido-matches)))))))
  
! (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 (cond
!                         (removep
!                          (delq nil
!                                (mapcar
!                                 (lambda (elt)
!                                   (when (not (member elt ido-matches))
!                                     elt))
!                                 ido-cur-list)))
!                         (t ido-matches))
!           ido-matches ido-cur-list
  	  ido-text-init ""
  	  ido-rescan nil
  	  ido-exit 'keep)

-- 
Nicolas.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15631; Package emacs. (Tue, 30 Jun 2015 15:29:02 GMT) Full text and rfc822 format available.

Message #8 received at 15631 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Richard <youngfrog <at> members.fsf.org>
To: 15631 <at> debbugs.gnu.org
Subject: Re: bug#15631: 24.3;
 ido : invert effect of ido-restrict-to-matches with prefix arg
Date: Tue, 30 Jun 2015 17:28:38 +0200
[Message part 1 (text/plain, inline)]
Nicolas Richard <theonewiththeevillook <at> yahoo.fr> writes:
> The function `ido-restrict-to-matches' is used within ido to restrict
> focus on currently matched items. It was asked on #emacs to have a
> function with the opposite effect : restrict focus on unmatched items.
>
> I found it was useful for me and came up with this solution (adding an
> optional argument to the existing function) :

I modified the patch a tiny bit and now use the new library seq.el and
add a NEWS entry. If nobody complains I'll install this patch in the
next few days.

[0001-Add-argument-to-reverse-the-meaning-of-ido-restrict-.patch (text/x-diff, inline)]
From c8469c5892c7d01045f81a99a7535b3ed76abd2d Mon Sep 17 00:00:00 2001
From: Nicolas Richard <youngfrog <at> members.fsf.org>
Date: Tue, 30 Jun 2015 09:18:27 +0200
Subject: [PATCH] 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.

; * etc/NEWS: Mention the change
---
 etc/NEWS    |  3 +++
 lisp/ido.el | 17 +++++++++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 1f8cbbc..8ee8364 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 those elements that do not match
+the current input.
 
 ** Minibuffer
 
diff --git a/lisp/ido.el b/lisp/ido.el
index 5995fcd..1f12fbf 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)
-- 
2.4.5

[Message part 3 (text/plain, inline)]
-- 
Nico.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15631; Package emacs. (Tue, 30 Jun 2015 16:18:02 GMT) Full text and rfc822 format available.

Message #11 received at 15631 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Nicolas Richard <youngfrog <at> members.fsf.org>
Cc: 15631 <at> debbugs.gnu.org
Subject: Re: bug#15631: 24.3;
 ido : invert effect of ido-restrict-to-matches with prefix arg
Date: Tue, 30 Jun 2015 19:17:17 +0300
> From: Nicolas Richard <youngfrog <at> members.fsf.org>
> Date: Tue, 30 Jun 2015 17:28:38 +0200
> 
> +*** A prefix argument to `ido-restrict-to-matches' will reverse its
> +meaning, and the list is restricted those elements that do not match
> +the current input.                ^^^

A "to" is missing where indicated.

Thanks.




Reply sent to Nicolas Richard <youngfrog <at> members.fsf.org>:
You have taken responsibility. (Wed, 01 Jul 2015 23:02:02 GMT) Full text and rfc822 format available.

Notification sent to Nicolas Richard <theonewiththeevillook <at> yahoo.fr>:
bug acknowledged by developer. (Wed, 01 Jul 2015 23:02:03 GMT) Full text and rfc822 format available.

Message #16 received at 15631-done <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Richard <youngfrog <at> members.fsf.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 15631-done <at> debbugs.gnu.org
Subject: Re: bug#15631: 24.3;
 ido : invert effect of ido-restrict-to-matches with prefix arg
Date: Thu, 02 Jul 2015 01:01:19 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:
> A "to" is missing where indicated.

Thanks, I fixed it and pushed. Closing.

Nico.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 30 Jul 2015 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 333 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.