[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Conditionally loading ob-sh or ob-shell
From: |
Loris Bennett |
Subject: |
Re: Conditionally loading ob-sh or ob-shell |
Date: |
Tue, 21 Apr 2020 15:58:44 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Loris Bennett <address@hidden> writes:
> Hi,
>
> I want to use one init.el across multiple machines with different
> versions of Emacs and Org. Since 'ob-sh.el' changed to 'ob-shell', I
> need to do either
>
> (org-babel-do-load-languages
> 'org-babel-load-languages
> '((org . t)
> (emacs-lisp . t)
> (shell . t)
> (perl . t)
> (R . t)
> (matlab . t)
> (gnuplot . t)
> (dot . t)
> (ditaa . t)
> (plantuml . t)
> (sqlite . t)
> (python . t)
> (latex . t)))
> or
>
> (org-babel-do-load-languages
> 'org-babel-load-languages
> '((org . t)
> (emacs-lisp . t)
> (sh . t)
> (perl . t)
> (R . t)
> (matlab . t)
> (gnuplot . t)
> (dot . t)
> (ditaa . t)
> (plantuml . t)
> (sqlite . t)
> (python . t)
> (latex . t)))
>
> I can obviously use a conditional to test the Emacs or Org version and
> execute one block or the other. However, since the list of languages is
> quite long, I would like to avoid repeating it.
>
> I create init.el from an init.org, so I am open to tangling solutions too.
>
> Cheers,
>
> Loris
I discovered
append org-babel-load-languages
and solved the problem like this:
(org-babel-do-load-languages
'org-babel-load-languages
'(
(org . t)
(emacs-lisp . t)
(perl . t)
(R . t)
(matlab . t)
(gnuplot . t)
(dot . t)
(ditaa . t)
(plantuml . t)
(sqlite . t)
(python . t)
(latex . t)))
(if (string= org-version "8.2.10")
(org-babel-do-load-languages
'org-babel-load-languages
(append org-babel-load-languages
'((sh . t))))
(org-babel-do-load-languages
'org-babel-load-languages
(append org-babel-load-languages
'((shell . t)))))
The version test is a bit rigid, but
org-version-check
is deprecated in my newer, primary version of Org and I couldn't work
out how to use it anyway 😅
Cheers,
Loris
--
This signature is currently under construction.