diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2020-05-13 15:13:14 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2020-05-13 15:35:56 +0200 |
commit | 89c759f3adc378530be3d83a87b62a6c1947f012 (patch) | |
tree | 6ceaca1257f5e33e525be83e15f1e0daefab0730 | |
parent | 4349402f3ff0921b4c47e1c91fc73ddadc0b4d03 (diff) | |
download | org-mode-89c759f3adc378530be3d83a87b62a6c1947f012.tar.gz |
ob: Replace angle brackets with parenthesis in Babel hashes
* lisp/ob-core.el (org-babel-hash-show-time): Remove
unnecessary :version keyword.
(org-babel-result-regexp):
(org-babel--insert-results-keyword): Remove angle brackets from time
stamp in hash.
* testing/lisp/test-ob.el (test-ob/where-is-src-block-result): Update
test.
Reported-by: stardiviner <numbchild@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2020-05/msg00198.html>
-rw-r--r-- | lisp/ob-core.el | 23 | ||||
-rw-r--r-- | testing/lisp/test-ob.el | 15 |
2 files changed, 23 insertions, 15 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 2d4ff56..489f58a 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -165,7 +165,6 @@ This string must include a \"%s\" which will be replaced by the results." "Non-nil means show the time the code block was evaluated in the result hash." :group 'org-babel :type 'boolean - :version "26.1" :package-version '(Org . "9.0") :safe #'booleanp) @@ -488,11 +487,21 @@ For the format of SAFE-LIST, see `org-babel-safe-header-args'." "Regexp matching a NAME keyword.") (defconst org-babel-result-regexp - (format "^[ \t]*#\\+%s\\(?:\\[\\(?:%s \\)?\\([[:alnum:]]+\\)\\]\\)?:[ \t]*" - org-babel-results-keyword - ;; <%Y-%m-%d %H:%M:%S> - "<\\(?:[0-9]\\{4\\}-[0-1][0-9]-[0-3][0-9] \ -[0-2][0-9]\\(?::[0-5][0-9]\\)\\{2\\}\\)>") + (rx (seq bol + (zero-or-more (any "\t ")) + "#+results" + (opt "[" + ;; Time stamp part. + (opt "(" + (= 4 digit) (= 2 "-" (= 2 digit)) + " " + (= 2 digit) (= 2 ":" (= 2 digit)) + ") ") + ;; SHA1 hash. + (group (one-or-more hex-digit)) + "]") + ":" + (zero-or-more (any "\t ")))) "Regular expression used to match result lines. If the results are associated with a hash key then the hash will be saved in match group 1.") @@ -1940,7 +1949,7 @@ the results hash, or nil. Leave point before the keyword." (cond ((not hash) nil) (org-babel-hash-show-time (format "[%s %s]" - (format-time-string "<%F %T>") + (format-time-string "(%F %T)") hash)) (t (format "[%s]" hash))) ":" diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index c02bcd1..7c44622 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -2090,34 +2090,33 @@ default-directory ;; Handle hashes with times. (should (equal - "#+RESULTS[<2014-03-04 00:41:10> bbbb]:" + "#+RESULTS[(2014-03-04 00:41:10) bbbb]:" (org-test-with-temp-text - " -<point>#+BEGIN_SRC emacs-lisp + "#+BEGIN_SRC emacs-lisp \(+ 1 1) #+END_SRC -#+RESULTS[<2012-03-29 16:40:12> aaaa]:" +#+RESULTS[(2012-03-29 16:40:12) aaaa]:" (let ((org-babel-results-keyword "RESULTS") (org-babel-hash-show-time t)) (cl-letf (((symbol-function 'format-time-string) - (lambda (&rest _) "<2014-03-04 00:41:10>"))) + (lambda (&rest _) "(2014-03-04 00:41:10)"))) (goto-char (org-babel-where-is-src-block-result nil nil "bbbb")) (org-trim (buffer-substring-no-properties (point) (point-max)))))))) (should (equal - "#+RESULTS[<2012-03-29 16:40:12> aaaa]:" + "#+RESULTS[(2012-03-29 16:40:12) aaaa]:" (org-test-with-temp-text " <point>#+BEGIN_SRC emacs-lisp \(+ 1 1) #+END_SRC -#+RESULTS[<2012-03-29 16:40:12> aaaa]:" +#+RESULTS[(2012-03-29 16:40:12) aaaa]:" (let ((org-babel-results-keyword "RESULTS") (org-babel-hash-show-time t)) (cl-letf (((symbol-function 'format-time-string) - (lambda (&rest _) "<2014-03-04 00:41:10>"))) + (lambda (&rest _) "(2014-03-04 00:41:10)"))) (goto-char (org-babel-where-is-src-block-result nil nil "aaaa")) (org-trim (buffer-substring-no-properties (point) (point-max)))))))) ;; RESULTS keyword may not be the last affiliated keyword. |