Function: isearch-occur
isearch-occur is an interactive and byte-compiled function defined in
isearch.el.gz.
Signature
(isearch-occur REGEXP &optional NLINES)
Documentation
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.
Probably introduced at or before Emacs version 23.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/isearch.el.gz
(defun isearch-occur (regexp &optional nlines)
"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
(let* ((perform-collect (consp current-prefix-arg))
(regexp (cond
((functionp isearch-regexp-function)
(funcall isearch-regexp-function isearch-string))
(isearch-regexp-function (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.
(let ((default (car occur-collect-regexp-history))
regexp-collect)
(with-isearch-suspended
(setq regexp-collect
(read-regexp
(format-prompt "Regexp to collect" default)
default 'occur-collect-regexp-history)))
regexp-collect))
;; 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'.
(search-upper-case nil)
(search-spaces-regexp
(if (if isearch-regexp
isearch-regexp-lax-whitespace
isearch-lax-whitespace)
search-whitespace-regexp)))
(occur (if isearch-regexp-function
(propertize regexp
'isearch-string isearch-string
'isearch-regexp-function-descr
(isearch--describe-regexp-mode isearch-regexp-function))
regexp)
nlines
(if (use-region-p) (region-bounds)))))