Bläddra i källkod

named code blocks are replaced with their results

* lisp/ob.el (org-babel-find-named-result): Downcase "name" before comparison.
* testing/lisp/test-ob.el (test-ob/does-not-replace-a-block-with-the-results):
  Test that named code blocks are replaced with their results.
Eric Schulte 14 år sedan
förälder
incheckning
83dfaa5c8f
2 ändrade filer med 12 tillägg och 1 borttagningar
  1. 1 1
      lisp/ob.el
  2. 11 0
      testing/lisp/test-ob.el

+ 1 - 1
lisp/ob.el

@@ -1409,7 +1409,7 @@ buffer or nil if no such result exists."
       (when (re-search-forward
 	     (concat org-babel-result-regexp
 		     "[ \t]" (regexp-quote name) "[ \t\n\f\v\r]") nil t)
-	(when (and (string= "name" (match-string 1))
+	(when (and (string= "name" (downcase (match-string 1)))
 		   (or (looking-at org-babel-src-block-regexp)
 		       (looking-at org-babel-multi-line-header-regexp)))
 	  (throw 'is-a-code-block (org-babel-find-named-result name (point))))

+ 11 - 0
testing/lisp/test-ob.el

@@ -420,6 +420,17 @@ duplicate results block."
 #+end_src"
     (should (string= "#+begin_src emacs-lisp" (org-babel-execute-src-block)))))
 
+(ert-deftest test-ob/does-not-replace-a-block-with-the-results ()
+  (org-test-with-temp-text "#+NAME: foo
+#+BEGIN_SRC emacs-lisp
+ 'foo
+#+END_SRC\n"
+    (org-babel-next-src-block 1)
+    (should (eq 'foo (org-babel-execute-src-block)))
+    (goto-char (point-min))
+    (org-babel-next-src-block 1)
+    (should (looking-at org-babel-src-block-regexp))))
+
 (provide 'test-ob)
 
 ;;; test-ob ends here