emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] Dynamic scoping of project-plist in preparation-function
@ 2016-06-21 18:16 Arun Isaac
  2016-06-21 20:15 ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Arun Isaac @ 2016-06-21 18:16 UTC (permalink / raw)
  To: Emacs-orgmode@gnu.org


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


The org mode manual says "The project property list is scoped into this
call as the variable project-plist". But, ox-publish.el has lexical
binding enabled, and the variable project-plist doesn't seem to be
accessible from the executed preparation-function. When I try to access
the variable, I get a (void-variable project-plist) error.

Please find attached a minimal elisp file to reproduce the bug.

emacs -Q -l preparation-function-dynamic-scoping.el

My understanding of dynamic and lexical binding is a little foggy. So,
do let me know if I'm missing something.

Regards,
Arun Isaac.


[-- Attachment #1.2: preparation-function-dynamic-scoping.el --]
[-- Type: application/emacs-lisp, Size: 510 bytes --]

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] Dynamic scoping of project-plist in preparation-function
  2016-06-21 18:16 [BUG] Dynamic scoping of project-plist in preparation-function Arun Isaac
@ 2016-06-21 20:15 ` Nicolas Goaziou
  2016-06-22  6:07   ` Arun Isaac
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2016-06-21 20:15 UTC (permalink / raw)
  To: Arun Isaac; +Cc: Emacs-orgmode@gnu.org

Hello,

Arun Isaac <arunisaac@systemreboot.net> writes:

> The org mode manual says "The project property list is scoped into this
> call as the variable project-plist". But, ox-publish.el has lexical
> binding enabled, and the variable project-plist doesn't seem to be
> accessible from the executed preparation-function. When I try to access
> the variable, I get a (void-variable project-plist) error.
>
> Please find attached a minimal elisp file to reproduce the bug.
>
> emacs -Q -l preparation-function-dynamic-scoping.el
>
> My understanding of dynamic and lexical binding is a little foggy. So,
> do let me know if I'm missing something.

There are two ways to handle this.

1. Create a new global variable, with appropriate prefix, to hold
   project plist, e.g., `org-publish-project-plist';

2. Require preparation functions to accept one parameter, the project
   plist.

I'd favor the second one. In any case, the manual should be updated
accordingly.

WDYT?

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] Dynamic scoping of project-plist in preparation-function
  2016-06-21 20:15 ` Nicolas Goaziou
@ 2016-06-22  6:07   ` Arun Isaac
  2016-06-22 13:34     ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Arun Isaac @ 2016-06-22  6:07 UTC (permalink / raw)
  To: Emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 596 bytes --]


> 2. Require preparation functions to accept one parameter, the project
>    plist.

I think adding project-plist as a parameter to preparation functions is
definitely more elegant.

But, I also came across this old thread where it was noted that making
project-plist a proper parameter, instead of it being dynamically scoped
into the preparation function, would break a lot of code.

https://lists.gnu.org/archive/html/emacs-orgmode/2010-03/msg00016.html

But now, with org moving to lexical binding, I think it is time to make
project-plist a proper parameter, despite the costs of doing so.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] Dynamic scoping of project-plist in preparation-function
  2016-06-22  6:07   ` Arun Isaac
@ 2016-06-22 13:34     ` Nicolas Goaziou
  2016-06-22 14:37       ` Arun Isaac
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2016-06-22 13:34 UTC (permalink / raw)
  To: Arun Isaac; +Cc: Emacs-orgmode@gnu.org

Hello,

Arun Isaac <arunisaac@systemreboot.net> writes:

>> 2. Require preparation functions to accept one parameter, the project
>>    plist.
>
> I think adding project-plist as a parameter to preparation functions is
> definitely more elegant.

Done in 5cd793c.

> But, I also came across this old thread where it was noted that making
> project-plist a proper parameter, instead of it being dynamically scoped
> into the preparation function, would break a lot of code.

Bad code deserves to be broken anyway.

More seriously, the fix is trivial, so I don't think this is an issue.

Thank you for the feedback.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] Dynamic scoping of project-plist in preparation-function
  2016-06-22 13:34     ` Nicolas Goaziou
@ 2016-06-22 14:37       ` Arun Isaac
  2016-06-22 16:37         ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Arun Isaac @ 2016-06-22 14:37 UTC (permalink / raw)
  To: Emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 295 bytes --]


> Done in 5cd793c.

After 5cd793c, the documentation for the preparation function says
"Each preparation function is called with a single argument, the project
property". This could be clearer if it is "... the project property
list", as it is in the documentation for the completion function.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] Dynamic scoping of project-plist in preparation-function
  2016-06-22 14:37       ` Arun Isaac
@ 2016-06-22 16:37         ` Nicolas Goaziou
  0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2016-06-22 16:37 UTC (permalink / raw)
  To: Arun Isaac; +Cc: Emacs-orgmode@gnu.org

Arun Isaac <arunisaac@systemreboot.net> writes:

> After 5cd793c, the documentation for the preparation function says
> "Each preparation function is called with a single argument, the project
> property". This could be clearer if it is "... the project property
> list", as it is in the documentation for the completion function.

Indeed, that's a typo. Fixed. Thank you.

Regards,

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-06-22 16:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-21 18:16 [BUG] Dynamic scoping of project-plist in preparation-function Arun Isaac
2016-06-21 20:15 ` Nicolas Goaziou
2016-06-22  6:07   ` Arun Isaac
2016-06-22 13:34     ` Nicolas Goaziou
2016-06-22 14:37       ` Arun Isaac
2016-06-22 16:37         ` 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).