mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-25 07:27:57 +00:00
lisp/ol.el: Fix shadowed radio targets
* lisp/ol.el (org-update-radio-target-regexp): Sort radio targets before building the regexp that matches them. * testing/lisp/test-org.el: Test shadowed radio targets. The bug occurs when two targets share the same prefix and when and the longer target appears first.
This commit is contained in:
parent
0e7033e0ca
commit
d9963c58dc
@ -2040,6 +2040,10 @@ Also refresh fontification if needed."
|
||||
(cl-pushnew (org-element-property :value obj) rtn
|
||||
:test #'equal))))
|
||||
rtn))))
|
||||
(setq targets
|
||||
(sort targets
|
||||
(lambda (a b)
|
||||
(> (length a) (length b)))))
|
||||
(setq org-target-link-regexp
|
||||
(and targets
|
||||
(concat before-re
|
||||
|
@ -2915,6 +2915,18 @@ Foo Bar
|
||||
(org-open-at-point)
|
||||
(eq (org-element-type (org-element-context)) 'radio-target))))
|
||||
|
||||
(ert-deftest test-org/open-at-point/radio-target-shadowed ()
|
||||
"Test `org-open-at-point' on shadowed radio targets."
|
||||
(should
|
||||
(org-test-with-temp-text
|
||||
"<<<target shadowed>>> <<<target>>> <point>target shadowed"
|
||||
(org-update-radio-target-regexp)
|
||||
(org-open-at-point)
|
||||
(string=
|
||||
(org-element-property :value
|
||||
(org-element-radio-target-parser))
|
||||
"target shadowed"))))
|
||||
|
||||
(ert-deftest test-org/open-at-point/tag ()
|
||||
"Test `org-open-at-point' on tags."
|
||||
(should
|
||||
|
Loading…
Reference in New Issue
Block a user