From: Juri Linkov Date: Thu, 23 Feb 2012 00:36:49 +0000 (+0200) Subject: * lisp/isearch.el (isearch-occur): Sync interactive spec with occur's X-Git-Tag: emacs-pretest-24.0.94~65 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0bd1e07406f0140d699a0d12a655753cf77cdf8a;p=emacs.git * lisp/isearch.el (isearch-occur): Sync interactive spec with occur's new feature in `occur-read-primary-args'. Doc fix. * etc/NEWS: Add new "collect" feature of `occur'. Fixes: debbugs:10705 --- diff --git a/etc/NEWS b/etc/NEWS index 583c86b901d..65b6e532fc8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -965,6 +965,12 @@ Its functions and variables have been similarly renamed. ** Occur Edit mode applies edits made in *Occur* buffers to the original buffers. It is bound to "e" in Occur mode. +** When `occur' is called with the prefix argument `C-u' +the matching strings are collected into the `*Occur*' buffer +without line numbers. If there are parenthesized subexpressions +in the specified regexp, `occur' reads replacement text that +may contain \\& and \\N whose convention follows `replace-match'. + +++ ** New global minor mode electric-pair-mode. When enabled, typing an open parenthesis automatically inserts the diff --git a/lisp/ChangeLog b/lisp/ChangeLog index eaf04e72ecd..d69231fd806 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-02-23 Juri Linkov + + * isearch.el (isearch-occur): Sync interactive spec with occur's + new feature in `occur-read-primary-args'. Doc fix. (Bug#10705) + 2012-02-22 Juri Linkov * international/mule-cmds.el (read-char-by-name): Use \` and \'. diff --git a/lisp/isearch.el b/lisp/isearch.el index 27b82940043..9d69443b6a4 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -1433,16 +1433,38 @@ See `isearch-query-replace' for more information." (isearch-query-replace delimited t)) (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'." + "Run `occur' using the last search string as the regexp. +Interactively, REGEXP is constructed using the search string from the +last search command. NLINES has the same meaning as in `occur'. + +If the last search command was a word search, REGEXP is computed from +the search words, ignoring 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 literal string, REGEXP is constructed by quoting all the special +characters in that string." (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'.