emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shouldn't ob-shell's org-babel-expand-src-block prepend the :shebang


From: Vladimir Nikishkin
Subject: Re: Shouldn't ob-shell's org-babel-expand-src-block prepend the :shebang value?
Date: Thu, 10 Sep 2020 14:52:47 +0800

So, my point is the following. A shebang is an almost universally
accepted way to specify which interpreter should be used for code
evaluation.

In the ob-core.el, at line 787, the function called
org-babel-expand-src-block makes a buffer out of the noweb-expanded
code.
(I am working with org 20200907)

The sexp is looking like this:

(org-edit-src-code
     expanded (concat "*Org-Babel Preview " (buffer-name) "[ " lang " ]*"))

I suggest replacing this sexp with

(org-edit-src-code
     (seq-concatenate 'string (or (alist-get :shebang params) "") "\n"
expanded) (concat "*Org-Babel Preview " (buffer-name) "[ " lang "
]*"))

This way the expanded buffer would respect the shebang, and the
resulting buffer would be saveable as a runnable file.

I suspect that the second branch of the (if) should be left as it is,
because non-interactive usage probably means that the code will be
used later as a part of something, and therefore does not need a
shebang.

Vlad

On Sat, 5 Sep 2020 at 15:13, Bastien <bzg@gnu.org> wrote:
>
> Vladimir Nikishkin <lockywolf@gmail.com> writes:
>
> > I'll try to do one this week, but I can't submit a patch officially
> > because of my employer being staunchly against signing the copyright
> > disclaimer.
>
> :/
>
> So please just give directions on what to modify and how, and that'd
> be enough for someone (probably me) to get started.
>
> Thanks!
>
> --
>  Bastien



-- 
Yours sincerely, Vladimir Nikishkin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]