Browse Source

org-agenda.el (org-agenda-write): Ask before overwriting an existing file

* org-agenda.el (org-agenda-write): Ask before overwriting an
existing file.

Thanks to Rainer Stengele for suggesting this.
Bastien Guerry 12 years ago
parent
commit
0c40f479cd
1 changed files with 3 additions and 1 deletions
  1. 3 1
      lisp/org-agenda.el

+ 3 - 1
lisp/org-agenda.el

@@ -3210,7 +3210,9 @@ the settings have already been scoped and we do not wish to overrule other,
 higher priority settings.
 If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write."
   (interactive "FWrite agenda to file: \nP")
-  (if (not (file-writable-p file))
+  (if (or (not (file-writable-p file))
+	  (and (file-exists-p file)
+	       (not (y-or-n-p (format "Overwrite existing file %s? " file)))))
       (error "Cannot write agenda to file %s" file))
   (org-let (if nosettings nil org-agenda-exporter-settings)
     '(save-excursion