* [PATCH] Fix shadowed radio targets
@ 2022-06-06 19:44 Rudolf Adamkovič
2022-06-09 8:25 ` Ihor Radchenko
0 siblings, 1 reply; 2+ messages in thread
From: Rudolf Adamkovič @ 2022-06-06 19:44 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 216 bytes --]
Hello everyone!
If one defines two radio targets, say <<<peptide bond>>> and
<<<peptide>>>, the first one does not work if defined first. Please,
see the attached patch. I have the copyright papers signed.
Rudy
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ol.el-Fix-shadowed-radio-targets.patch --]
[-- Type: text/x-patch, Size: 1869 bytes --]
From f0077a592fbf4ddfde02f5899dc428db4f7ecbf2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <salutis@me.com>
Date: Sat, 23 Apr 2022 11:39:33 +0200
Subject: [PATCH] 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.
---
lisp/ol.el | 3 +++
testing/lisp/test-org.el | 12 ++++++++++++
2 files changed, 15 insertions(+)
diff --git a/lisp/ol.el b/lisp/ol.el
index d4bd0e40c..189e31b1e 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -2040,6 +2040,9 @@ Also refresh fontification if needed."
(cl-pushnew (org-element-property :value obj) rtn
:test #'equal))))
rtn))))
+ (sort targets
+ (lambda (a b)
+ (> (length a) (length b))))
(setq org-target-link-regexp
(and targets
(concat before-re
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 5f13e89a4..121f9efd5 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -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
--
2.36.1
[-- Attachment #3: Type: text/plain, Size: 246 bytes --]
--
"One can begin to reason only when a clear picture has been formed in
the imagination."
-- Walter Warwick Sawyer, Mathematician's Delight, 1943
Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-09 8:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-06 19:44 [PATCH] Fix shadowed radio targets Rudolf Adamkovič
2022-06-09 8:25 ` Ihor Radchenko
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.