emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Loris Bennett" <loris.bennett@fu-berlin.de>
To: Org Mode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: Conditionally loading ob-sh or ob-shell
Date: Tue, 21 Apr 2020 15:58:44 +0200	[thread overview]
Message-ID: <87wo690wkr.fsf@hornfels.zedat.fu-berlin.de> (raw)
In-Reply-To: <87tv1d2p19.fsf@hornfels.zedat.fu-berlin.de> (Loris Bennett's message of "Tue, 21 Apr 2020 10:58:42 +0200")

Loris Bennett <loris.bennett@fu-berlin.de> 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.


  reply	other threads:[~2020-04-21 13:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21  8:58 Conditionally loading ob-sh or ob-shell Loris Bennett
2020-04-21 13:58 ` Loris Bennett [this message]
2020-04-21 16:42   ` Steve Downey
2020-04-22  6:09     ` Loris Bennett

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wo690wkr.fsf@hornfels.zedat.fu-berlin.de \
    --to=loris.bennett@fu-berlin.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).