;;; aok.el -- various useful ways to do `multi-occur' ;; Copyright (C) 2004 Joe Corneli ;; Time-stamp: ;; This file is not part of GNU Emacs, but it is distributed under ;; the same terms as GNU Emacs. ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published ;; by the Free Software Foundation; either version 2, or (at your ;; option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Commentary: ;; search all buffers, all buffers whose filenames have a certain ;; type, or all buffers in a certain mode, with `all-occur', ;; `type-occur', or `mode-occur', respectively. ;;; Code: (require 'cl) (defun all-occur (rexp) "Search all buffers for REXP." (interactive "MRegexp: ") (multi-occur (buffer-list) rexp)) ;; this one {c}/{sh}ould be a completing read that would read from a ;; predefined list of filetype extensions (without requiring a match). (defun type-occur (extension rexp) "EXTENSION denotes a filetype extension to search. Run occur in all buffers whose names match this type for REXP." (interactive "MExtension: \nMRegexp: ") (multi-occur-by-filename-regexp (concat ".*\." extension) rexp)) (defun mode-occur (mode rexp) "Search all buffers with major mode MODE for REXP." (interactive (list (read-command "Mode: ") (read-string "Regexp: "))) (multi-occur (remove-if (lambda (buf) (set-buffer buf) (not (eq major-mode mode))) (buffer-list)) rexp)) ;;; aok.el ends here