* Avoid "Scheme implementation" prompt on export
@ 2024-10-14 10:17 Roi Martin
2024-10-14 17:45 ` Bruno Barbier
2024-10-19 13:32 ` Ihor Radchenko
0 siblings, 2 replies; 15+ messages in thread
From: Roi Martin @ 2024-10-14 10:17 UTC (permalink / raw)
To: emacs-orgmode
Hello,
I have an org document with the following structure:
---
Racket code block:
#+begin_src scheme
#lang racket
(+ 1 2)
#+end_src
Chez Scheme code block:
#+begin_src scheme
(+ 3 4)
#+end_src
---
It includes several code blocks with different scheme implementations
(e.g. Racket and Chez).
When I export the document to HTML, both from the Org Export Dispatcher
(C-c C-e) or calling (org-publish-all), I'm asked to choose a "Scheme
implementation" for every code block.
If I understand correctly, I can set a default Scheme implementation
with the `geiser-scheme-implementation' variable. However, I would like
to specify an implementation per block without having to answer the
prompt every time.
Is it possible?
Just in case, it is useful, I'm using the following package versions:
- GNU Emacs 29.4
- org 9.6.15
- geiser 20240907.2235
- geiser-chez 20230707.1334
- geiser-guile 20240920.35
- geiser-racket 20210421.125
- htmlize 20240915.1657
Thanks for your help!
Best,
Roi
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Avoid "Scheme implementation" prompt on export
2024-10-14 10:17 Avoid "Scheme implementation" prompt on export Roi Martin
@ 2024-10-14 17:45 ` Bruno Barbier
[not found] ` <87bjzma6ml.fsf@gmail.com>
2024-10-19 13:32 ` Ihor Radchenko
1 sibling, 1 reply; 15+ messages in thread
From: Bruno Barbier @ 2024-10-14 17:45 UTC (permalink / raw)
To: Roi Martin, emacs-orgmode
Hi Roi,
Roi Martin <jroi.martin@gmail.com> writes:
> If I understand correctly, I can set a default Scheme implementation
> with the `geiser-scheme-implementation' variable. However, I would like
> to specify an implementation per block without having to answer the
> prompt every time.
>
> Is it possible?
According to the current source code, you should be able to pick the
scheme implementation using the :scheme argument (either per block, per
heading, or per buffer). It should take the same value as the variable
'geiser-scheme-implementation'.
I don't have any scheme installed: I couldn't test it. Note that if
you're using sessions, that value will probably be ignored for already
opened sessions.
HTH,
Bruno
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Avoid "Scheme implementation" prompt on export
2024-10-14 10:17 Avoid "Scheme implementation" prompt on export Roi Martin
2024-10-14 17:45 ` Bruno Barbier
@ 2024-10-19 13:32 ` Ihor Radchenko
2024-10-20 11:36 ` Bruno Barbier
1 sibling, 1 reply; 15+ messages in thread
From: Ihor Radchenko @ 2024-10-19 13:32 UTC (permalink / raw)
To: Roi Martin; +Cc: emacs-orgmode
Roi Martin <jroi.martin@gmail.com> writes:
> I have an org document with the following structure:
>
> ---
> Racket code block:
>
> #+begin_src scheme
> #lang racket
> (+ 1 2)
> #+end_src
> ...
> It includes several code blocks with different scheme implementations
> (e.g. Racket and Chez).
>
> When I export the document to HTML, both from the Org Export Dispatcher
> (C-c C-e) or calling (org-publish-all), I'm asked to choose a "Scheme
> implementation" for every code block.
>
> If I understand correctly, I can set a default Scheme implementation
> with the `geiser-scheme-implementation' variable. However, I would like
> to specify an implementation per block without having to answer the
> prompt every time.
>
> Is it possible?
Org mode fontification routines do not support multiple different
variants of major mode in src blocks.
We also cannot handle major modes prompting user when they are
activated.
Actually, I have no idea how to handle such scenarios.
--
Ihor Radchenko // yantar92,
Org mode contributor,
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>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Avoid "Scheme implementation" prompt on export
2024-10-19 13:32 ` Ihor Radchenko
@ 2024-10-20 11:36 ` Bruno Barbier
2024-10-20 11:40 ` Ihor Radchenko
0 siblings, 1 reply; 15+ messages in thread
From: Bruno Barbier @ 2024-10-20 11:36 UTC (permalink / raw)
To: Ihor Radchenko, Roi Martin; +Cc: emacs-orgmode
Hi Ihor,
Ihor Radchenko <yantar92@posteo.net> writes:
> Org mode fontification routines do not support multiple different
> variants of major mode in src blocks.
> We also cannot handle major modes prompting user when they are
> activated.
>
In case you missed it, the workaround that solved
the OP problem is:
(setq geiser-mode-auto-p nil)
Without this, htmlfontify turn on scheme-mode, and geiser then asks for
which implementation to use.
Bruno
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> 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>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Avoid "Scheme implementation" prompt on export
2024-10-20 11:36 ` Bruno Barbier
@ 2024-10-20 11:40 ` Ihor Radchenko
0 siblings, 0 replies; 15+ messages in thread
From: Ihor Radchenko @ 2024-10-20 11:40 UTC (permalink / raw)
To: Bruno Barbier; +Cc: Roi Martin, emacs-orgmode
Bruno Barbier <brubar.cs@gmail.com> writes:
> Ihor Radchenko <yantar92@posteo.net> writes:
>
>> Org mode fontification routines do not support multiple different
>> variants of major mode in src blocks.
>> We also cannot handle major modes prompting user when they are
>> activated.
>>
>
> In case you missed it, the workaround that solved
> the OP problem is:
> (setq geiser-mode-auto-p nil)
>
> Without this, htmlfontify turn on scheme-mode, and geiser then asks for
> which implementation to use.
I saw it.
I was commenting on the possibility for Org mode to solve this type of
problems in some general way.
--
Ihor Radchenko // yantar92,
Org mode contributor,
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>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Avoid "Scheme implementation" prompt on export
@ 2024-10-15 14:30 Roi Martin
2024-10-15 17:08 ` Bruno Barbier
0 siblings, 1 reply; 15+ messages in thread
From: Roi Martin @ 2024-10-15 14:30 UTC (permalink / raw)
To: Bruno Barbier, emacs-orgmode
Bruno Barbier <brubar.cs@gmail.com> writes:
> I've installed chez and racket. Indeed, the argument :session
> if half-ignored.
>
> I've attached a quick ugly hack; with that change, it is now working
> for me.
>
> #+begin_src scheme :scheme racket
> (banner)
> #+end_src
>
> #+RESULTS:
> : Welcome to Racket v8.14 [cs].\n
>
> (setq-default geiser-chez-binary "chezscheme")
> #+begin_src scheme :scheme chez
> (scheme-version)
> #+end_src
>
> #+RESULTS:
> : Chez Scheme Version 10.0.0
>
> Could you try it?
I tried the current main branch (commit da0f6eff75cd ("ox-texinfo: Fix
edge case with - Variable: nil:: definition") with and without the
patch. Unless I'm doing something wrong, exporting the document to HTML
with "C-c C-e h H" asks for the Scheme implementation for every code
block. Please, note that the htmlize package must be installed.
Also, note that executing the code block with "C-c C-c" never asked for
the Scheme implementation when the ":scheme" argument is specified.
Cheers,
Roi
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Avoid "Scheme implementation" prompt on export
2024-10-15 14:30 Roi Martin
@ 2024-10-15 17:08 ` Bruno Barbier
2024-10-15 20:56 ` Roi Martin
0 siblings, 1 reply; 15+ messages in thread
From: Bruno Barbier @ 2024-10-15 17:08 UTC (permalink / raw)
To: Roi Martin, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1586 bytes --]
Roi Martin <jroi.martin@gmail.com> writes:
> I tried the current main branch (commit da0f6eff75cd ("ox-texinfo: Fix
> edge case with - Variable: nil:: definition") with and without the
> patch. Unless I'm doing something wrong, exporting the document to HTML
> with "C-c C-e h H" asks for the Scheme implementation for every code
> block. Please, note that the htmlize package must be installed.
>
> Also, note that executing the code block with "C-c C-c" never asked for
> the Scheme implementation when the ":scheme" argument is specified.
My patch fixes a real bug though. Are you sure org is using the correct
scheme implementation when doing "C-c C-c" ?
I just checked exporting my example to html: it works for me.
I've tested using the same version as you:
Org mode commit: da0f6eff75cd
with my patch applied on top, and using a clean bare bone emacs,
without any config.
I'm launching emacs like this:
emacs -q test_ob-scheme-bug.org
Running the elisp code block, I'm getting the expected result in HTML.
In the HTML file, I see:
#+begin_example
<pre class="example">
Welcome to Racket v8.14 [cs].\n
</pre>
#+end_example
and:
#+begin_example
<pre class="example">
Chez Scheme Version 10.0.0
</pre>
#+end_example
I've attached the org file that I've used to test this. The first elisp
block allows to configure Emacs from scratch (downloading and installing
the required packages), export the org file to HTML and open the HTML
result.
Maybe something is wrong in your configuration ?
Bruno
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: test_ob-scheme-bug.org --]
[-- Type: text/org, Size: 849 bytes --]
* Mandatory first heading
:PROPERTIES:
:header-args:scheme: :exports both :results value
:END:
#+begin_src elisp
(setq-local org-confirm-babel-evaluate nil)
(setq package-archives
'(("gnu" . "http://elpa.gnu.org/packages/")
("melpa-stable" . "http://stable.melpa.org/packages/")))
(setq package-check-signature t) ; 'allow-unsigned)
(setq package-unsigned-archives (list "melpa-stable"))
(package-initialize)
(load-library "ob-scheme")
(package-install 'geiser)
(package-install 'geiser-chez)
(package-install 'geiser-racket)
(setq-default geiser-chez-binary "chezscheme")
(org-export-to-file 'html "test.html")
(find-file "test.html")
#+end_src
#+begin_src scheme :scheme racket
(banner)
#+end_src
#+begin_src scheme :scheme chez
(scheme-version)
#+end_src
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Avoid "Scheme implementation" prompt on export
2024-10-15 17:08 ` Bruno Barbier
@ 2024-10-15 20:56 ` Roi Martin
2024-10-16 9:41 ` Bruno Barbier
0 siblings, 1 reply; 15+ messages in thread
From: Roi Martin @ 2024-10-15 20:56 UTC (permalink / raw)
To: Bruno Barbier, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1656 bytes --]
Bruno Barbier <brubar.cs@gmail.com> writes:
> My patch fixes a real bug though. Are you sure org is using the correct
> scheme implementation when doing "C-c C-c" ?
I think it works fine if you set the `org-babel-load-languages' variable
in the elisp code block:
(org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t)
(scheme . t)))
> I just checked exporting my example to html: it works for me.
Have you tried with the htmlize package installed?
(package-install 'htmlize)
> I'm launching emacs like this:
>
> emacs -q test_ob-scheme-bug.org
>
> Maybe something is wrong in your configuration ?
I did my last tests launching emacs like this:
emacs -Q --init-directory=initdir -L ~/src/org-mode/lisp test_ob-scheme-bug.org
I also simplified the elisp code block a bit:
#+begin_src elisp
(setq package-archives
'(("gnu" . "https://elpa.gnu.org/packages/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")))
(setq package-check-signature t)
(package-initialize)
(package-install 'geiser)
(package-install 'geiser-chez)
(package-install 'geiser-racket)
(package-install 'htmlize)
(setq-local org-confirm-babel-evaluate nil)
(org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t)
(scheme . t)))
(org-export-to-file 'html "test.html")
#+end_src
I attached my test file. I hope it helps.
Best,
Roi
[-- Attachment #2: test_ob-scheme-bug.org --]
[-- Type: text/plain, Size: 744 bytes --]
* Mandatory first heading
:PROPERTIES:
:header-args:scheme: :exports both :results value
:END:
#+begin_src elisp
(setq package-archives
'(("gnu" . "https://elpa.gnu.org/packages/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")))
(setq package-check-signature t)
(package-initialize)
(package-install 'geiser)
(package-install 'geiser-chez)
(package-install 'geiser-racket)
(package-install 'htmlize)
(setq-local org-confirm-babel-evaluate nil)
(org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t)
(scheme . t)))
(org-export-to-file 'html "test.html")
#+end_src
#+begin_src scheme :scheme racket
(banner)
#+end_src
#+begin_src scheme :scheme chez
(scheme-version)
#+end_src
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Avoid "Scheme implementation" prompt on export
2024-10-15 20:56 ` Roi Martin
@ 2024-10-16 9:41 ` Bruno Barbier
2024-10-16 13:01 ` Roi Martin
0 siblings, 1 reply; 15+ messages in thread
From: Bruno Barbier @ 2024-10-16 9:41 UTC (permalink / raw)
To: Roi Martin, emacs-orgmode
Roi Martin <jroi.martin@gmail.com> writes:
> Bruno Barbier <brubar.cs@gmail.com> writes:
>
>> My patch fixes a real bug though. Are you sure org is using the correct
>> scheme implementation when doing "C-c C-c" ?
> I think it works fine if you set the `org-babel-load-languages' variable
> in the elisp code block:
>
> (org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t)
> (scheme . t)))
>
ok. I simplified:
(load-library "ob-scheme")
into:
(org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t)
(scheme . t))
:)
>> I just checked exporting my example to html: it works for me.
>
> Have you tried with the htmlize package installed?
>
> (package-install 'htmlize)
>
Nope. Everything was included in my minimal reproducible example and
htmlize was not there. And I didn't use the GNU nongnu repo either.
Using htmlize *AND* the nongnu version, I'm indeed able to reproduce.
The HTML fontification is launching REPLs, and *may* prompts
for the implementation to use. I'm able to work around this with this
setting:
(setq geiser-mode-auto-p nil)
I'm not sure what the real solution should be though.
And thanks for your test file! (probably impossible to spot the melpa vs
nongnu difference without it).
Bruno
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Avoid "Scheme implementation" prompt on export
2024-10-16 9:41 ` Bruno Barbier
@ 2024-10-16 13:01 ` Roi Martin
2024-10-19 13:42 ` Ihor Radchenko
0 siblings, 1 reply; 15+ messages in thread
From: Roi Martin @ 2024-10-16 13:01 UTC (permalink / raw)
To: Bruno Barbier, emacs-orgmode
Bruno Barbier <brubar.cs@gmail.com> writes:
> The HTML fontification is launching REPLs, and *may* prompts
> for the implementation to use. I'm able to work around this with this
> setting:
>
> (setq geiser-mode-auto-p nil)
>
> I'm not sure what the real solution should be though.
Thanks a lot for the workaround! It works like a charm.
After pinpointing the issue to having htmlize installed, I've been
digging a bit and it seems that the `org-html-fontify-code' function in
`ox-html` triggers the prompt. It creates a temporary buffer with the
code and enables the corresponding language mode:
...
(with-temp-buffer
;; Switch to language-specific mode.
(funcall lang-mode)
(insert code)
...
So, it makes sense to set `geiser-mode-auto-p' to nil in order to avoid
being prompted for the specific Scheme implementation.
Maybe, we could have an alist that associates a language to some kind of
"setup" function. For instance, in the case of Scheme, it would read
the `:scheme' argument and set the geiser implementation. However, I'm
not sure if it is worth it. Also, I'm not familiar with the code base
of org-mode, so bear with me. Probably, what I'm proposing does not make
sense or is not the optimal solution.
What do you think?
In any case, thanks a lot for your help!
Best,
Roi
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Avoid "Scheme implementation" prompt on export
2024-10-16 13:01 ` Roi Martin
@ 2024-10-19 13:42 ` Ihor Radchenko
0 siblings, 0 replies; 15+ messages in thread
From: Ihor Radchenko @ 2024-10-19 13:42 UTC (permalink / raw)
To: Roi Martin; +Cc: Bruno Barbier, emacs-orgmode
Roi Martin <jroi.martin@gmail.com> writes:
> Maybe, we could have an alist that associates a language to some kind of
> "setup" function. For instance, in the case of Scheme, it would read
> the `:scheme' argument and set the geiser implementation. However, I'm
> not sure if it is worth it. Also, I'm not familiar with the code base
> of org-mode, so bear with me. Probably, what I'm proposing does not make
> sense or is not the optimal solution.
>
> What do you think?
The problem is deeper.
Org mode does not even always call a given major mode for each src
block. For the purposes of fontification, a single major mode buffer may
be created and then reused to fontify src blocks with the same language.
If you want some kind of "setup" function, it is what scheme-mode-hook
(or <major-mode>-hook) is for.
--
Ihor Radchenko // yantar92,
Org mode contributor,
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>
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2024-10-20 11:39 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-14 10:17 Avoid "Scheme implementation" prompt on export Roi Martin
2024-10-14 17:45 ` Bruno Barbier
[not found] ` <87bjzma6ml.fsf@gmail.com>
2024-10-14 19:52 ` Roi Martin
2024-10-15 10:50 ` Bruno Barbier
2024-10-19 13:36 ` Ihor Radchenko
2024-10-20 11:22 ` Bruno Barbier
2024-10-19 13:32 ` Ihor Radchenko
2024-10-20 11:36 ` Bruno Barbier
2024-10-20 11:40 ` Ihor Radchenko
-- strict thread matches above, loose matches on Subject: below --
2024-10-15 14:30 Roi Martin
2024-10-15 17:08 ` Bruno Barbier
2024-10-15 20:56 ` Roi Martin
2024-10-16 9:41 ` Bruno Barbier
2024-10-16 13:01 ` Roi Martin
2024-10-19 13:42 ` Ihor Radchenko
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).