* [Patch] Fix handling of variable capture location
@ 2017-05-17 0:57 Yuri Lensky
2017-05-17 12:25 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: Yuri Lensky @ 2017-05-17 0:57 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
[-- Attachment #1.1: Type: text/plain, Size: 65 bytes --]
Capture locations in variable not working before this patch.
YL
[-- Attachment #1.2: Type: text/html, Size: 121 bytes --]
[-- Attachment #2: 0001-org-capture.el-Fix-handling-of-variable-capture-loca.patch --]
[-- Type: application/octet-stream, Size: 915 bytes --]
From c0de1c390b370b497fbb093ac5efd3d7aeaac0dc Mon Sep 17 00:00:00 2001
From: "Yuri D. Lensky" <ydlensky@gmail.com>
Date: Sun, 12 Mar 2017 17:58:15 -0700
Subject: [PATCH] org-capture.el: Fix handling of variable capture location
---
lisp/org-capture.el | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 9ac9294..04c446d 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1060,7 +1060,8 @@ case, raise an error."
(let ((location (cond ((equal file "") org-default-notes-file)
((stringp file) (expand-file-name file org-directory))
((functionp file) (funcall file))
- ((and (symbolp file) (bound-and-true-p file)))
+ ((and (symbolp file) (boundp file) (symbol-value file))
+ (symbol-value file))
(t nil))))
(or (org-string-nw-p location)
(error "Invalid file location: %S" location))))
--
2.9.2.windows.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Patch] Fix handling of variable capture location
2017-05-17 0:57 [Patch] Fix handling of variable capture location Yuri Lensky
@ 2017-05-17 12:25 ` Nicolas Goaziou
2017-05-17 18:52 ` Yuri Lensky
0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2017-05-17 12:25 UTC (permalink / raw)
To: Yuri Lensky; +Cc: emacs-orgmode@gnu.org
Hello,
Yuri Lensky <ydl@ydl.cm> writes:
> Capture locations in variable not working before this patch.
Thank you.
Could you show an example demonstrating the issue? The only difference
I can see with your patch is that you're referring to the global value
of file, not the local one.
> From c0de1c390b370b497fbb093ac5efd3d7aeaac0dc Mon Sep 17 00:00:00 2001
> From: "Yuri D. Lensky" <ydlensky@gmail.com>
> Date: Sun, 12 Mar 2017 17:58:15 -0700
> Subject: [PATCH] org-capture.el: Fix handling of variable capture location
>
> ---
> lisp/org-capture.el | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/lisp/org-capture.el b/lisp/org-capture.el
> index 9ac9294..04c446d 100644
> --- a/lisp/org-capture.el
> +++ b/lisp/org-capture.el
> @@ -1060,7 +1060,8 @@ case, raise an error."
> (let ((location (cond ((equal file "") org-default-notes-file)
> ((stringp file) (expand-file-name file org-directory))
> ((functionp file) (funcall file))
> - ((and (symbolp file) (bound-and-true-p file)))
> + ((and (symbolp file) (boundp file) (symbol-value file))
> + (symbol-value file))
The second call to `symbol-value' is not needed.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch] Fix handling of variable capture location
2017-05-17 12:25 ` Nicolas Goaziou
@ 2017-05-17 18:52 ` Yuri Lensky
2017-05-19 14:16 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: Yuri Lensky @ 2017-05-17 18:52 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode@gnu.org, Yuri Lensky
[-- Attachment #1: Type: text/plain, Size: 1833 bytes --]
The second call is indeed needed. This is the case fixed by the patch:
(setq org-default-notes-file (expand-file-name "~/docs/notes.org"))
(setq org-capture-templates '(("t" "Todo" entry (file+olp
org-default-notes-file "Inbox") "* TODO %?\n%i")))
This breaks without the second symbol-value. The first is required to
replicate the intended functionality of bound-and-true-p.
YL
On Wed, May 17, 2017 at 5:25 AM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:
> Hello,
>
> Yuri Lensky <ydl@ydl.cm> writes:
>
> > Capture locations in variable not working before this patch.
>
> Thank you.
>
> Could you show an example demonstrating the issue? The only difference
> I can see with your patch is that you're referring to the global value
> of file, not the local one.
>
> > From c0de1c390b370b497fbb093ac5efd3d7aeaac0dc Mon Sep 17 00:00:00 2001
> > From: "Yuri D. Lensky" <ydlensky@gmail.com>
> > Date: Sun, 12 Mar 2017 17:58:15 -0700
> > Subject: [PATCH] org-capture.el: Fix handling of variable capture
> location
> >
> > ---
> > lisp/org-capture.el | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/lisp/org-capture.el b/lisp/org-capture.el
> > index 9ac9294..04c446d 100644
> > --- a/lisp/org-capture.el
> > +++ b/lisp/org-capture.el
> > @@ -1060,7 +1060,8 @@ case, raise an error."
> > (let ((location (cond ((equal file "") org-default-notes-file)
> > ((stringp file) (expand-file-name file
> org-directory))
> > ((functionp file) (funcall file))
> > - ((and (symbolp file) (bound-and-true-p file)))
> > + ((and (symbolp file) (boundp file) (symbol-value
> file))
> > + (symbol-value file))
>
> The second call to `symbol-value' is not needed.
>
> Regards,
>
> --
> Nicolas Goaziou
>
[-- Attachment #2: Type: text/html, Size: 2741 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch] Fix handling of variable capture location
2017-05-17 18:52 ` Yuri Lensky
@ 2017-05-19 14:16 ` Nicolas Goaziou
2017-05-19 23:37 ` Yuri Lensky
0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2017-05-19 14:16 UTC (permalink / raw)
To: Yuri Lensky; +Cc: emacs-orgmode@gnu.org
Hello,
Yuri Lensky <ydl@ydl.cm> writes:
> The second call is indeed needed.
AFAICT, it isn't.
(cond ('foo) (t nil)) => 'foo
> This is the case fixed by the patch:
>
> (setq org-default-notes-file (expand-file-name "~/docs/notes.org"))
> (setq org-capture-templates '(("t" "Todo" entry (file+olp
> org-default-notes-file "Inbox") "* TODO %?\n%i")))
OK, I see. I introduced this regression in
88a3c2483ee47b342e9bb7d2c1645dce11179bf5.
I applied your patch with a slight change:
((and (symbolp file) (boundp file) (symbol-value file)) (symbol-value file))
=>
((and (symbolp file) (boundp file)) (symbol-value file))
Thank you.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch] Fix handling of variable capture location
2017-05-19 14:16 ` Nicolas Goaziou
@ 2017-05-19 23:37 ` Yuri Lensky
2017-05-20 6:36 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: Yuri Lensky @ 2017-05-19 23:37 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode@gnu.org, Yuri Lensky
[-- Attachment #1: Type: text/plain, Size: 1257 bytes --]
Thanks!
I now understand what you mean by the second call to symbol-value not being
needed. The previous behavior only chose this "branch" of the cond if
symbol-value was not nil. To keep this behavior but only have one call to
symbol-value, why not change to (keep the symbol-value in the cond as
opposed to the body of the branch):
((and (symbolp file) (boundp file) (symbol-value file)))
to keep the old behavior of the cond statement?
YL
On Fri, May 19, 2017 at 7:16 AM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:
> Hello,
>
> Yuri Lensky <ydl@ydl.cm> writes:
>
> > The second call is indeed needed.
>
> AFAICT, it isn't.
>
> (cond ('foo) (t nil)) => 'foo
>
> > This is the case fixed by the patch:
> >
> > (setq org-default-notes-file (expand-file-name "~/docs/notes.org"))
> > (setq org-capture-templates '(("t" "Todo" entry (file+olp
> > org-default-notes-file "Inbox") "* TODO %?\n%i")))
>
> OK, I see. I introduced this regression in
> 88a3c2483ee47b342e9bb7d2c1645dce11179bf5.
>
> I applied your patch with a slight change:
>
> ((and (symbolp file) (boundp file) (symbol-value file)) (symbol-value
> file))
>
> =>
>
> ((and (symbolp file) (boundp file)) (symbol-value file))
>
> Thank you.
>
> Regards,
>
> --
> Nicolas Goaziou
>
[-- Attachment #2: Type: text/html, Size: 2091 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch] Fix handling of variable capture location
2017-05-19 23:37 ` Yuri Lensky
@ 2017-05-20 6:36 ` Nicolas Goaziou
0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2017-05-20 6:36 UTC (permalink / raw)
To: Yuri Lensky; +Cc: emacs-orgmode@gnu.org
Hello,
Yuri Lensky <ydl@ydl.cm> writes:
> I now understand what you mean by the second call to symbol-value not being
> needed. The previous behavior only chose this "branch" of the cond if
> symbol-value was not nil. To keep this behavior but only have one call to
> symbol-value, why not change to (keep the symbol-value in the cond as
> opposed to the body of the branch):
>
> ((and (symbolp file) (boundp file) (symbol-value file)))
>
> to keep the old behavior of the cond statement?
We don't need to keep the old behaviour. The current one is as good.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-05-20 6:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-17 0:57 [Patch] Fix handling of variable capture location Yuri Lensky
2017-05-17 12:25 ` Nicolas Goaziou
2017-05-17 18:52 ` Yuri Lensky
2017-05-19 14:16 ` Nicolas Goaziou
2017-05-19 23:37 ` Yuri Lensky
2017-05-20 6:36 ` Nicolas Goaziou
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).