mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 20:37:51 +00:00
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.
This commit is contained in:
parent
3502e6fa7c
commit
823c821bc8
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue