GNU bug report logs - #10705
24.0.93; Collect strings matching regexp from Isearch

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> jurta.org>

Date: Thu, 2 Feb 2012 21:38:02 UTC

Severity: normal

Found in version 24.0.93

Done: Juri Linkov <juri <at> jurta.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Juri Linkov <juri <at> jurta.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#10705: closed (24.0.93; Collect strings matching regexp from
 Isearch)
Date: Thu, 23 Feb 2012 00:42:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Thu, 23 Feb 2012 02:38:04 +0200
with message-id <87ty2imljn.fsf <at> mail.jurta.org>
and subject line Re: bug#10705: 24.0.93; Collect strings matching regexp from Isearch
has caused the debbugs.gnu.org bug report #10705,
regarding 24.0.93; Collect strings matching regexp from Isearch
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
10705: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10705
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Juri Linkov <juri <at> jurta.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.93; Collect strings matching regexp from Isearch
Date: Thu, 02 Feb 2012 23:02:03 +0200
Currently `isearch-occur' is not in sync with the interactive specification
of `occur' that provides a new feature of `C-u M-x occur RET' that collects
the matching strings into the `*Occur*' buffer without line numbers.

The following patch syncs code from `occur-read-primary-args' to `isearch-occur'.

It doesn't quit Isearch when there are no subexpression in the regexp
(it collects the entire match with "\\&").

But in case of subexpression in the regexp, it quits Isearch because
it needs to ask for a substituted replacement string using `read-string'.

=== modified file 'lisp/isearch.el'
--- lisp/isearch.el	2012-01-25 17:54:01 +0000
+++ lisp/isearch.el	2012-02-02 21:01:12 +0000
@@ -1467,12 +1467,27 @@ (defun isearch-occur (regexp &optional n
 Interactively, REGEXP is the current search regexp or a quoted search
 string.  NLINES has the same meaning as in `occur'."
   (interactive
-   (list
-    (cond
-     (isearch-word (word-search-regexp isearch-string))
-     (isearch-regexp isearch-string)
-     (t (regexp-quote isearch-string)))
-    (if current-prefix-arg (prefix-numeric-value current-prefix-arg))))
+   (let* ((perform-collect (consp current-prefix-arg))
+	  (regexp (cond
+		   (isearch-word (word-search-regexp isearch-string))
+		   (isearch-regexp isearch-string)
+		   (t (regexp-quote isearch-string)))))
+     (list regexp
+	   (if perform-collect
+	       ;; Perform collect operation
+	       (if (zerop (regexp-opt-depth regexp))
+		   ;; No subexpression so collect the entire match.
+		   "\\&"
+		 ;; Get the regexp for collection pattern.
+		 (isearch-done nil t)
+		 (isearch-clean-overlays)
+		 (let ((default (car occur-collect-regexp-history)))
+		   (read-string
+		    (format "Regexp to collect (default %s): " default)
+		    nil 'occur-collect-regexp-history default)))
+	     ;; Otherwise normal occur takes numerical prefix argument.
+	     (when current-prefix-arg
+	       (prefix-numeric-value current-prefix-arg))))))
   (let ((case-fold-search isearch-case-fold-search)
 	;; Set `search-upper-case' to nil to not call
 	;; `isearch-no-upper-case-p' in `occur-1'.




[Message part 3 (message/rfc822, inline)]
From: Juri Linkov <juri <at> jurta.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 10705-done <at> debbugs.gnu.org
Subject: Re: bug#10705: 24.0.93; Collect strings matching regexp from Isearch
Date: Thu, 23 Feb 2012 02:38:04 +0200
Installed, with all the comments from Eli and Drew.

Also added a NEWS entry for this feature extracted from the docstring of `occur'.


This bug report was last modified 13 years and 94 days ago.

Previous Next


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