Subject: bug#14784: Occur from more Isearch types

From: Lars Ingebrigtsen <[email-masked]>
Date: Wed, 26 Jun 2019 17:44:15 +0200

Juri Linkov <[email-masked]> writes:

> Like bug#14673 added `Buffer-menu-multi-occur' to invoke Occur
> from multiple marked buffers, it would also make sense to invoke Occur
> from other search types where the search space differs from the default
> single-buffer search.  Then typing `M-s o' in the minibuffer's isearch
> will show occurrences from all minibuffer history elements, and
> when typed in the comint's history isearch, will show occurrences
> from all shell history elements:

[...]

> +(defun minibuffer-occur (regexp &optional nlines)
> +  "Show all entries in the minibuffer history containing a match for REGEXP.
> +Like `occur', but acts on the contents of the minibuffer history
> +in the currently active minibuffer."
> +  (interactive (occur-read-primary-args))
> +  (when (and (minibufferp) minibuffer-history-variable)
> +    (let* ((history-variable minibuffer-history-variable)
> +	   (history (symbol-value history-variable)))
> +      (with-current-buffer
> +	  (get-buffer-create (format " *Minibuffer history %s*"
> +				     history-variable))
> +	(erase-buffer)
> +	(dolist (line history)
> +	  (insert (query-replace-descr line) "\n"))
> +	(occur-1 regexp nlines (list (current-buffer)))))))

That's an interesting feature...  But with normal `C-s i foo M-s o', we
can then jump to the result, while we can't really do that there, can
we?  So there's a bit of a disconnect between using an Occur buffer and
the minibuffer...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no