Browse Source

Agenda: New command to revert all Org-mode buffers from files

Carsten Dominik 16 years ago
parent
commit
ce42b4be86
3 changed files with 30 additions and 7 deletions
  1. 5 0
      lisp/ChangeLog
  2. 0 7
      lisp/org-agenda.el
  3. 25 0
      lisp/org.el

+ 5 - 0
lisp/ChangeLog

@@ -1,3 +1,8 @@
+2009-02-10  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.el (org-save-all-org-buffers): Moved here from org-agenda.el.
+	(org-revert-all-org-buffers): New command.
+
 2009-02-09  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org.el (org-return): Implement `org-return-follows-link' in the

+ 0 - 7
lisp/org-agenda.el

@@ -4327,13 +4327,6 @@ So this is just a shortcut for `\\[org-agenda]', available in the agenda."
   (let ((org-agenda-window-setup 'current-window))
     (org-agenda arg)))
 
-(defun org-save-all-org-buffers ()
-  "Save all Org-mode buffers without user confirmation."
-  (interactive)
-  (message "Saving all Org-mode buffers...")
-  (save-some-buffers t 'org-mode-p)
-  (message "Saving all Org-mode buffers... done"))
-
 (defun org-agenda-redo ()
   "Rebuild Agenda.
 When this is the global TODO list, a prefix argument will be interpreted."

+ 25 - 0
lisp/org.el

@@ -12269,6 +12269,31 @@ If there is already a time stamp at the cursor position, update it."
 	 (string-to-number (match-string 2 s)))
     0))
 
+;;;; Files
+
+(defun org-save-all-org-buffers ()
+  "Save all Org-mode buffers without user confirmation."
+  (interactive)
+  (message "Saving all Org-mode buffers...")
+  (save-some-buffers t 'org-mode-p)
+  (message "Saving all Org-mode buffers... done"))
+
+(defun org-revert-all-org-buffers ()
+  "Revert all Org-mode buffers.
+Prompt for confirmation when there are unsaved changes."
+  (interactive)
+  (unless (yes-or-no-p "Revert all 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))
+	   (switch-to-buffer b)
+	   (revert-buffer t 'no-confirm)))
+       (buffer-list)))))
+
 ;;;; Agenda files
 
 ;;;###autoload