emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Show all lines in marked buffers matching a regexp (with patch)


From: Matthias Meulien
Subject: Show all lines in marked buffers matching a regexp (with patch)
Date: Wed, 19 Jun 2013 02:46:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Don't you think the Buffer List should have a command to show all lines in marked buffers matching a regexp? An analog of `M-s a C-s' and `M-s a M-C-s' but using Multi Occur in place of ISearch.

Here is a patch to lisp/buff-menu.el that adds such a command with key binding `M-s a C-o'.
>From a4f8d342ebad3f357ba470c8e7b56a36e57c4379 Mon Sep 17 00:00:00 2001
From: Matthias Meulien <address@hidden>
Date: Wed, 19 Jun 2013 02:28:22 +0200
Subject: [PATCH] Extend buffer menu with command to show lines in marked
 buffers matching a regexp

---
 lisp/buff-menu.el | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el
index 6c02233..0ac109d 100644
--- a/lisp/buff-menu.el
+++ b/lisp/buff-menu.el
@@ -129,7 +129,8 @@ commands.")
     (define-key map "T" 'Buffer-menu-toggle-files-only)
     (define-key map (kbd "M-s a C-s")   'Buffer-menu-isearch-buffers)
     (define-key map (kbd "M-s a M-C-s") 'Buffer-menu-isearch-buffers-regexp)
-
+    (define-key map (kbd "M-s a C-o") 'Buffer-menu-multi-occur)
+    
     (define-key map [mouse-2] 'Buffer-menu-mouse-select)
     (define-key map [follow-link] 'mouse-face)
 
@@ -169,6 +170,9 @@ commands.")
     (bindings--define-key menu-map [ir]
       '(menu-item "Isearch Marked Buffers..." Buffer-menu-isearch-buffers
                 :help "Search for a string through all marked buffers using 
Isearch"))
+    (bindings--define-key menu-map [mo]
+      '(menu-item "Multi Occur Marked Buffers..." Buffer-menu-multi-occur
+                :help "Show lines matching a regexp in marked buffers using 
Occur"))
     (bindings--define-key menu-map [s3] menu-bar-separator)
     (bindings--define-key menu-map [by]
       '(menu-item "Bury" Buffer-menu-bury
@@ -226,6 +230,7 @@ In Buffer Menu mode, the following commands are defined:
      buffer selected before this one in another window.
 \\[Buffer-menu-isearch-buffers]    Incremental search in the marked buffers.
 \\[Buffer-menu-isearch-buffers-regexp]  Isearch for regexp in the marked 
buffers.
+\\[Buffer-menu-multi-occur] Show lines matching regexp in the marked buffers.
 \\[Buffer-menu-visit-tags-table]    visit-tags-table this buffer.
 \\[Buffer-menu-not-modified]    Clear modified-flag on that buffer.
 \\[Buffer-menu-save]    Mark that buffer to be saved, and move down.
@@ -477,6 +482,13 @@ If UNMARK is non-nil, unmark them."
   (interactive)
   (multi-isearch-buffers-regexp (Buffer-menu-marked-buffers)))
 
+(defun Buffer-menu-multi-occur ()
+  "Show all lines in marked buffers containing a match for a
+regexp ."
+  (interactive)
+  (let ((regexp (occur-read-primary-args)))
+    (multi-occur (Buffer-menu-marked-buffers) (car regexp))))
+
 
 (defun Buffer-menu-visit-tags-table ()
   "Visit the tags table in the buffer on this line.  See `visit-tags-table'."
-- 
1.8.3.1

Comments welcome,
-- 
Matthias

reply via email to

[Prev in Thread] Current Thread [Next in Thread]