Skip to content

Instantly share code, notes, and snippets.

@offby1
Created December 7, 2010 11:11
Show Gist options
  • Save offby1/731686 to your computer and use it in GitHub Desktop.
Save offby1/731686 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 buffers."
(interactive (list (grep-read-regexp)
current-prefix-arg))
(message "Regexp is %s; prefix is %s" regexp prefix)
(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 [f7] 'search-all-buffers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment