emacs-orgmode
[Top][All Lists]
Advanced

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

[O] revert all org buffers which changed on disk


From: Daniel Clemente
Subject: [O] revert all org buffers which changed on disk
Date: Wed, 27 Apr 2011 12:18:19 +0200
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.8 Emacs/24.0.50 (i686-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

Hi.
  org-revert-all-org-buffers loads all buffers from disk even if they didn't 
change. This can be very slow if you have hundreds of org files. The code below 
adds an extra check to only revert files which changed (according to 
verify-visited-file-modtime).
  It may be better to have only one function, org-revert-org-buffers, which by 
default reverts only changed buffers, but accepts a parameter to revert them 
all.



(defun org-revert-changed-org-buffers ()
  "Revert all Org-mode buffers changed outside of Emacs.

This works like org-revert-all-org-buffers but is limited to those files
which have a more recent modification time than the one in Emacs' buffer.
This function is faster because it does not reload unchanged buffers."
  (interactive)
  (unless (yes-or-no-p "Revert changed Org buffers from their files? ")
    (error "Abort"))
  (save-excursion
    (save-window-excursion
      (mapc
       (lambda (b)
     (when (and (with-current-buffer b (org-mode-p))
            (with-current-buffer b buffer-file-name)
            (not (verify-visited-file-modtime b)))
       (switch-to-buffer b)
       (revert-buffer t 'no-confirm)))
       (buffer-list))
      (when (and (featurep 'org-id) org-id-track-globally)
    (org-id-locations-load)))))



reply via email to

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