Org-mode mailing list
 help / color / mirror / Atom feed
* Bug: :prologue and :epilogue are ignored in ob-sql code blocks (inter alia)
@ 2020-11-24 23:40 Tim Landscheidt
  2020-11-25  0:00 ` Tom Gillespie
  0 siblings, 1 reply; 2+ messages in thread
From: Tim Landscheidt @ 2020-11-24 23:40 UTC (permalink / raw)
  To: emacs-orgmode

With Emacs 27.1/org-mode 9.3, "(org) Environment of a Code
Block" ends with:

| Inserting headers and footers
| -----------------------------

| The ‘prologue’ header argument is for appending to the top of the code
| block for execution, like a reset instruction.  For example, you may use
| ‘:prologue "reset"’ in a Gnuplot code block or, for every such block:
|
|      (add-to-list 'org-babel-default-header-args:gnuplot
|                   '((:prologue . "reset")))

|    Likewise, the value of the ‘epilogue’ header argument is for
| appending to the end of the code block for execution.

However it appears as if :prologue and :epilogue are ignored
in ob-sql code blocks:

| #+NAME: test-for-ob-sql
| #+BEGIN_SRC sql :engine postgresql :results verbatim :prologue "SELECT 1;" :epilogue "SELECT 5;" :cmdline --no-psqlrc -P format=aligned -P footer=on
|   SELECT 2;
|   SELECT 3;
|   SELECT 4;
| #+END_SRC

| #+RESULTS: test-for-ob-sql
| #+begin_example
|  ?column?
| ----------
|         2
| (1 Zeile)

|  ?column?
| ----------
|         3
| (1 Zeile)

|  ?column?
| ----------
|         4
| (1 Zeile)

| #+end_example

It seems that :prologue and :epilogue are only honoured in
languages that use org-babel-expand-body:generic and a
(very) few others; especially, the following languages prob-
ably ignore them (untested):

| [tim@passepartout ~/src/emacs]$ find lisp/org -type f -name ob-\*.el \
| > -not -exec fgrep -q 'org-babel-expand-body:generic' {} \; \
| > -not -exec fgrep -q ':prologue' {} \; \
| > -print
| lisp/org/ob-C.el
| lisp/org/ob-J.el
| lisp/org/ob-abc.el
| lisp/org/ob-awk.el
| lisp/org/ob-calc.el
| lisp/org/ob-clojure.el
| lisp/org/ob-comint.el
| lisp/org/ob-css.el
| lisp/org/ob-ditaa.el
| lisp/org/ob-dot.el
| lisp/org/ob-ebnf.el
| lisp/org/ob-emacs-lisp.el
| lisp/org/ob-eval.el
| lisp/org/ob-exp.el
| lisp/org/ob-fortran.el
| lisp/org/ob-hledger.el
| lisp/org/ob-latex.el
| lisp/org/ob-ledger.el
| lisp/org/ob-lisp.el
| lisp/org/ob-lob.el
| lisp/org/ob-makefile.el
| lisp/org/ob-matlab.el
| lisp/org/ob-mscgen.el
| lisp/org/ob-org.el
| lisp/org/ob-picolisp.el
| lisp/org/ob-ref.el
| lisp/org/ob-sed.el
| lisp/org/ob-shen.el
| lisp/org/ob-sql.el
| lisp/org/ob-sqlite.el
| lisp/org/ob-table.el
| lisp/org/ob-stan.el
| lisp/org/ob-vala.el


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

* Re: Bug: :prologue and :epilogue are ignored in ob-sql code blocks (inter alia)
  2020-11-24 23:40 Bug: :prologue and :epilogue are ignored in ob-sql code blocks (inter alia) Tim Landscheidt
@ 2020-11-25  0:00 ` Tom Gillespie
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Gillespie @ 2020-11-25  0:00 UTC (permalink / raw)
  To: Tim Landscheidt; +Cc: emacs-orgmode

Tim,
    Thank for the report, and the digging for ob-langs that might be
affected. The underlying issue is that prologue and epilogue are part
of both the user facing parts of org babel as well as the internal
language implementation facing code. This is a fundamental design flaw
in org babel that needs to be fixed. I have been working on writing up
and diagraming a potential solution for community feedback, but it is
not quite ready yet. Thus, I'm filing this thread along with the
others that I have been compiling about org babel issues. Best!
Tom

On Tue, Nov 24, 2020 at 6:40 PM Tim Landscheidt <tim@tim-landscheidt.de> wrote:
>
> With Emacs 27.1/org-mode 9.3, "(org) Environment of a Code
> Block" ends with:
>
> | Inserting headers and footers
> | -----------------------------
>
> | The ‘prologue’ header argument is for appending to the top of the code
> | block for execution, like a reset instruction.  For example, you may use
> | ‘:prologue "reset"’ in a Gnuplot code block or, for every such block:
> |
> |      (add-to-list 'org-babel-default-header-args:gnuplot
> |                   '((:prologue . "reset")))
>
> |    Likewise, the value of the ‘epilogue’ header argument is for
> | appending to the end of the code block for execution.
>
> However it appears as if :prologue and :epilogue are ignored
> in ob-sql code blocks:
>
> | #+NAME: test-for-ob-sql
> | #+BEGIN_SRC sql :engine postgresql :results verbatim :prologue "SELECT 1;" :epilogue "SELECT 5;" :cmdline --no-psqlrc -P format=aligned -P footer=on
> |   SELECT 2;
> |   SELECT 3;
> |   SELECT 4;
> | #+END_SRC
>
> | #+RESULTS: test-for-ob-sql
> | #+begin_example
> |  ?column?
> | ----------
> |         2
> | (1 Zeile)
>
> |  ?column?
> | ----------
> |         3
> | (1 Zeile)
>
> |  ?column?
> | ----------
> |         4
> | (1 Zeile)
>
> | #+end_example
>
> It seems that :prologue and :epilogue are only honoured in
> languages that use org-babel-expand-body:generic and a
> (very) few others; especially, the following languages prob-
> ably ignore them (untested):
>
> | [tim@passepartout ~/src/emacs]$ find lisp/org -type f -name ob-\*.el \
> | > -not -exec fgrep -q 'org-babel-expand-body:generic' {} \; \
> | > -not -exec fgrep -q ':prologue' {} \; \
> | > -print
> | lisp/org/ob-C.el
> | lisp/org/ob-J.el
> | lisp/org/ob-abc.el
> | lisp/org/ob-awk.el
> | lisp/org/ob-calc.el
> | lisp/org/ob-clojure.el
> | lisp/org/ob-comint.el
> | lisp/org/ob-css.el
> | lisp/org/ob-ditaa.el
> | lisp/org/ob-dot.el
> | lisp/org/ob-ebnf.el
> | lisp/org/ob-emacs-lisp.el
> | lisp/org/ob-eval.el
> | lisp/org/ob-exp.el
> | lisp/org/ob-fortran.el
> | lisp/org/ob-hledger.el
> | lisp/org/ob-latex.el
> | lisp/org/ob-ledger.el
> | lisp/org/ob-lisp.el
> | lisp/org/ob-lob.el
> | lisp/org/ob-makefile.el
> | lisp/org/ob-matlab.el
> | lisp/org/ob-mscgen.el
> | lisp/org/ob-org.el
> | lisp/org/ob-picolisp.el
> | lisp/org/ob-ref.el
> | lisp/org/ob-sed.el
> | lisp/org/ob-shen.el
> | lisp/org/ob-sql.el
> | lisp/org/ob-sqlite.el
> | lisp/org/ob-table.el
> | lisp/org/ob-stan.el
> | lisp/org/ob-vala.el
>


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

end of thread, other threads:[~2020-11-25  0:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-24 23:40 Bug: :prologue and :epilogue are ignored in ob-sql code blocks (inter alia) Tim Landscheidt
2020-11-25  0:00 ` Tom Gillespie

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://orgmode.org/list/0 list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ https://orgmode.org/list \
		emacs-orgmode@gnu.org
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git