all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [babel] Execute checks before trying to load Babel languages
@ 2011-02-09 13:03 Sébastien Vauban
  2011-02-09 15:29 ` Dan Davison
  0 siblings, 1 reply; 2+ messages in thread
From: Sébastien Vauban @ 2011-02-09 13:03 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi,

I am sharing my .emacs file, and this is beginning to cause problems with
people who don't have the same environment as I do. In particular with the
following:

#+begin_src emacs-lisp
          (org-babel-do-load-languages
           'org-babel-load-languages
           '(
             (C . t)
             (R . t)
             (calc . t)
             (ditaa . t)
             (dot . t)
             (emacs-lisp . t)
             (gnuplot . t)
             (haskell . nil)
             (latex . t)
             (ledger . t)
             (ocaml . nil)
             (octave . nil)
             (org . t)
             (perl . t)
             (python . t)
             (ruby . t)
             (screen . t)
             (sh . t)
             (sql . t)
             (sqlite . t)))
#+end_src

Someone got:

--8<---------------cut here---------------start------------->8---
    Debugger entered--Lisp error: (file-error "Cannot open load file" "ob-calc")
--8<---------------cut here---------------end--------------->8---

In fact, this is much more general than checking the Org-version: it addresses
as well installed packages such as

- Rterm (R and ess-mode)
- ditaa (requires =sudo aptitude install openjdk-6-jre=)
- gnuplot (requires gnuplot-mode)
- ledger (requires that =ob-ledger= is found...)
- org (requires that =ob-org= is found...)
- ruby

Do I have to check myself for such executables in a way similar to:

#+begin_src emacs-lisp
(when (find-exec "Rterm")
  ... add R language ...
  )

(when (file-exists-p "ob-ledger")
  ... add ledger language ...
  )
#+end_src

or could we come up with some more generic and compact solution that would
easily be usable by all of us?

Maybe such a check should be made, by default, in every language file?

Best regards,
  Seb

-- 
Sébastien Vauban


_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: [babel] Execute checks before trying to load Babel languages
  2011-02-09 13:03 [babel] Execute checks before trying to load Babel languages Sébastien Vauban
@ 2011-02-09 15:29 ` Dan Davison
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Davison @ 2011-02-09 15:29 UTC (permalink / raw)
  To: Sébastien Vauban; +Cc: emacs org-mode mailing list

Hey Seb,

> I am sharing my .emacs file, and this is beginning to cause problems with
> people who don't have the same environment as I do. In particular with the
> following:
>
> #+begin_src emacs-lisp
>           (org-babel-do-load-languages
>            'org-babel-load-languages
>            '(
>              (C . t)
>              (R . t)
>              (calc . t)
>              (ditaa . t)
[...]
>              (sqlite . t)))
> #+end_src
>

A couple of ideas:

1. I use this, which loads all languages supported in the current
   version of Org. dan/org-babel-list-supported-languages is a personal
   function, code below.

#+begin_src emacs-lisp
(setq org-babel-load-languages
      (mapcar (lambda (lang) (cons lang t))
              (dan/org-babel-list-supported-languages)))
(org-babel-do-load-languages
 'org-babel-load-languages org-babel-load-languages)
#+end_src

[...]

> In fact, this is much more general than checking the Org-version: it addresses
> as well installed packages such as
>
> - Rterm (R and ess-mode)
> - ditaa (requires =sudo aptitude install openjdk-6-jre=)
> - gnuplot (requires gnuplot-mode)

I don't think any of these are required in order to load the
language. They should only be required when executing a block (and in
the case of 'ess, when :session is used)

> - ledger (requires that =ob-ledger= is found...)
> - org (requires that =ob-org= is found...)

2. Seeing as you're sharing config files, maybe the solution is to
   accept that some bits of the configuration are by their nature
   specific to a paticular user and not robust across different
   installations. So in your main shared config file you could make a
   conservative decision to activate only emacs-lisp, or a set of core
   languages that you are confident will be present on your colleagues'
   systems. Then in addition you would have your own personal config
   file that gets loaded after the shared config, which activates your
   own languages.

Dan

#+begin_src emacs-lisp
(require 'cl)
(defun dan/org-babel-list-supported-languages ()
  (interactive)
  (sort
   (set-difference
    (mapcar
     (lambda (s) (intern (progn (string-match "^ob-\\(.+\\)\.el$" s)
                                (match-string 1 s))))
     (directory-files
      (save-window-excursion
        (file-name-directory
         (buffer-file-name (find-library "ob"))))
      nil "^ob-.+\.el$"))
    '(comint eval exp keys lob ref table tangle))
   (lambda (x y) (string< (downcase (symbol-name x))
                          (downcase (symbol-name y))))))
#+end_src


> - ruby



>
> Do I have to check myself for such executables in a way similar to:
>
> #+begin_src emacs-lisp
> (when (find-exec "Rterm")
>   ... add R language ...
>   )
>
> (when (file-exists-p "ob-ledger")
>   ... add ledger language ...
>   )
> #+end_src
>
> or could we come up with some more generic and compact solution that would
> easily be usable by all of us?
>
> Maybe such a check should be made, by default, in every language file?
>
> Best regards,
>   Seb

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

end of thread, other threads:[~2011-02-09 15:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-09 13:03 [babel] Execute checks before trying to load Babel languages Sébastien Vauban
2011-02-09 15:29 ` Dan Davison

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.