1

How do I programmatically extract key-value pairs from "Babel Languages" list in defcustom org-babel-load-languages section of org.el?

I want to read the "Babel Languages" configuration into an org-mode code block and return the full list of the available programming languages.

For example, I'm want to transform the input below:

(const :tag "Awk" awk)
(const :tag "C" C)
(const :tag "R" R)

into an output value like this

(("Awk") ("C") ("R"))

I included the specific defcustom section from org.el for clarification.

(defcustom org-babel-load-languages '((emacs-lisp . t))
  "Languages which can be evaluated in Org-mode buffers.
This list can be used to load support for any of the languages
below, note that each language will depend on a different set of
system executables and/or Emacs modes.  When a language is
\"loaded\", then code blocks in that language can be evaluated
with `org-babel-execute-src-block' bound by default to C-c
C-c (note the `org-babel-no-eval-on-ctrl-c-ctrl-c' variable can
be set to remove code block evaluation from the C-c C-c
keybinding.  By default only Emacs Lisp (which has no
requirements) is loaded."
  :group 'org-babel
  :set 'org-babel-do-load-languages
  :version "24.1"
  :type '(alist :tag "Babel Languages"
        :key-type
        (choice
         (const :tag "Awk" awk)
         (const :tag "C" C)
         (const :tag "R" R)
         (const :tag "Asymptote" asymptote)
         (const :tag "Calc" calc)
         (const :tag "Clojure" clojure)
         (const :tag "CSS" css)
         (const :tag "Ditaa" ditaa)
         (const :tag "Dot" dot)
         (const :tag "Emacs Lisp" emacs-lisp)
         (const :tag "Fortran" fortran)
         (const :tag "Gnuplot" gnuplot)
         (const :tag "Haskell" haskell)
         (const :tag "IO" io)
         (const :tag "Java" java)
         (const :tag "Javascript" js)
         (const :tag "LaTeX" latex)
         (const :tag "Ledger" ledger)
         (const :tag "Lilypond" lilypond)
         (const :tag "Lisp" lisp)
         (const :tag "Makefile" makefile)
         (const :tag "Maxima" maxima)
         (const :tag "Matlab" matlab)
         (const :tag "Mscgen" mscgen)
         (const :tag "Ocaml" ocaml)
         (const :tag "Octave" octave)
         (const :tag "Org" org)
         (const :tag "Perl" perl)
         (const :tag "Pico Lisp" picolisp)
         (const :tag "PlantUML" plantuml)
         (const :tag "Python" python)
         (const :tag "Ruby" ruby)
         (const :tag "Sass" sass)
         (const :tag "Scala" scala)
         (const :tag "Scheme" scheme)
         (const :tag "Screen" screen)
         (const :tag "Shell Script" sh)
         (const :tag "Shen" shen)
         (const :tag "Sql" sql)
         (const :tag "Sqlite" sqlite))
        :value-type (boolean :tag "Activate" :value t)))
2

I think that what you want is (get 'org-babel-load-languages 'custom-type). You might also want to look into what custom-declare-variable function does to find out what are the name of other properties the customized variable may have.

  • I will check these out and reply back! – Melioratus Apr 26 '15 at 15:06
  • Thanks! (get 'org-babel-load-languages 'custom-type) works great! – Melioratus Jun 1 '15 at 23:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.