emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* revert all org buffers which changed on disk
@ 2011-04-27 10:18 Daniel Clemente
  2011-04-28 23:01 ` Jason Dunsmore
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Clemente @ 2011-04-27 10:18 UTC (permalink / raw)
  To: org-mode Mailinglist


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: revert all org buffers which changed on disk
  2011-04-27 10:18 revert all org buffers which changed on disk Daniel Clemente
@ 2011-04-28 23:01 ` Jason Dunsmore
  2011-05-02 12:09   ` Daniel Clemente
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Dunsmore @ 2011-04-28 23:01 UTC (permalink / raw)
  To: Daniel Clemente; +Cc: org-mode Mailinglist

Daniel Clemente <n142857@gmail.com> writes:

> Hi.
>   org-revert-all-org-buffers loads all buffers from disk even if they didn't change.

FYI, there's also a package called revbufs:
http://www.neilvandyke.org/revbufs/revbufs.el

Although it's not specific to org files.

Regards,
Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: revert all org buffers which changed on disk
  2011-04-28 23:01 ` Jason Dunsmore
@ 2011-05-02 12:09   ` Daniel Clemente
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Clemente @ 2011-05-02 12:09 UTC (permalink / raw)
  To: org-mode Mailinglist; +Cc: Jason Dunsmore

El Thu, 28 Apr 2011 18:01:04 -0500 Jason Dunsmore va escriure:
> >   org-revert-all-org-buffers loads all buffers from disk even if they didn't change.
> 
> FYI, there's also a package called revbufs:
> http://www.neilvandyke.org/revbufs/revbufs.el
> 

  That's very useful, thanks.

  I think org-revert-all-org-buffers does unneeded work and can be optimized, therefore I propose substituting it for org-revert-changed-or-buffers or some code from revbufs.el 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-02 12:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-27 10:18 revert all org buffers which changed on disk Daniel Clemente
2011-04-28 23:01 ` Jason Dunsmore
2011-05-02 12:09   ` Daniel Clemente

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).