--- org.el Fri Jun 19 12:07:26 2015 +++ org-modif.el Wed Jun 24 09:13:10 2015 @@ -18097,17 +18097,28 @@ (defun org-file-menu-entry (file) (vector file (list 'find-file file) t)) -(defun org-check-agenda-file (file) - "Make sure FILE exists. If not, ask user what to do." +(defun org-check-agenda-file-1 (file) + "Make sure FILE exists. If not, ask user what to do. + +Possible outcomes: +1. File exists -> return NIL. +2. File doesn't exist and user requests to remove it -> throws 'nextfile. +3. File doesn't exist and user requests to remove it -> raise error \"Abort\". + +You probably want `org-check-agenda-file'." (when (not (file-exists-p file)) (message "Non-existent agenda file %s. [R]emove from list or [A]bort?" (abbreviate-file-name file)) (let ((r (downcase (read-char-exclusive)))) (cond ((equal r ?r) - (org-remove-file file) (throw 'nextfile t)) (t (error "Abort")))))) + +(defun org-check-agenda-file (file) + "Make sure FILE exists, else if user agrees, remove FILE from `org-agenda-files'." + (when (catch 'nextfile (org-check-agenda-file-1 file)) + (org-remove-file file))) (defun org-get-agenda-file-buffer (file) "Get a buffer visiting FILE. If the buffer needs to be created, add --- org-contacts.el Fri Jun 19 12:07:20 2015 +++ org-contacts-modif.el Wed Jun 24 09:13:56 2015 @@ -216,7 +216,18 @@ (defun org-contacts-files () "Return list of Org files to use for contact management." - (or org-contacts-files (org-agenda-files t 'ifmode))) + (if org-contacts-files + (org-remove-if (lambda (file) + (when (catch 'nextfile + (org-check-agenda-file-1 file)) + (customize-save-variable 'org-contacts-files + (delete file org-contacts-files)))) + org-contacts-files) + (let (result) + (dolist (file (org-agenda-files t 'ifmode) (nreverse result)) + (unless (catch 'nextfile + (org-check-agenda-file file)) + (push file result)))))) (defun org-contacts-db-need-update-p () "Determine whether `org-contacts-db' needs to be refreshed." @@ -250,7 +261,6 @@ (make-progress-reporter "Updating Org Contacts Database..." 0 (length org-contacts-files))) (i 0)) (dolist (file (org-contacts-files)) - (org-check-agenda-file file) (with-current-buffer (org-get-agenda-file-buffer file) (unless (eq major-mode 'org-mode) (error "File %s is no in `org-mode'" file))