Browse Source

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.
Eric Schulte 7 years ago
parent
commit
c21692506d
2 changed files with 20 additions and 3 deletions
  1. 4 3
      lisp/ob-ref.el
  2. 16 0
      testing/lisp/test-ob.el

+ 4 - 3
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)

+ 16 - 0
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