daveb@ingres.com (When a problem comes along . . . you must whip it) (08/16/90)
I'm looking for something sort of like: (defun apply-over (buffer-regexp func) "run func in all buffers matching regexp" ... ) thanks, -dB -- "In my opinion, most C programs should be indented 6 feet under." David Brower: {amdahl, cpsc6a, mtxinu, sun}!rtech!daveb daveb@ingres.com
roland@ai.mit.edu (Roland McGrath) (08/16/90)
In article <1990Aug15.172610.17351@ingres.Ingres.COM> daveb@ingres.com (When a problem comes along . . . you must whip it) writes:
I'm looking for something sort of like:
(defun apply-over (buffer-regexp func)
"run func in all buffers matching regexp"
... )
Ya mean like this?
(defun apply-over (regexp func)
(interactive "sRegexp: \naFunction: ")
(let ((list (buffer-list))
(cur (current-buffer)))
(while list
(if (and (buffer-name (car list))
(string-match regexp (buffer-name (car list))))
(progn
(set-buffer (car list))
(funcall func)))
(setq list (cdr list)))
(set-buffer cur)))
--
Roland McGrath
Free Software Foundation, Inc.
roland@ai.mit.edu, uunet!ai.mit.edu!roland
tale@turing.cs.rpi.edu (David C Lawrence) (08/17/90)
In <ROLAND.90Aug16022927@pogo.ai.mit.edu> roland@ai.mit.edu (Roland McGrath): Ya mean like this? (defun apply-over (regexp func) (interactive "sRegexp: \naFunction: ") (let ((list (buffer-list)) (cur (current-buffer))) (while list (if (and (buffer-name (car list)) (string-match regexp (buffer-name (car list)))) (progn (set-buffer (car list)) (funcall func))) (setq list (cdr list))) (set-buffer cur))) ^^^^^^^^^^^^^^^^ Do instead: (if (get-buffer cur) (set-buffer cur)) Ignoring buffers which programmers say are ignorable is arguably desirable too; you could add "bname" to the ``let'' car and change the ``and'' to: (and (setq bname (buffer-name (car list))) (/= (aref bname 0) ?\ ) (string-match regexp bname)) Of course, you might want to want the functionality of being able to touch them; maybe a third arg (a prefix arg) like some functions take for handling the "minibuffer too" would be good. I think I'd prefer to have default behaviour not accidentally stepping on the toes of hidden buffers or requiring me to start my regexps with ^[^ ]. Dave -- (setq mail '("tale@cs.rpi.edu" "tale@ai.mit.edu" "tale@rpitsmts.bitnet"))