emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Daimrod <daimrod@gmail.com>
To: Philippe Crama <phcrama.ebiz@gmx.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] org-contacts.el: Catch 'nextfile in org-contacts-db
Date: Sun, 21 Jun 2015 18:14:09 +0200	[thread overview]
Message-ID: <87zj3tqbse.fsf@gmail.com> (raw)
In-Reply-To: <7za8w7j4o5.wl-phcrama.ebiz@gmx.com> (Philippe Crama's message of "Wed, 10 Jun 2015 11:25:46 +0200")


[-- Attachment #1.1: Type: text/plain, Size: 395 bytes --]

Philippe Crama <phcrama.ebiz@gmx.com> 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?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-org-contacts.el-Handle-missing-files-in-org-contacts.patch --]
[-- Type: text/x-diff, Size: 1967 bytes --]

From b3bb252c6e2138fa65b7c960060d68ea8c260873 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gr=C3=A9goire=20Jadi?= <gregoire.jadi@univ-nantes.fr>
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


[-- Attachment #1.3: Type: text/plain, Size: 37 bytes --]



> Regards,

-- 
Daimrod/Greg

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

  reply	other threads:[~2015-06-21 16:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-10  9:25 [PATCH] org-contacts.el: Catch 'nextfile in org-contacts-db Philippe Crama
2015-06-21 16:14 ` Daimrod [this message]
2015-06-23 21:49 ` Nicolas Goaziou
     [not found] <trinity-55a13834-abf3-4572-9c5a-fd0b5f8c5cd6-1435130389011@3capp-mailcom-bs13>
2015-06-25 11:01 ` phcrama.ebiz
2015-07-01 15:39   ` Daimrod
2015-07-04 21:12     ` phcrama.ebiz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zj3tqbse.fsf@gmail.com \
    --to=daimrod@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=phcrama.ebiz@gmx.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).