summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ecay <aaronecay@gmail.com>2016-09-01 16:57:57 +0100
committerAaron Ecay <aaronecay@gmail.com>2016-09-01 16:57:57 +0100
commit890ed78c0d689c6f46b7943e577dff2d9b1763b2 (patch)
tree05477d6ed7530a4c89c018469bef1d32d9dfa425
parent38de6b6ed432fdd086bbdf856bd19eb0f608e48e (diff)
downloadorg-mode-890ed78c0d689c6f46b7943e577dff2d9b1763b2.tar.gz
babel: replace org-babel-*-read-string functions with single version.
* lisp/ob-core.el (org-babel-strip-quotes): New function. * lisp/ob-haskell.el (org-babel-haskell-read-string): Remove. (org-babel-execute:haskell): Use new function. * lisp/ob-octave.el (org-babel-octave-read-string): Remove. (org-babel-octave-evaluate-session): Use new function. * lisp/ob-ruby.el (org-babel-ruby-read-string): Remove.
-rw-r--r--lisp/ob-core.el7
-rw-r--r--lisp/ob-haskell.el8
-rw-r--r--lisp/ob-octave.el10
-rw-r--r--lisp/ob-ruby.el6
4 files changed, 10 insertions, 21 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index eb6e0c4..857c4ca 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -3083,6 +3083,13 @@ Callers of this function will probably want to add an entry to
(when (and sym (boundp sym))
(defvaralias (intern (concat "org-babel-" var ":" new)) sym)))))
+(defun org-babel-strip-quotes (string)
+ "Strip \\\"s from around a string, if applicable."
+ (if (and (string-prefix-p "\"" string)
+ (string-suffix-p "\"" string))
+ (substring string 1 -1)
+ string))
+
(provide 'ob-core)
;; Local variables:
diff --git a/lisp/ob-haskell.el b/lisp/ob-haskell.el
index d76244f..4263ffd 100644
--- a/lisp/ob-haskell.el
+++ b/lisp/ob-haskell.el
@@ -74,7 +74,7 @@
(insert org-babel-haskell-eoe)
(comint-send-input nil t)))
(results (mapcar
- #'org-babel-haskell-read-string
+ #'org-babel-strip-quotes
(cdr (member org-babel-haskell-eoe
(reverse (mapcar #'org-trim raw)))))))
(org-babel-reassemble-table
@@ -89,12 +89,6 @@
(org-babel-pick-name (cdr (assoc :rowname-names params))
(cdr (assoc :rowname-names params))))))
-(defun org-babel-haskell-read-string (string)
- "Strip \\\"s from around a haskell string."
- (if (string-match "^\"\\([^\000]+\\)\"$" string)
- (match-string 1 string)
- string))
-
(defun org-babel-haskell-initiate-session (&optional _session _params)
"Initiate a haskell session.
If there is not a current inferior-process-buffer in SESSION
diff --git a/lisp/ob-octave.el b/lisp/ob-octave.el
index 4a0b324..420f723 100644
--- a/lisp/ob-octave.el
+++ b/lisp/ob-octave.el
@@ -238,11 +238,11 @@ value of the last statement in BODY, as elisp."
(setq results
(if matlabp
(cdr (reverse (delq "" (mapcar
- #'org-babel-octave-read-string
+ #'org-babel-strip-quotes
(mapcar #'org-trim raw)))))
(cdr (member org-babel-octave-eoe-output
(reverse (mapcar
- #'org-babel-octave-read-string
+ #'org-babel-strip-quotes
(mapcar #'org-trim raw)))))))
(mapconcat #'identity (reverse results) "\n")))))
@@ -259,12 +259,6 @@ This removes initial blank and comment lines and then calls
(delete-region beg end)))
(org-babel-import-elisp-from-file temp-file '(16))))
-(defun org-babel-octave-read-string (string)
- "Strip \\\"s from around octave string."
- (if (string-match "^\"\\([^\000]+\\)\"$" string)
- (match-string 1 string)
- string))
-
(provide 'ob-octave)
diff --git a/lisp/ob-ruby.el b/lisp/ob-ruby.el
index 6d5c682..19b7774 100644
--- a/lisp/ob-ruby.el
+++ b/lisp/ob-ruby.el
@@ -254,12 +254,6 @@ return the value of the last statement in BODY, as elisp."
(comint-send-input nil t))
(org-babel-eval-read-file tmp-file))))))
-(defun org-babel-ruby-read-string (string)
- "Strip \\\"s from around a ruby string."
- (if (string-match "^\"\\([^\000]+\\)\"$" string)
- (match-string 1 string)
- string))
-
(provide 'ob-ruby)