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: Wed, 01 Jul 2015 17:39:53 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5.50 (gnu/linux)

address@hidden writes:

> Hi Nicolas and Greg,

Hi Philippe, sorry for the late reply :(

> Thank you for applying my initial patch.
>
> Inspired by Greg's improvements to my patch, I'd like to propose the attached 
> (presumptuously named) better-patch that I believe fixes the TODO of my 
> initial patch.
>
> Sorry it isn't quite in the format of the previous one/recommended by the 
> project but I'm not on my main machine now.

> --- 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"))))))

The 3. item looks wrong to me. I think it should be:
3. File doesn't exist and user requests to abort -> raise 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

Moreover, I'm not sure about changing the behaviour of an existing
function. Though the change looks good to me, it is very likely users
(or maybe even other parts of org-mode, I'haven't check) rely on it, and
expect to catch exceptions.

> +++ org-contacts-modif.el     Wed Jun 24 09:13:56 2015
> [snip]

I agree with the modifications of org-contacts.el.


Maybe org-contacts.el should have its own version of
`org-check-agenda-file' (e.g. named `org-contacts-check-contacts-file')
until we find a better solution...

WDYT?


Best,

-- 
Daimrod/Greg

Attachment: signature.asc
Description: PGP signature


reply via email to

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