help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reloading all open buffers


From: Joakim Hove
Subject: Re: reloading all open buffers
Date: Mon, 08 Dec 2003 15:41:42 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux)

"Javier Oviedo" <email_joviedo@yahoo.com> writes:

> Hello all. I like to call a function that would "reload" all buffers that I
> have open...with the exception of buffers that have been modified but not
> yet saved. Can someone help me out with this? Thanks in advance.

This is at least a start:

(defun reload-all-buffers ()
  (interactive)
  (dolist (buffer (buffer-list))
    (if (and (buffer-file-name buffer)          ;; Ignoring buffers like 
*scratch* and *Messages*
             (not (buffer-modified-p buffer)))  ;; Ignoring buffers which have 
been modified
        (let ((file (buffer-file-name buffer)))
          (if (file-exists-p file)              ;; Checking that the file still 
exists
              (save-excursion
                (set-buffer buffer)
                (revert-buffer t t)))))))
          

HTH - Joakim

-- 
  /--------------------------------------------------------------------\
 / Joakim Hove  / hove@bccs.no  /  (55 5) 84076       |                 \
 | Unifob AS, Avdeling for Beregningsvitenskap (BCCS) | Stabburveien 18 |
 | CMU                                                | 5231 Paradis    |
 \ Thormøhlensgt.55, 5020 Bergen.                     | 55 91 28 18     /
  \--------------------------------------------------------------------/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]