emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* declaring :var in a property drawer
@ 2021-05-23 14:25 Greg Minshall
  2021-05-24  8:57 ` Eric S Fraga
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Minshall @ 2021-05-23 14:25 UTC (permalink / raw)
  To: emacs-orgmode

hi.  i noticed the following behavior, and am curious if it is
intentional.

if i declare a :tangle and a :var in a property drawer and then, in that
subtree, have N>1 source blocks (which will all end up in the same
tangled file), the :var'iable will be assigned a value N times.  below i
have an example using bash source blocks, where it doesn't make sense,
afaics(ee).  (when exporting elisp blocks, each :var'iable is assigned a
value in a =let= form that surrounds the code for that block, so i guess
it makes sense.)

cheers, Greg

* :var's and property drawers
    :properties:
    :header-args: :tangle "foo.bar"
    :header-args+: :var x=1
    :end:

#+begin_src bash
  echo x is $x
#+end_src

#+begin_src bash
    echo "'x.*=.*1' occurences:"
    grep 'x.*=.*1' foo.bar | grep -v grep
#+end_src


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

* Re: declaring :var in a property drawer
  2021-05-23 14:25 declaring :var in a property drawer Greg Minshall
@ 2021-05-24  8:57 ` Eric S Fraga
  2021-05-24  9:22   ` Greg Minshall
  0 siblings, 1 reply; 3+ messages in thread
From: Eric S Fraga @ 2021-05-24  8:57 UTC (permalink / raw)
  To: Greg Minshall; +Cc: emacs-orgmode

On Sunday, 23 May 2021 at 17:25, Greg Minshall wrote:
> hi.  i noticed the following behavior, and am curious if it is
> intentional.

I would suggest it is intentional: setting a header property means it
applies to *all* src blocks.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.5-534-g8f03cd


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

* Re: declaring :var in a property drawer
  2021-05-24  8:57 ` Eric S Fraga
@ 2021-05-24  9:22   ` Greg Minshall
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Minshall @ 2021-05-24  9:22 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: emacs-orgmode

Eric,

> I would suggest it is intentional: setting a header property means it
> applies to *all* src blocks.

thanks.  but, in this case, all source blocks are being tangled to the
same file.  which, for many (most?) languages (but not elisp), means the
variable is going to be defined (and re-defined) at (the particular
language's version of) global scope.  which seems mostly redundant.

that was what i was wondering about.

cheers, Greg


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

end of thread, other threads:[~2021-05-24  9:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-23 14:25 declaring :var in a property drawer Greg Minshall
2021-05-24  8:57 ` Eric S Fraga
2021-05-24  9:22   ` Greg Minshall

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