From c21692506d8742523e0f8d558e97699be3a15dd0 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 15 Nov 2011 11:18:26 -0700 Subject: [PATCH] fix bug missing references to example blocks * lisp/ob-ref.el (org-babel-ref-resolve): Don't change location when looking at the contents. * testing/lisp/test-ob.el (test-ob/catches-all-references): Test enforcing the correct behavior. --- lisp/ob-ref.el | 7 ++++--- testing/lisp/test-ob.el | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lisp/ob-ref.el b/lisp/ob-ref.el index 9534aac9f..b7988eeb4 100644 --- a/lisp/ob-ref.el +++ b/lisp/ob-ref.el @@ -174,9 +174,10 @@ the variable." (lob-info (setq type 'lob)) (id (setq type 'id)) ((and (looking-at org-babel-src-name-regexp) - (progn (forward-line 1) - (or (looking-at org-babel-src-block-regexp) - (looking-at org-babel-multi-line-header-regexp)))) + (save-excursion + (forward-line 1) + (or (looking-at org-babel-src-block-regexp) + (looking-at org-babel-multi-line-header-regexp)))) (setq type 'source-block)) (t (while (not (setq type (org-babel-ref-at-ref-p))) (forward-line 1) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index ef854cb83..ceaafb347 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -431,6 +431,22 @@ duplicate results block." (org-babel-next-src-block 1) (should (looking-at org-babel-src-block-regexp)))) +(ert-deftest test-ob/catches-all-references () + (org-test-with-temp-text " +#+NAME: literal-example +#+BEGIN_EXAMPLE +A literal example +on two lines +#+END_EXAMPLE + +#+NAME: read-literal-example +#+BEGIN_SRC emacs-lisp :var x=literal-example + (concatenate 'string x \" for me.\") +#+END_SRC" + (org-babel-next-src-block 1) + (should (string= (org-babel-execute-src-block) + "A literal example\non two lines for me.")))) + (provide 'test-ob) ;;; test-ob ends here