unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14784: Occur from more Isearch types
@ 2013-07-03 23:28 Juri Linkov
  2019-06-26 15:44 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2013-07-03 23:28 UTC (permalink / raw)
  To: 14784

Severity: wishlist
Tags: patch

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:

=== modified file 'lisp/simple.el'
--- lisp/simple.el	2013-06-27 00:50:50 +0000
+++ lisp/simple.el	2013-07-03 23:17:01 +0000
@@ -1938,6 +2032,22 @@
 Go to the history element by the absolute history position HIST-POS."
   (goto-history-element hist-pos))
 
+(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)))))))
+
 \f
 ;Put this on C-x u, so we can force that rather than C-_ into startup msg
 (define-obsolete-function-alias 'advertised-undo 'undo "23.2")

=== modified file 'lisp/comint.el'
--- lisp/comint.el	2013-06-21 09:37:04 +0000
+++ lisp/comint.el	2013-07-03 23:15:59 +0000
@@ -1570,6 +1570,20 @@
 Go to the history element by the absolute history position HIST-POS."
   (comint-goto-input hist-pos))
 
+(defun comint-history-occur (regexp &optional nlines)
+  "Show all entries in the input history containing a match for REGEXP.
+Like `occur', but acts on the contents of the input history
+in the currently active comint buffer."
+  (interactive (occur-read-primary-args))
+  (when comint-input-ring
+    (let ((input-ring comint-input-ring))
+      (with-current-buffer
+	  (get-buffer-create " *Comint history*")
+	(erase-buffer)
+	(dotimes (i (1- (ring-length input-ring)))
+	  (insert (query-replace-descr (ring-ref input-ring i)) "\n"))
+	(occur-1 regexp nlines (list (current-buffer)))))))
+
 \f
 (defun comint-within-quotes (beg end)
   "Return t if the number of quotes between BEG and END is odd.

=== modified file 'lisp/isearch.el'
--- lisp/isearch.el	2013-06-13 22:08:45 +0000
+++ lisp/isearch.el	2013-07-03 23:18:35 +0000
@@ -1785,7 +1888,12 @@ (defun isearch-occur (regexp &optional n
 		 isearch-regexp-lax-whitespace
 	       isearch-lax-whitespace)
 	     search-whitespace-regexp)))
-    (occur regexp nlines)))
+    (cond ((and (minibufferp) minibuffer-history-variable)
+	   (minibuffer-occur regexp nlines))
+	  ((and (boundp 'comint-input-ring) comint-input-ring)
+	   (comint-history-occur regexp nlines))
+	  (t
+	   (occur regexp nlines)))))
 
 (declare-function hi-lock-read-face-name "hi-lock" ())





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#14784: Occur from more Isearch types
  2013-07-03 23:28 bug#14784: Occur from more Isearch types Juri Linkov
@ 2019-06-26 15:44 ` Lars Ingebrigtsen
  2020-08-13 11:23   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2019-06-26 15:44 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 14784

Juri Linkov <juri@jurta.org> 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





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#14784: Occur from more Isearch types
  2019-06-26 15:44 ` Lars Ingebrigtsen
@ 2020-08-13 11:23   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-13 11:23 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 14784

Lars Ingebrigtsen <larsi@gnus.org> writes:

> 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...

That was a year ago, and there was no response, so I'm guessing there
wasn't much interest in adding this feature, so I'm closing this bug
report.  Please reopen if this is incorrect.

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





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-13 11:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-03 23:28 bug#14784: Occur from more Isearch types Juri Linkov
2019-06-26 15:44 ` Lars Ingebrigtsen
2020-08-13 11:23   ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).