emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH] ob-core: Fix indented cached result returning nil


From: Bjarte Johansen
Subject: [O] [PATCH] ob-core: Fix indented cached result returning nil
Date: Thu, 21 May 2015 12:38:06 +0200

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.
---
 lisp/ob-core.el         |  3 ++-
 testing/lisp/test-ob.el | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 91bbde4..1f21685 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -652,7 +652,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)
+           (end-of-line 1)
+           (forward-char (1+ (current-indentation)))
            (let ((result (org-babel-read-result)))
              (message (replace-regexp-in-string
                        "%" "%%" (format "%S" result))) result)))
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index f52ff24..55b45ad 100644
--- a/testing/lisp/test-ob.el
+++ b/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
+   (org-test-with-temp-text
+    "
+* Test
+  #+<point>BEGIN_SRC emacs-lisp :file test.txt :cache yes
+    (message \"test\")
+  #+END_SRC
+
+  #+RESULTS[f82e11feb0f46907bc5a256a27e9dd81a3876d14]:
+  [[file:test.txt]]"
+    (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))
-- 
2.3.2 (Apple Git-55)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]