Don't match partial names when resolving code or data references
* lisp/ob.el (org-babel-named-src-block-regexp-for-name): Ensure that partial names are not matched. (org-babel-named-data-regexp-for-name): Ensure that partial names are not matched. * testing/lisp/test-ob.el (test-ob/do-not-resolve-to-partial-names-data): Test to ensure that partial names are not matched.
This commit is contained in:
parent
19884ab280
commit
7c21098323
|
@ -433,12 +433,13 @@ can not be resolved.")
|
||||||
|
|
||||||
(defun org-babel-named-src-block-regexp-for-name (name)
|
(defun org-babel-named-src-block-regexp-for-name (name)
|
||||||
"This generates a regexp used to match a src block named 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)))
|
(substring org-babel-src-block-regexp 1)))
|
||||||
|
|
||||||
(defun org-babel-named-data-regexp-for-name (name)
|
(defun org-babel-named-data-regexp-for-name (name)
|
||||||
"This generates a regexp used to match data named 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
|
;;; functions
|
||||||
(defvar call-process-region)
|
(defvar call-process-region)
|
||||||
|
|
|
@ -463,6 +463,40 @@ on two lines
|
||||||
(org-babel-next-src-block 2)
|
(org-babel-next-src-block 2)
|
||||||
(should (string= (org-babel-execute-src-block) "baz"))))
|
(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)
|
(provide 'test-ob)
|
||||||
|
|
||||||
;;; test-ob ends here
|
;;; test-ob ends here
|
||||||
|
|
Loading…
Reference in New Issue