[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Two low-priority questions re: design of org-babel-do-load-languages

From: Mandar Mitra
Subject: Two low-priority questions re: design of org-babel-do-load-languages
Date: Wed, 22 Mar 2023 00:55:15 +0530

Here's the code from my version of org.el (9.5.5, inbuilt in Emacs 28.2).

(defun org-babel-do-load-languages (sym value)
  "Load the languages defined in `org-babel-load-languages'."
  (set-default sym value)
  (dolist (pair org-babel-load-languages)
    (let ((active (cdr pair)) (lang (symbol-name (car pair))))
      (if active
          (require (intern (concat "ob-" lang)))
         (intern (concat "org-babel-execute:" lang)))
         (intern (concat "org-babel-expand-body:" lang)))))))

1. Question from purely a programming student's perspective: this seems to be 
doing two things: (i) a set-default on line 3, and (ii) actually loading the 
language support libraries. If one were re-designing from scratch, without 
worrying about backward compatibility, would it be cleaner to separate the 
above into

(defun org-babel-do-load-languages () ; no arguments
  "Load the languages defined in `org-babel-load-languages'."
  (interactive) ; why not?       
  (dolist (pair org-babel-load-languages) ... ))


(defun org-babel-update-loaded-languages (value) ; value seems enough, don't 
need sym
  "Update the value of `org-babel-load-languages' and call 
  (set-default ...))

2. This question 
 asks: is there any way for org-babel to load support for languages when I 
actually try to use a code block with that language? [as opposed to customising 
org-babel-load-languages or similar]

and the accepted answer suggests the following:

(defadvice org-babel-execute-src-block (around load-language nil activate)
  "Load language if needed" ...

What would be the downside of making load-on-demand the default for all 
languages? Then people wouldn't have to customise org-babel-load-languages.

Apologies if this is not the right list for such "idle curiosity" type 
questions, and thanks for any insights!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]