emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [PATCH] org-contacts.el: Catch 'nextfile in org-contacts-db


From: Daimrod
Subject: Re: [O] [PATCH] org-contacts.el: Catch 'nextfile in org-contacts-db
Date: Sun, 21 Jun 2015 18:14:09 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5.50 (gnu/linux)

Philippe Crama <address@hidden> writes:

> Hi,

Hello Philippe,

> This is a small patch to catch the 'nextfile thrown by
> `org-check-agenda-file' in `org-contacts-db'.
>
> I don't know how to fix the TODO in the comment myself, sorry.  At
> least, with the patch, the execution doesn't abort anymore.

Thanks for the report and the patch. I've attached a patch inspired by
yours. WDYT?

From b3bb252c6e2138fa65b7c960060d68ea8c260873 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gr=C3=A9goire=20Jadi?= <address@hidden>
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


> Regards,

-- 
Daimrod/Greg

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]