all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: 10705@debbugs.gnu.org
Subject: bug#10705: 24.0.93; Collect strings matching regexp from Isearch
Date: Thu, 02 Feb 2012 23:02:03 +0200	[thread overview]
Message-ID: <874nvac6us.fsf@mail.jurta.org> (raw)

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'.







             reply	other threads:[~2012-02-02 21:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-02 21:02 Juri Linkov [this message]
2012-02-03  7:38 ` bug#10705: 24.0.93; Collect strings matching regexp from Isearch Eli Zaretskii
2012-02-04  0:14   ` Juri Linkov
2012-02-04  7:26     ` Eli Zaretskii
2012-02-04 14:41       ` Drew Adams
2012-02-23  0:38       ` Juri Linkov
2012-02-23  0:57 ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874nvac6us.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=10705@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.