Browse Source

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.
Nicolas Goaziou 7 years ago
parent
commit
823c821bc8
2 changed files with 15 additions and 14 deletions
  1. 10 14
      lisp/ob-core.el
  2. 5 0
      lisp/org-compat.el

+ 10 - 14
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.

+ 5 - 0
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