summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2014-04-02 12:16:52 (GMT)
committer Nicolas Goaziou <n.goaziou@gmail.com>2014-04-02 12:54:37 (GMT)
commit23e62f7527e7106abd12f35fc919f44dfe22f097 (patch)
tree640f8623f74afb80fa9f424f4d49f50b59eb73b8
parent8a43270e8ee85e43de607f9fc152dc2f459e9cbb (diff)
downloadorg-mode-23e62f7527e7106abd12f35fc919f44dfe22f097.zip
org-mode-23e62f7527e7106abd12f35fc919f44dfe22f097.tar.gz
Radio targets cannot beging or end with whitespace
* lisp/org.el (org-radio-target-regexp): Radio targets cannot begin or end with whitespace. (org-target-regexp): Update syntax according to previous rule. (org-any-target-regexp): Fix fontification bug. * testing/lisp/test-org-element.el (test-org-element/radio-target-parser): Add test. Variables are turned into defconst to emphasize the fact that they are not subject to change. Thanks to Daniel Clemente for reporting it. http://permalink.gmane.org/gmane.emacs.orgmode/84461
-rw-r--r--lisp/org.el12
-rw-r--r--testing/lisp/test-org-element.el9
2 files changed, 18 insertions, 3 deletions
diff --git a/lisp/org.el b/lisp/org.el
index bb83eb7..9283d36 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6065,11 +6065,17 @@ by a #."
(defvar org-target-link-regexp nil
"Regular expression matching radio targets in plain text.")
(make-variable-buffer-local 'org-target-link-regexp)
-(defvar org-target-regexp "<<\\([^<>\n\r]+\\)>>"
+
+(defconst org-target-regexp (let ((border "[^<>\n\r \t]"))
+ (format "<<\\(%s\\|%s[^<>\n\r]*%s\\)>>"
+ border border border))
"Regular expression matching a link target.")
-(defvar org-radio-target-regexp "<<<\\([^<>\n\r]+\\)>>>"
+
+(defconst org-radio-target-regexp (format "<%s>" org-target-regexp)
"Regular expression matching a radio target.")
-(defvar org-any-target-regexp "<<<?\\([^<>\n\r]+\\)>>>?" ; FIXME, not exact, would match <<<aaa>> as a radio target.
+
+(defconst org-any-target-regexp
+ (format "%s\\|%s" org-radio-target-regexp org-target-regexp)
"Regular expression matching any target.")
(defun org-activate-target-links (limit)
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index def1659..d6e38ff 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -1699,6 +1699,15 @@ Outside list"
(should
(eq 'radio-target
(org-test-with-temp-text "<<<\\alpha radio>>>"
+ (org-element-type (org-element-context)))))
+ ;; Radio targets cannot begin or end with white space.
+ (should-not
+ (eq 'radio-target
+ (org-test-with-temp-text "<<< radio>>>"
+ (org-element-type (org-element-context)))))
+ (should-not
+ (eq 'radio-target
+ (org-test-with-temp-text "<<<radio >>>"
(org-element-type (org-element-context))))))