Skip to content

Instantly share code, notes, and snippets.

@offby1
Created April 21, 2012 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save offby1/2437224 to your computer and use it in GitHub Desktop.
Save offby1/2437224 to your computer and use it in GitHub Desktop.
(defun search-all-buffers (regexp prefix)
"Searches file-visiting buffers for occurence of REGEXP. With
prefix > 1 (i.e., if you type C-u \\[search-all-buffers]),
searches all non-hidden buffers; with C-u C-u, searches *all*
buffers."
(interactive (list (grep-read-regexp)
current-prefix-arg))
(multi-occur
(if (member prefix '(4 (4)))
(buffer-list)
(remove-if
(lambda (b) (some (lambda (rx) (string-match rx (file-name-nondirectory (buffer-file-name b)))) search-all-buffers-ignored-files))
(remove-if-not 'buffer-file-name (buffer-list))))
regexp))
(global-set-key (kbd "<f7>") 'search-all-buffers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment