From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] ob-core: Fix indented cached result returning nil Date: Thu, 21 May 2015 00:19:33 +0200 Message-ID: <87egma7uyy.fsf@selenimh.access.network> References: <1432135367-37309-1-git-send-email-bjarte.johansen@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35334) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvCJW-0005hg-LD for emacs-orgmode@gnu.org; Wed, 20 May 2015 18:18:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YvCJV-0007BR-KT for emacs-orgmode@gnu.org; Wed, 20 May 2015 18:18:10 -0400 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:32858) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvCJV-0007B1-Dd for emacs-orgmode@gnu.org; Wed, 20 May 2015 18:18:09 -0400 In-Reply-To: <1432135367-37309-1-git-send-email-bjarte.johansen@gmail.com> (Bjarte Johansen's message of "Wed, 20 May 2015 17:22:47 +0200") 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: Bjarte Johansen Cc: emacs-orgmode@gnu.org Hello, Bjarte Johansen writes: > Fix a problem where a source block would return nil if the result was > cached and it was indented. Thank you. Some comments follow. > * 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. You need to add TINYCHANGE at the end of the commit message if you haven't signed FSF papers yet. > - (end-of-line 1) (forward-char 1) > + (end-of-line 1) (forward-char (1+ (current-indentation))) Slightly better: (forward-line) (forward-char (current-indentation)) > +(ert-deftest test-org-babel/indented-cached-org-bracket-link () > + "When the result of a source block is indentend, a link and ^^^^^^^^ "a cached indented link" > +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)))))) You should use `org-test-with-temp-text' instead, and avoid "sh" as it might not be active. OTOH, emacs-lisp is always available: --8<---------------cut here---------------start------------->8--- (should (org-test-with-temp-text "* Test #+BEGIN_SRC emacs-lisp :file test.txt :cache yes (message \"text\") #+END_SRC #+RESULTS[c9828cf13461ca9ccb31e76ba4aee02ec6d7a4e7]: [[file:test.txt]]" (string= (concat default-directory "test.txt") (org-babel-execute-src-block)))) --8<---------------cut here---------------end--------------->8--- Regards, -- Nicolas Goaziou