浏览代码

ob-core: Fix indented cached result returning nil

Fix a problem where a source block would return nil oif the result was
cached and it was indented.

* lisp/ob-core.el (org-babel-execute-src-block): Move point to the the
 first character of the result instead of the beginning of the line.

* testing/lisp/test-ob.el
 (test-org-babel/indented-cached-org-bracket-link): Added test to
 to see if the indented cached result returns what it should return.
Bjarte Johansen 10 年之前
父节点
当前提交
b6934e3471
共有 2 个文件被更改,包括 18 次插入1 次删除
  1. 2 1
      lisp/ob-core.el
  2. 16 0
      testing/lisp/test-ob.el

+ 2 - 1
lisp/ob-core.el

@@ -653,7 +653,8 @@ block."
 	 (cache-current-p
 	  (save-excursion ;; return cached result
 	    (goto-char (org-babel-where-is-src-block-result nil info))
-	    (end-of-line 1) (forward-char 1)
+	    (forward-line)
+	    (skip-chars-forward " \t")
 	    (let ((result (org-babel-read-result)))
 	      (message (replace-regexp-in-string
 			"%" "%%" (format "%S" result))) result)))

+ 16 - 0
testing/lisp/test-ob.el

@@ -20,6 +20,22 @@
 
 ;;; Code:
 
+(ert-deftest test-org-babel/indented-cached-org-bracket-link ()
+  "When the result of a source block is a cached indented link it
+should still return the link."
+  (should
+   (let ((default-directory temporary-file-directory))
+     (org-test-with-temp-text
+      "
+* Test
+  #+<point>BEGIN_SRC emacs-lisp :file test.txt :cache yes
+    (message \"test\")
+  #+END_SRC"
+      ;; Execute twice as the first time creates the cache.
+      (org-babel-execute-src-block)
+      (string= (concat default-directory "test.txt")
+	       (org-babel-execute-src-block))))))
+
 (ert-deftest test-org-babel/multi-line-header-regexp ()
   (should(equal "^[ \t]*#\\+headers?:[ \t]*\\([^\n]*\\)$"
 		org-babel-multi-line-header-regexp))