emacs-orgmode
[Top][All Lists]
Advanced

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

bug#52545: 29.0.50; Make org-babel-execute-buffer ignore irrelevant src


From: Berry, Charles
Subject: bug#52545: 29.0.50; Make org-babel-execute-buffer ignore irrelevant src blocks
Date: Sat, 18 Dec 2021 19:57:03 +0000


> On Dec 18, 2021, at 1:49 AM, Ihor Radchenko <yantar92@gmail.com> wrote:
> 
> "Berry, Charles" <ccberry@health.ucsd.edu> writes:
> 
>> If I have a typo in the name of a language, the error message you quote 
>> tells me what my mistake was. 
>> 
>> I'd say that is a feature, not a bug.
> 
> Agree. However, some languages simply do not define babel execute
> function. The error is same regardless whether a language backend is not
> available/not loaded or the backend is loaded, but does not provide
> babel execute function.
> 
> Maybe we can provide a custom list of languages where we do not throw
> the error? If a language is in the list and there is no babel execute
> function, we can simply ignore the source block. If a language is in the
> list, but there is babel execute function, we throw another error.
> 
> Though I am not a big fan of introducing yet another customisation.
> Maybe someone has better ideas?
> 

I believe there is a feeling that org-babel is already so complicated that 
adding features should be avoided. 

There are workable approaches under the current setup. 

---

For one, you can define lang specific header-args, so just define :eval no for 
the lang's that you want to use, but that do not have org-babel-execute:<lang> 
defined: 

#+property: header-args:nada :eval no
#+property: header-args :exports both :eval yes

The code here will be rendered, but the block will not execute:

#+begin_src nada
  "haha"
#+end_src

---

Another is to use a custom :eval arg like this:

#+property: header-args :eval (my-eval-p) :exports both

#+begin_src not_defined
  "haha"
#+end_src

Where `my-eval-p' is defined as:

#+begin_src emacs-lisp
  (defun my-eval-p ()
    (let ((lang (car (org-babel-get-src-block-info 'light))))
      (if (fboundp (intern (concat "org-babel-execute:" lang)))
          "yes"
        "no")))
#+end_src

Obviously, you can elaborate `my-eval-p' to satisfy individual needs.

Best,
Chuck







reply via email to

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