GNU bug report logs -
#10705
24.0.93; Collect strings matching regexp from Isearch
Previous Next
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.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 10705 in the body.
You can then email your comments to 10705 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10705
; Package
emacs
.
(Thu, 02 Feb 2012 21:38:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Juri Linkov <juri <at> jurta.org>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Thu, 02 Feb 2012 21:38:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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'.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10705
; Package
emacs
.
(Fri, 03 Feb 2012 07:42:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 10705 <at> debbugs.gnu.org (full text, mbox):
> From: Juri Linkov <juri <at> jurta.org>
> 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'.
Btw, while at that, how about fixing the doc string as well. What it
says now, viz.
> Interactively, REGEXP is the current search regexp or a quoted search
> string. NLINES has the same meaning as in `occur'."
is not clear enough: what is a "quoted search string"? I'd suggest to
describe explicitly the 3 cases handled by the code:
> + (regexp (cond
> + (isearch-word (word-search-regexp isearch-string))
> + (isearch-regexp isearch-string)
> + (t (regexp-quote isearch-string)))))
and refer to the relevant string in each case.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10705
; Package
emacs
.
(Sat, 04 Feb 2012 01:07:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 10705 <at> debbugs.gnu.org (full text, mbox):
>> Interactively, REGEXP is the current search regexp or a quoted search
>> string. NLINES has the same meaning as in `occur'."
>
> is not clear enough: what is a "quoted search string"? I'd suggest to
> describe explicitly the 3 cases handled by the code:
>
>> + (regexp (cond
>> + (isearch-word (word-search-regexp isearch-string))
>> + (isearch-regexp isearch-string)
>> + (t (regexp-quote isearch-string)))))
>
> and refer to the relevant string in each case.
Is this better?
=== modified file 'lisp/isearch.el'
--- lisp/isearch.el 2012-02-03 23:50:41 +0000
+++ lisp/isearch.el 2012-02-04 00:10:01 +0000
@@ -1464,8 +1464,11 @@ (defun isearch-query-replace-regexp (&op
(defun isearch-occur (regexp &optional nlines)
"Run `occur' with regexp to search from the current search string.
-Interactively, REGEXP is the current search regexp or a quoted search
-string. NLINES has the same meaning as in `occur'."
+Interactively, in word search REGEXP is computed from words
+without regard to punctuation, in regexp search REGEXP is
+the current search regexp, in normal search REGEXP is created
+from the current search string quoting all special regexp characters.
+NLINES has the same meaning as in `occur'."
(interactive
(let* ((perform-collect (consp current-prefix-arg))
(regexp (cond
BTW, shouldn't this new feature (collecting strings with `C-u M-x occur')
be announced in NEWS?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10705
; Package
emacs
.
(Sat, 04 Feb 2012 07:28:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 10705 <at> debbugs.gnu.org (full text, mbox):
> From: Juri Linkov <juri <at> jurta.org>
> Cc: 10705 <at> debbugs.gnu.org
> Date: Sat, 04 Feb 2012 02:14:15 +0200
>
> >> Interactively, REGEXP is the current search regexp or a quoted search
> >> string. NLINES has the same meaning as in `occur'."
> >
> > is not clear enough: what is a "quoted search string"? I'd suggest to
> > describe explicitly the 3 cases handled by the code:
> >
> >> + (regexp (cond
> >> + (isearch-word (word-search-regexp isearch-string))
> >> + (isearch-regexp isearch-string)
> >> + (t (regexp-quote isearch-string)))))
> >
> > and refer to the relevant string in each case.
>
> Is this better?
>
> === modified file 'lisp/isearch.el'
> --- lisp/isearch.el 2012-02-03 23:50:41 +0000
> +++ lisp/isearch.el 2012-02-04 00:10:01 +0000
> @@ -1464,8 +1464,11 @@ (defun isearch-query-replace-regexp (&op
>
> (defun isearch-occur (regexp &optional nlines)
> "Run `occur' with regexp to search from the current search string.
> -Interactively, REGEXP is the current search regexp or a quoted search
> -string. NLINES has the same meaning as in `occur'."
> +Interactively, in word search REGEXP is computed from words
> +without regard to punctuation, in regexp search REGEXP is
> +the current search regexp, in normal search REGEXP is created
> +from the current search string quoting all special regexp characters.
> +NLINES has the same meaning as in `occur'."
When you say "in word search" etc., you actually mean "when invoked
after a word search command", right? If so, I suggest the following
wording:
Run `occur' using the last search string as the regexp.
Interactively, REGEXP is constructed using the search string from the
last search command.
If the last search command was a word search, REGEXP is computed from
the search words disregarding punctuation. If the last search
command was a regular expression search, REGEXP is the regular
expression used in that search. If the last search command searched
for a string, REGEXP is constructed by quoting all the special
characters in that string.
> BTW, shouldn't this new feature (collecting strings with `C-u M-x occur')
> be announced in NEWS?
I think it should be.
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10705
; Package
emacs
.
(Sat, 04 Feb 2012 14:43:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 10705 <at> debbugs.gnu.org (full text, mbox):
> When you say "in word search" etc., you actually mean "when invoked
> after a word search command", right? If so, I suggest the following
> wording:
>
> Run `occur' using the last search string as the regexp.
> Interactively, REGEXP is constructed using the search string from the
> last search command.
>
> If the last search command was a word search, REGEXP is computed from
> the search words disregarding punctuation. If the last search
> command was a regular expression search, REGEXP is the regular
> expression used in that search. If the last search command searched
> for a string, REGEXP is constructed by quoting all the special
> characters in that string.
+1, with the same assumption ("when you say...").
However:
* it should be "the search words, disregarding punctuation" (comma - it is not
the words themselves that disregard punctuation)
* "ignoring" is better than "disregarding" here
And just what do we mean by the computation of REGEXP paying no
attention to punctuation? Maybe an "(e.g. ...)" is in order.
* "searched for a literal string" (or "searched for a regular string") is
perhaps better than "searched for a string"
FWIW, the doc string for `isearch-forward-regexp' refers to a
literal search as "a regular string search". But I'm not sure
that "regular string" is a good choice in such contexts, as it
can suggest having something to do with regular expressions.
Reply sent
to
Juri Linkov <juri <at> jurta.org>
:
You have taken responsibility.
(Thu, 23 Feb 2012 00:42:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Juri Linkov <juri <at> jurta.org>
:
bug acknowledged by developer.
(Thu, 23 Feb 2012 00:42:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 10705-done <at> debbugs.gnu.org (full text, mbox):
Installed, with all the comments from Eli and Drew.
Also added a NEWS entry for this feature extracted from the docstring of `occur'.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#10705
; Package
emacs
.
(Thu, 23 Feb 2012 01:01:01 GMT)
Full text and
rfc822 format available.
Message #25 received at 10705 <at> debbugs.gnu.org (full text, mbox):
I noticed that another occur's new feature `occur-edit-mode' lacks
a menu item. I added it too.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 22 Mar 2012 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 12 years and 60 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.