unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: 14784@debbugs.gnu.org
Subject: bug#14784: Occur from more Isearch types
Date: Thu, 04 Jul 2013 02:28:15 +0300	[thread overview]
Message-ID: <87ip0r6x68.fsf@mail.jurta.org> (raw)

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" ())





             reply	other threads:[~2013-07-03 23:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-03 23:28 Juri Linkov [this message]
2019-06-26 15:44 ` bug#14784: Occur from more Isearch types Lars Ingebrigtsen
2020-08-13 11:23   ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ip0r6x68.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=14784@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).