Commit 0bd1e074 authored by Juri Linkov's avatar Juri Linkov
Browse files

* 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
parent 19e9789e
......@@ -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
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 \'.
......@@ -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."
(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)
(let ((default (car occur-collect-regexp-history)))
(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'.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment