Daniel Bausch <[email protected]> writes:
>> Probably, it should. Consider a block with :eval no. If you want to run
>> it, there should be a way to override :eval.
>
> I realized myself, while playing around with the prototype
> implementation, that I actually quite often need to not only assign
> variables, but also need to override header arguments. I therefore
> developed this further to have a special separator key ":&headers" in
> the argument list after which header arguments can be specified.
Introducing new semantics is generally not the best idea.
Ideally, we should reuse something either from Elisp, or, at least, from
Org.
> I have developed another machinery (cascading header arg classes - off
> topic here) that allows me to switch the target database much easier.
> So with "#+call:" I write.
>
> #+name: foo
> #+begin_src sql :var hello="world"
> SELECT '$hello' FROM dual;
> #+end_src
>
> #+call: foo("org") :class alice@db1
>
> #+call: foo("mode") :class bob@db2
While it may be tempting to develop whole new concepts for Org,
especially when you can implement them with LLM, I strongly advice
trying built-in options and customizations first. Org (and Elisp) have
plenty of features that are flexible enough to fit many needs. Adding
new things will produce subtle (or not so subtle) bugs, sooner or later,
especially as you update to new Org version developed without your new
additions in mind.
> The equivalent with the :&headers key is then:
>
> #+begin_src elisp
> (let ((result1 (org-babel-call "foo"))
> (result2 (org-babel-call "foo" :hello "org" :&headers :class
> "alice@db1"))
> (result3 (org-babel-call "foo" :hello "mode" :&headers :class
> "bob@db2")))
> ...)
> #+end_src
What about simply
(org-babel-call "foo"
:class "alice@db1"
:var hello "org")
and making org-babel-call a macro (so that hello do not need to be quoted)?
> I also thought about adding support for positional arguments which
> "#+call" also has. (Those then do not look like header arguments
> anymore.)
>
> (org-babel-call "foo" "org")
> (org-babel-call "foo" "org" :&headers :class "alice@db1")
This idea has merits, but I am not a fan of new concept with :&headers.
Alternative idea:
(org-babel-call (foo "org")
:class "alice@db1)
(org-babel-call (foo :hello "org")
:class "alice@db1" :eval "yes")
(foo :hello "org") will follow normal Elisp function semantics but call
src blocks. Header args specified as extra.
A bit like `eval'.
--
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>