summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-07-23 10:34:37 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-07-23 10:34:37 +0200
commit609c3b3c144e8f58851f7cf50adaed94a0fcdf0e (patch)
tree1635bf2176dabefa9fd5693433d558d68d764581
parentfcc2ca69572f0875441169fa125eb2b2fec5cdeb (diff)
downloadorg-mode-609c3b3c144e8f58851f7cf50adaed94a0fcdf0e.tar.gz
ob-shell: Improve `org-babel-shell-name' customization
* lisp/ob-shell.el (org-babel-shell-initialize): New function (org-babel-shell-names): Properly update execute functions whenever the variable is modified outside the Customize interface.
-rw-r--r--lisp/ob-shell.el23
1 files changed, 15 insertions, 8 deletions
diff --git a/lisp/ob-shell.el b/lisp/ob-shell.el
index 1d94862..4d24bbc 100644
--- a/lisp/ob-shell.el
+++ b/lisp/ob-shell.el
@@ -43,18 +43,25 @@
(defcustom org-babel-shell-names
'("sh" "bash" "csh" "ash" "dash" "ksh" "mksh" "posh")
- "List of names of shell supported by babel shell code blocks."
+ "List of names of shell supported by babel shell code blocks.
+Call `org-babel-shell-initialize' when modifying this variable
+outside the Customize interface."
:group 'org-babel
:type '(repeat (string :tag "Shell name: "))
:set (lambda (symbol value)
(set-default symbol value)
- (dolist (name value)
- (eval `(defun ,(intern (concat "org-babel-execute:" name))
- (body params)
- ,(format "Execute a block of %s commands with Babel." name)
- (let ((shell-file-name ,name))
- (org-babel-execute:shell body params)))
- t))))
+ (org-babel-shell-initialize)))
+
+(defun org-babel-shell-initialize ()
+ "Define execution functions associated to shell names.
+This function has to be called whenever `org-babel-shell-names'
+is modified outside the Customize interface."
+ (dolist (name org-babel-shell-names)
+ (eval `(defun ,(intern (concat "org-babel-execute:" name))
+ (body params)
+ ,(format "Execute a block of %s commands with Babel." name)
+ (let ((shell-file-name ,name))
+ (org-babel-execute:shell body params))))))
(defun org-babel-execute:shell (body params)
"Execute a block of Shell commands with Babel.