Browse Source

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.
Bastien 5 years ago
parent
commit
cad2a6a588
1 changed files with 3 additions and 2 deletions
  1. 3 2
      lisp/org-src.el

+ 3 - 2
lisp/org-src.el

@@ -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