summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-05-01 15:33:09 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-05-01 15:33:09 +0200
commit823c821bc8ec11988440fdfa3ab48fdfa1955f26 (patch)
tree038a9a71d64ca279302268b485f0bb05c38e5ca5
parent3502e6fa7cb304d6b29aef032fe49ea4a79b58f0 (diff)
downloadorg-mode-823c821bc8ec11988440fdfa3ab48fdfa1955f26.tar.gz
ob-core: Small refactoring
* lisp/ob-core.el (org-babel-read): Small refactoring. (org-babel--string-to-number): Use `string-match-p' instead of `string-match'. * lisp/org-compat.el (org-babel-number-p): Move obsolete alias.
-rw-r--r--lisp/ob-core.el24
-rw-r--r--lisp/org-compat.el5
2 files changed, 15 insertions, 14 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 1e13aa5..03a187e 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2849,24 +2849,20 @@ Otherwise if CELL looks like lisp (meaning it starts with a
lisp, otherwise return it unmodified as a string. Optional
argument INHIBIT-LISP-EVAL inhibits lisp evaluation for
situations in which is it not appropriate."
- (if (and (stringp cell) (not (equal cell "")))
- (or (org-babel--string-to-number cell)
- (if (and (not inhibit-lisp-eval)
- (or (member (substring cell 0 1) '("(" "'" "`" "["))
- (string= cell "*this*")))
- (eval (read cell) t)
- (if (string= (substring cell 0 1) "\"")
- (read cell)
- (progn (set-text-properties 0 (length cell) nil cell) cell))))
- cell))
+ (cond ((not (org-string-nw-p cell)) cell)
+ ((org-babel--string-to-number cell))
+ ((and (not inhibit-lisp-eval)
+ (or (memq (string-to-char cell) '(?\( ?' ?` ?\[))
+ (string= cell "*this*")))
+ (eval (read cell) t))
+ ((eq (string-to-char cell) ?\") (read cell))
+ (t (org-no-properties cell))))
(defun org-babel--string-to-number (string)
"If STRING represents a number return its value.
-
Otherwise return nil."
- (when (string-match "\\`-?[0-9]*\\.?[0-9]*\\'" string)
- (string-to-number string)))
-(define-obsolete-function-alias 'org-babel-number-p 'org-babel--string-to-number "Org 9.0")
+ (and (string-match-p "\\`-?[0-9]*\\.?[0-9]*\\'" string)
+ (string-to-number string)))
(defun org-babel-import-elisp-from-file (file-name &optional separator)
"Read the results located at FILE-NAME into an elisp table.
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index f4d389e..1f2dd80 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -286,6 +286,11 @@ See `org-link-parameters' for documentation on the other parameters."
(org-unbracket-string "\"" "\"" s))
(make-obsolete 'org-remove-double-quotes 'org-unbracket-string "Org 9.0")
+(define-obsolete-function-alias 'org-babel-number-p
+ 'org-babel--string-to-number "Org 9.0")
+
+
+
;;;; Obsolete link types
(eval-after-load 'org