Search through multiple (possibly all) buffers.
‘occur’in all buffers
‘find’commands – demo (flash)
moccur-edit.el, you can edit the results in place after using
‘color-moccur’– demo (flash)
‘grep’output to perform replacements on files
Built into Emacs 23, this command can search any files or buffers matching a regexp for a particular regexp.
To select buffers to search individually:
To select files to search by regexp:
To select buffers to search by regexp:
C-u M-x multi-occur-in-matching-buffers
You can use multiple regexps for searching and change regexps on the fly (incrementally). See Icicles - Search Commands, Overview. Search-and-replace across multiple buffers or files, with complex replacement possibilities – see Icicles - Search-And-Replace.
Search all buffers for REGEXP and present matching lines like grep.
search-buffers.el<elisp>:53:(defvar search-buffers-current-extent nil) search-buffers.el<elisp>:55:(defvar search-buffers-highlight-xtnt nil) search-buffers.el<elisp>:57:(defvar search-buffer nil) search-buffers.el<elisp>:60:(defun list-matches-in-buffers (regexp)
Search all buffers that have a file name associated with them and present matching lines. And C-c C-c gets you to the occurence.
Lines matching def.+ Buffer: moccur.el<mylisp> File: d:/akihisa/mylisp/moccur.el 49 (defface moccur-face 60 (defvar moccur-overlays nil) 61 (defvar moccur-regexp "")
moccur is basis of color-moccur. You can search all buffers and matched line is displayed to other window.
Screenshot, searching for “setq match”:
moccur-split-word : non-nil means to input word splited by space. You can search “(setq ov (make-overlay (match-beginning 0)” by “setq match” or “match setq”. You don’t need to input complicated regexp.
Upperside:Search result buffer, lowerside:matched file buffer
moccur-edit allows you to edit files by just editing the Moccur buffer of color-moccur.
Screenshot, where “ov” is replaced with “moccur-ov”:
The following function does the same thing as moccur, but the search is restricted to buffers with the same major mode as the current buffer.
(defun moccur-in-same-major-mode () "MOccur, but restricts search to buffers with the same major mode as the current buffer." (interactive) (let ((buf-names nil) (current-major-mode major-mode)) (dolist (buf (buffer-list)) (with-current-buffer buf (when (eql major-mode current-major-mode) (push (buffer-name buf) buf-names)))) (let ((*moccur-buffer-name-inclusion-list* (list (regexp-opt buf-names)))) (call-interactively 'moccur))))
This code lets you grep through all loaded buffers that have a file associated with them. It’s similar to ‘moccur’ and it’s many variants, but uses the standard compilation-mode interface, i.e. next-error, previous-error, etc. all work.
I have the same problem with symbol-near-point. Replacing it with symbol-at-point fixes problem. I’m using Emacs 22. -Petteri
Problem should be fixed now. -ScottFrazer
grep(-find) by elisp
M-x moccur-grep and input directory, regexp, filemask
In MiniBuffer, input directory
In minibuffer, input regexp and filemask. Last word is filemask.
Input Regexp and FileMask: gnus el$
How to use is same to M-x moccur-grep.
(defun search-all-buffers (regexp) (interactive "sRegexp: ") (multi-occur-in-matching-buffers "." regexp t)) (global-set-key [f7] 'search-all-buffers)