emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Conditionally loading ob-sh or ob-shell
@ 2020-04-21  8:58 Loris Bennett
  2020-04-21 13:58 ` Loris Bennett
  0 siblings, 1 reply; 4+ messages in thread
From: Loris Bennett @ 2020-04-21  8:58 UTC (permalink / raw)
  To: Org Mode Mailing List

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

-- 
This signature is currently under construction.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Conditionally loading ob-sh or ob-shell
  2020-04-21  8:58 Conditionally loading ob-sh or ob-shell Loris Bennett
@ 2020-04-21 13:58 ` Loris Bennett
  2020-04-21 16:42   ` Steve Downey
  0 siblings, 1 reply; 4+ messages in thread
From: Loris Bennett @ 2020-04-21 13:58 UTC (permalink / raw)
  To: Org Mode Mailing List

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Conditionally loading ob-sh or ob-shell
  2020-04-21 13:58 ` Loris Bennett
@ 2020-04-21 16:42   ` Steve Downey
  2020-04-22  6:09     ` Loris Bennett
  0 siblings, 1 reply; 4+ messages in thread
From: Steve Downey @ 2020-04-21 16:42 UTC (permalink / raw)
  To: Loris Bennett; +Cc: Org Mode Mailing List

[-- Attachment #1: Type: text/plain, Size: 2892 bytes --]

My workaround for dealing with different org versions on different machines:

>  (org-babel-do-load-languages
>   'org-babel-load-languages
>   `((perl       . t)
>     (ruby       . t)
>     ,(if (version< org-version "9.0")
>          '(sh         . t)
>        '(shell      . t))
>     (python     . t)
>     (emacs-lisp . t)
>     (C          . t)
>     (dot        . t)))))
>

On Tue, Apr 21, 2020 at 9:59 AM Loris Bennett <loris.bennett@fu-berlin.de>
wrote:

> 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.
>
>

[-- Attachment #2: Type: text/html, Size: 6461 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Conditionally loading ob-sh or ob-shell
  2020-04-21 16:42   ` Steve Downey
@ 2020-04-22  6:09     ` Loris Bennett
  0 siblings, 0 replies; 4+ messages in thread
From: Loris Bennett @ 2020-04-22  6:09 UTC (permalink / raw)
  To: Org Mode Mailing List

Hi Steve,

Thanks for that - much more compact.  I didn't know about the
`,-construction.

Cheers,

Loris

Steve Downey <sdowney@gmail.com> writes:

> My workaround for dealing with different org versions on different machines:
>
>   (org-babel-do-load-languages
>    'org-babel-load-languages
>    `((perl       . t)
>      (ruby       . t)
>      ,(if (version< org-version "9.0")
>           '(sh         . t)
>         '(shell      . t))
>      (python     . t)
>      (emacs-lisp . t)
>      (C          . t)
>      (dot        . t)))))
>
> On Tue, Apr 21, 2020 at 9:59 AM Loris Bennett <loris.bennett@fu-berlin.de> wrote:
>
>  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.
>
-- 
This signature is currently under construction.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-22  6:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-21  8:58 Conditionally loading ob-sh or ob-shell Loris Bennett
2020-04-21 13:58 ` Loris Bennett
2020-04-21 16:42   ` Steve Downey
2020-04-22  6:09     ` Loris Bennett

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).