From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bjarte Johansen Subject: [PATCH] ob-core: Fix indented cached result returning nil Date: Wed, 20 May 2015 17:22:47 +0200 Message-ID: <1432135367-37309-1-git-send-email-bjarte.johansen@gmail.com> References: Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yv5pu-0000rG-SL for emacs-orgmode@gnu.org; Wed, 20 May 2015 11:23:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yv5pp-0005hD-MY for emacs-orgmode@gnu.org; Wed, 20 May 2015 11:23:10 -0400 Received: from mail-la0-x233.google.com ([2a00:1450:4010:c03::233]:34032) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yv5pp-0005ft-EC for emacs-orgmode@gnu.org; Wed, 20 May 2015 11:23:05 -0400 Received: by laat2 with SMTP id t2so78936781laa.1 for ; Wed, 20 May 2015 08:23:04 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: Bjarte Johansen Fix a problem where a source block would return nil if 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 | 2 +- testing/lisp/test-ob.el | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 91bbde4..e7e029d 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -652,7 +652,7 @@ 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..ae61b0c 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -20,6 +20,23 @@ ;;; Code: +(ert-deftest test-org-babel/indented-cached-org-bracket-link () + "When the result of a source block is indentend, a link and +cached it should still return the link." + (let ((test-block (concat "* Test\n" + " #+BEGIN_SRC sh :file test.txt :cache yes\n" + " echo 'text'\n" + " #+END_SRC\n" + "\n" + " #+RESULTS[be4fa2f5922220a6bc5b6c1f2a6747a067404506]:\n" + " [[file:test.txt]]"))) + (with-temp-buffer + (insert test-block) + (search-backward "BEGIN_SRC") + (org-mode) + (should (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)