Browse Source

Fix radio targets detection

* lisp/org.el (org-all-targets): Fix radio targets detection when
  object is directly followed by a non-whitespace character.

* testing/lisp/test-org.el: Add test.
Nicolas Goaziou 5 years ago
parent
commit
31052f1c91
2 changed files with 5 additions and 0 deletions
  1. 2 0
      lisp/org.el
  2. 3 0
      testing/lisp/test-org.el

+ 2 - 0
lisp/org.el

@@ -5793,6 +5793,8 @@ targets."
     (save-excursion
       (goto-char (point-min))
       (while (re-search-forward re nil t)
+	;; Make sure point is really within the object.
+	(backward-char)
 	(let ((obj (org-element-context)))
 	  (when (memq (org-element-type obj) '(radio-target target))
 	    (add-to-list 'rtn (downcase (org-element-property :value obj))))))

+ 3 - 0
testing/lisp/test-org.el

@@ -878,6 +878,9 @@ Text.
    (equal '("radio-target" "target")
 	  (org-test-with-temp-text "<<target>> <<<radio-target>>>\n: <<verb>>"
 	    (org-all-targets))))
+  (should
+   (equal '("radio-target")
+	  (org-test-with-temp-text "<<<radio-target>>>!" (org-all-targets))))
   ;; With argument.
   (should
    (equal '("radio-target")