all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mandar Mitra <mandar.mitra@gmail.com>
To: emacs orgmode-mailinglist <emacs-orgmode@gnu.org>
Subject: Two low-priority questions re: design of org-babel-do-load-languages
Date: Wed, 22 Mar 2023 00:55:15 +0530	[thread overview]
Message-ID: <20230321192515.uvhj4vdpwrztfdkp@gmail.com> (raw)

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)))
	(fmakunbound
	 (intern (concat "org-babel-execute:" lang)))
	(fmakunbound
	 (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) ... ))

and

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


2. This question https://emacs.stackexchange.com/questions/20577/org-babel-load-all-languages-on-demand 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!

-mandar


             reply	other threads:[~2023-03-21 19:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-21 19:25 Mandar Mitra [this message]
2023-03-22 12:55 ` Two low-priority questions re: design of org-babel-do-load-languages Ihor Radchenko
2023-03-22 19:21   ` Mandar Mitra

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

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

  git send-email \
    --in-reply-to=20230321192515.uvhj4vdpwrztfdkp@gmail.com \
    --to=mandar.mitra@gmail.com \
    --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 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.