* ob-shell: possibly missing initiate-session functions?
@ 2024-06-10 2:48 Suhail Singh
2024-06-16 18:53 ` Matt
0 siblings, 1 reply; 6+ messages in thread
From: Suhail Singh @ 2024-06-10 2:48 UTC (permalink / raw)
To: Org mailing list
Currently (Org 9.7.3), org-babel-switch-to-session invokes
org-babel-initiate-session which tries to invoke
org-babel-<lang>-initiate-session. On a related note, ob-shell defines
org-babel-sh-initiate-session (and uses it within
org-babel-execute:shell).
However, there are no definitions for org-babel-shell-initiate-session
nor org-babel-bash-initiate-session etc. This means that trying to use
org-metadown (which invokes org-babel-switch-to-session) on shell and
bash language session blocks results in the following errors
respectively:
#+begin_comment
org-babel-initiate-session: No org-babel-initiate-session function for shell!
org-babel-initiate-session: No org-babel-initiate-session function for bash!
#+end_comment
Is this a bug? If so, does org-babel-shell-initialize need to be
patched to set up function aliases pointing to
org-babel-sh-initiate-session ?
FWIW, I have been using such aliases in my personal config for bash and
shell language blocks and they seem to behave as expected.
--
Suhail
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: ob-shell: possibly missing initiate-session functions?
2024-06-10 2:48 ob-shell: possibly missing initiate-session functions? Suhail Singh
@ 2024-06-16 18:53 ` Matt
2024-06-16 22:54 ` Suhail Singh
0 siblings, 1 reply; 6+ messages in thread
From: Matt @ 2024-06-16 18:53 UTC (permalink / raw)
To: Suhail Singh; +Cc: Org mailing list
---- On Mon, 10 Jun 2024 04:48:10 +0200 Suhail Singh wrote ---
> Currently (Org 9.7.3), org-babel-switch-to-session invokes
> org-babel-initiate-session which tries to invoke
> org-babel--initiate-session. On a related note, ob-shell defines
> org-babel-sh-initiate-session (and uses it within
> org-babel-execute:shell).
>
> However, there are no definitions for org-babel-shell-initiate-session
> nor org-babel-bash-initiate-session etc. This means that trying to use
> org-metadown (which invokes org-babel-switch-to-session) on shell and
> bash language session blocks results in the following errors
> respectively:
>
> #+begin_comment
> org-babel-initiate-session: No org-babel-initiate-session function for shell!
> org-babel-initiate-session: No org-babel-initiate-session function for bash!
> #+end_comment
>
> Is this a bug? If so, does org-babel-shell-initialize need to be
> patched to set up function aliases pointing to
> org-babel-sh-initiate-session ?
>
> FWIW, I have been using such aliases in my personal config for bash and
> shell language blocks and they seem to behave as expected.
Thank you for your message! Yes, I would consider this a bug.
I agree, defining an alias within "org-babel-shell-initialize" seems reasonable. However, it's important that "explicit-shell-file-name" is set to the appropriate shell name. In your case, I suspect it's a coincidence that aliasing "org-babel-sh-initiate-session" works. A "shell" block defaults to "explicit-shell-file-name". This, I suspect, is "bash" in your case, yet may be something different on another system. The alias would need to close over "explicit-shell-file-name" like is done with "org-babel-execute:name".
--
Matt Trzcinski
Emacs Org contributor (ob-shell)
Learn more about Org mode at https://orgmode.org
Support Org development at https://liberapay.com/org-mode
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: ob-shell: possibly missing initiate-session functions?
2024-06-16 18:53 ` Matt
@ 2024-06-16 22:54 ` Suhail Singh
2024-06-17 15:45 ` Ihor Radchenko
0 siblings, 1 reply; 6+ messages in thread
From: Suhail Singh @ 2024-06-16 22:54 UTC (permalink / raw)
To: Matt; +Cc: Suhail Singh, Org mailing list
Matt <matt@excalamus.com> writes:
> I agree, defining an alias within "org-babel-shell-initialize" seems
> reasonable. However, it's important that "explicit-shell-file-name"
> is set to the appropriate shell name. In your case, I suspect it's a
> coincidence that aliasing "org-babel-sh-initiate-session" works. A
> "shell" block defaults to "explicit-shell-file-name". This, I
> suspect, is "bash" in your case, yet may be something different on
> another system.
In my case, explicit-shell-file-name has the default value of nil.
However, shell-file-name (which is initialized from $SHELL) is
"/bin/bash".
> The alias would need to close over "explicit-shell-file-name" like is
> done with "org-babel-execute:name".
And what should be done in the case of org-babel-shell-initiate-session?
Should shell-file-name and explicit-shell-file-name remain unaltered
from their existing settings in that case?
I'm happy to send a patch, though it may be simpler for you to do so
yourself in case you have write-access. Please let me know.
--
Suhail
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: ob-shell: possibly missing initiate-session functions?
2024-06-16 22:54 ` Suhail Singh
@ 2024-06-17 15:45 ` Ihor Radchenko
2024-06-17 18:29 ` Suhail Singh
0 siblings, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2024-06-17 15:45 UTC (permalink / raw)
To: Suhail Singh; +Cc: Matt, Org mailing list
Suhail Singh <suhailsingh247@gmail.com> writes:
>> The alias would need to close over "explicit-shell-file-name" like is
>> done with "org-babel-execute:name".
>
> And what should be done in the case of org-babel-shell-initiate-session?
> Should shell-file-name and explicit-shell-file-name remain unaltered
> from their existing settings in that case?
Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5b366a731
--
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] 6+ messages in thread
* Re: ob-shell: possibly missing initiate-session functions?
2024-06-17 15:45 ` Ihor Radchenko
@ 2024-06-17 18:29 ` Suhail Singh
2024-06-18 12:46 ` Ihor Radchenko
0 siblings, 1 reply; 6+ messages in thread
From: Suhail Singh @ 2024-06-17 18:29 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Suhail Singh, Matt, Org mailing list
Ihor Radchenko <yantar92@posteo.net> writes:
> Fixed, on main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5b366a731
#+begin_src diff
(put fname 'definition-name 'org-babel-shell-initialize))
+ (let ((fname (intern (concat "org-babel-prep-session:" name))))
+ (defalias fname
+ (lambda (session params)
+ (:documentation
+ (format "Prepare %s SESSION according to the header arguments specified in PARAMS." name))
+ (let ((explicit-shell-file-name name)
+ (shell-file-name name))
+ (org-babel-prep-session:shell session params))))
+ (put fname 'definition-name 'org-babel-shell-initialize))
+ (let ((fname (intern (format "org-babel-%s-initiate-session" name))))
+ (defalias fname
+ (lambda (session _params)
+ (:documentation
+ (format "Initiate %s session named SESSION." name))
+ (let ((explicit-shell-file-name name)
+ (shell-file-name name))
+ (org-babel-sh-initiate-session session))))
+ (put fname 'definition-name 'org-babel-shell-initialize))
#+end_src
Am I mistaken, or does something still need to be done about
org-babel-shell-initiate-session ?
--
Suhail
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: ob-shell: possibly missing initiate-session functions?
2024-06-17 18:29 ` Suhail Singh
@ 2024-06-18 12:46 ` Ihor Radchenko
0 siblings, 0 replies; 6+ messages in thread
From: Ihor Radchenko @ 2024-06-18 12:46 UTC (permalink / raw)
To: Suhail Singh; +Cc: Matt, Org mailing list
Suhail Singh <suhailsingh247@gmail.com> writes:
> Ihor Radchenko <yantar92@posteo.net> writes:
>
>> Fixed, on main.
>> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5b366a731
> ...
> Am I mistaken, or does something still need to be done about
> org-babel-shell-initiate-session ?
True.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5e9ac146f
--
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] 6+ messages in thread
end of thread, other threads:[~2024-06-18 12:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-10 2:48 ob-shell: possibly missing initiate-session functions? Suhail Singh
2024-06-16 18:53 ` Matt
2024-06-16 22:54 ` Suhail Singh
2024-06-17 15:45 ` Ihor Radchenko
2024-06-17 18:29 ` Suhail Singh
2024-06-18 12:46 ` 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).