From b3bb252c6e2138fa65b7c960060d68ea8c260873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Jadi?= Date: Mon, 15 Jun 2015 09:36:36 +0200 Subject: [PATCH] org-contacts.el: Handle missing files in `org-contacts-files' gracefully * contrib/lisp/org-contacts.el (org-contacts-files): Catch 'nextfile From `org-check-agenda-file' and update `org-contacts-files' if modified. (org-contacts-db): Don't call `org-check-agenda-file' now called in `org-contacts-files'. When `org-agenda-files' contains non-existent files, remove them if the user asks for it instead of failing. Modified from a patch proposal by Philippe Crama --- contrib/lisp/org-contacts.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el index bc07fc1..3e14c7e 100644 --- a/contrib/lisp/org-contacts.el +++ b/contrib/lisp/org-contacts.el @@ -227,7 +227,12 @@ A regexp matching strings of whitespace, `,' and `;'.") (defun org-contacts-files () "Return list of Org files to use for contact management." - (or org-contacts-files (org-agenda-files t 'ifmode))) + (org-remove-if (lambda (file) + (when (catch 'nextfile + (org-check-agenda-file file)) + (customize-save-variable 'org-contacts-files + (delete file org-contacts-files)))) + (or org-contacts-files (org-agenda-files t 'ifmode)))) (defun org-contacts-db-need-update-p () "Determine whether `org-contacts-db' needs to be refreshed." @@ -261,7 +266,6 @@ to dead or no buffer." (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 not in `org-mode'" file)) -- 1.9.1