diff --git a/lisp/ob.el b/lisp/ob.el index 5e721ba41..26a3af718 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -433,12 +433,13 @@ can not be resolved.") (defun org-babel-named-src-block-regexp-for-name (name) "This generates a regexp used to match a src block named NAME." - (concat org-babel-src-name-regexp (regexp-quote name) "[ \t\n]*" + (concat org-babel-src-name-regexp (regexp-quote name) + "\\([ \t]\\|$\\|(\\)" ".*[\r\n]" (substring org-babel-src-block-regexp 1))) (defun org-babel-named-data-regexp-for-name (name) "This generates a regexp used to match data named NAME." - (concat org-babel-result-regexp (regexp-quote name) "[ \t]*.*$")) + (concat org-babel-result-regexp (regexp-quote name) "\\([ \t]\\|$\\)")) ;;; functions (defvar call-process-region) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index c993fbef8..d145f4e3a 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -463,6 +463,40 @@ on two lines (org-babel-next-src-block 2) (should (string= (org-babel-execute-src-block) "baz")))) +(ert-deftest test-ob/do-not-resolve-to-partial-names-data () + (org-test-with-temp-text " +#+tblname: base_plus +| 1 | +| 2 | + +#+tblname: base +| 3 | +| 4 | + +#+begin_src emacs-lisp :var x=base + x +#+end_src" + (org-babel-next-src-block 1) + (should (equal (org-babel-execute-src-block) '((3) (4)))))) + +(ert-deftest test-ob/do-not-resolve-to-partial-names-code () + (org-test-with-temp-text " +#+name: base_plus +#+begin_src emacs-lisp + 'bar +#+end_src + +#+name: base +#+begin_src emacs-lisp + 'foo +#+end_src + +#+begin_src emacs-lisp :var x=base + x +#+end_src" + (org-babel-next-src-block 3) + (should (equal (org-babel-execute-src-block) "foo")))) + (provide 'test-ob) ;;; test-ob ends here