Newsgroups: comp.emacs
Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!rpi!rpi.edu!tale
From: tale@turing.cs.rpi.edu (David C Lawrence)
Subject: Re: has anyone got some lisp to apply a function over all/some buffers?
In-Reply-To: roland@ai.mit.edu's message of 16 Aug 90 06:29:27 GMT
Message-ID: <_R^%WR&@rpi.edu>
Organization: Rensselaer Polytechnic Institute Computer Science, Troy NY
References: <FELIX.90Aug13165019@cayucos.ai.sri.com>
	<1990Aug15.172610.17351@ingres.Ingres.COM>
	<ROLAND.90Aug16022927@pogo.ai.mit.edu>
Date: 17 Aug 90 05:00:06 GMT
Lines: 39

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"))
