org-src.el: Enhance `org-edit-src-code'

* lisp/org-src.el (org-edit-src-code): Don't throw an error
when trying to find the source language in a non-interactive
call, typically when called for template expansion.

Thanks to Tyler Smith and Jack Kamm for reporting a related bug.
This commit is contained in:
Bastien 2020-02-03 13:09:34 +01:00
parent 5c72d60d44
commit cad2a6a588

View file

@ -1022,8 +1022,9 @@ name of the sub-editing buffer."
(babel-info (and (eq type 'src-block)
(org-babel-get-src-block-info 'light)))
deactivate-mark)
(when (and (eq type 'src-block) (not (functionp lang-f)))
(error "No such language mode: %s" lang-f))
(when (and (called-interactively-p 'any)
(eq type 'src-block) (not (functionp lang-f)))
(user-error "No such language mode: %s" lang-f))
(org-src--edit-element
element
(or edit-buffer-name