From: Ihor Radchenko <yantar92@gmail.com>
To: sebastien.miquel@posteo.eu
Cc: emacs-orgmode <emacs-orgmode@gnu.org>,
Greg Minshall <minshall@umich.edu>
Subject: Re: [FR] Make :var foo=name-of-src-block assign the source block code instead of currently assigned result of evaluation (was: [PATCH] Add :noweb-prefix and :noweb-trans babel header arguments)
Date: Sat, 23 Jul 2022 12:52:12 +0800 [thread overview]
Message-ID: <87sfmsv3b7.fsf@localhost> (raw)
In-Reply-To: <635c8e99-ea37-f93a-4eab-e547d2c2ab61@posteo.eu>
Sébastien Miquel <sebastien.miquel@posteo.eu> writes:
> The uses are maybe too niche to warrant the breaking change. A syntax
> extension like
> : var=block-id[]
> seems possible, even though brackets are already overloaded.
This sounds better. Using brackets will actually make a lot of sense.
Currently, we have roughly the following logic in the :var references:
- :var x=reference(<optional parameters>)
will execute the reference and assign the returned value
- :var x=reference[<optional parameters>]
will take the reference text representation, possibly process it
according to the parameters, and return the processed text
*this only works for tables*
- :var x=reference
will perform some "default" action depending on the reference type.
the action may be "execute" or "get text representation" for source
blocks and others correspondingly.
Extending reference[...] syntax to all the element types will make
things consistent and allow future extensions if we decide to provide
"index" syntax for non-tables (code lines, function definitions?)
> One alternative is to only allow the syntax inside noweb brackets
> instead of generic variable arguments. I assume there'd be much less
> breakage. It would also makes sense to allow noweb references instead
> of block ids. We'd add support for
> : <<babel-fn(var=noweb-ref)>>
> and <<babel-fn(var=block-id)>> would also insert the contents as a
> by-product.
This would still be a breaking change. And we will introduce
inconsistency between resolving noweb references and resolving :var
header args.
Moreover, resolving references is currently handled by the same code
inside :vars and noweb references. Changing this will complicate the
source code as well, IMHO increasing the maintenance burden too much.
> Do you have any example of use in mind, beyond my original one ?
For example, one may convert .el file commentary to Readme.org:
#+name: my-library
#+begin_src :tangle my-library.el
;; Commentary:
;; A lot of commentary
#+end_src
#+begin_src :exports results :var commentary=my-library[]
(convert-to-org-headlines commentary)
#+end_src
Best,
Ihor
next prev parent reply other threads:[~2022-07-23 4:52 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-15 10:42 [PATCH] Add :noweb-prefix and :noweb-trans babel header arguments Sébastien Miquel
2022-04-28 13:45 ` Ihor Radchenko
2022-04-29 14:27 ` Sébastien Miquel
2022-04-30 6:05 ` Ihor Radchenko
2022-04-30 7:35 ` Sébastien Miquel
2022-04-30 8:41 ` Ihor Radchenko
2022-05-30 19:51 ` Sébastien Miquel
2022-05-31 5:14 ` Ihor Radchenko
2022-05-31 6:48 ` Sébastien Miquel
2022-07-16 8:57 ` [FR] Make :var foo=name-of-src-block assign the source block code instead of currently assigned result of evaluation (was: [PATCH] Add :noweb-prefix and :noweb-trans babel header arguments) Ihor Radchenko
2022-07-16 10:17 ` Greg Minshall
2022-07-16 10:45 ` Ihor Radchenko
2022-07-16 14:31 ` Greg Minshall
2022-07-17 17:39 ` Sébastien Miquel
2022-07-23 4:52 ` Ihor Radchenko [this message]
2022-08-29 17:39 ` [PATCH] " Sébastien Miquel
2022-08-31 4:04 ` Ihor Radchenko
2022-07-21 11:13 ` [PATCH] org-babel: Do not echo output of resolved noweb references Ihor Radchenko
2022-07-21 13:41 ` Sébastien Miquel
2022-08-22 12:01 ` Ihor Radchenko
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sfmsv3b7.fsf@localhost \
--to=yantar92@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=minshall@umich.edu \
--cc=sebastien.miquel@posteo.eu \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.