summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2015-08-03 02:45:25 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2015-08-03 02:59:13 +0200
commita3b2b7473ecfe019134bb68759fa726040197ed1 (patch)
tree40b3f26d3a3b5321d2742d9e5210327187b75263
parente50033d494f981604c5d0ffbe8e8cf1df992a7b2 (diff)
downloadorg-mode-a3b2b7473ecfe019134bb68759fa726040197ed1.tar.gz
Repair radio target search
* lisp/org.el (org-open-at-point): Find radio targets again. (org-search-radio-target): New function. * testing/lisp/test-org.el (test-org/open-at-point/radio-target): New test.
-rwxr-xr-xlisp/org.el46
-rw-r--r--testing/lisp/test-org.el8
2 files changed, 43 insertions, 11 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 1b69421..240542e 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10827,17 +10827,21 @@ link in a property drawer line."
(if (not arg) (org-mark-ring-push)
(switch-to-buffer-other-window
(org-get-buffer-for-internal-link (current-buffer))))
- (let ((cmd `(org-link-search
- ,(if (member type '("custom-id" "coderef"))
- (org-element-property :raw-link link)
- path)
- ,(cond ((equal arg '(4)) 'occur)
- ((equal arg '(16)) 'org-occur))
- ;; Prevent fuzzy links from matching
- ;; themselves.
- ,(and (equal type "fuzzy")
- (+ 2
- (org-element-property :begin link))))))
+ (let ((cmd
+ (if (equal type "radio")
+ `(org-search-radio-target
+ ,(org-element-property :path link))
+ `(org-link-search
+ ,(if (member type '("custom-id" "coderef"))
+ (org-element-property :raw-link link)
+ path)
+ ,(cond ((equal arg '(4)) 'occur)
+ ((equal arg '(16)) 'org-occur))
+ ;; Prevent fuzzy links from matching
+ ;; themselves.
+ ,(and (equal type "fuzzy")
+ (+ 2
+ (org-element-property :begin link)))))))
(condition-case nil
(let ((org-link-search-inhibit-query t)) (eval cmd))
(error (progn (widen) (eval cmd)))))))
@@ -10974,6 +10978,26 @@ the window configuration before `org-open-at-point' was called using:
(set-window-configuration org-window-config-before-follow-link)")
+(defun org-search-radio-target (target)
+ "Search a radio target matching TARGET in current buffer.
+White spaces are not significant."
+ (let ((re (format "<<<%s>>>"
+ (mapconcat #'regexp-quote
+ (org-split-string target "[ \t\n]+")
+ "[ \t]+\\(?:\n[ \t]*\\)?")))
+ (origin (point)))
+ (goto-char (point-min))
+ (catch :radio-match
+ (while (re-search-forward re nil t)
+ (backward-char)
+ (let ((object (org-element-context)))
+ (when (eq (org-element-type object) 'radio-target)
+ (goto-char (org-element-property :begin object))
+ (org-show-context 'link-search)
+ (throw :radio-match nil))))
+ (goto-char origin)
+ (user-error "No match for radio target: %s" target))))
+
(defun org-link-search (s &optional type avoid-pos stealth)
"Search for a search string S.
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index c8052f7..8282bbe 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -1660,6 +1660,14 @@ drops support for Emacs 24.1 and 24.2."
(prog1 (with-current-buffer "*info*" (looking-at "\nOrg Mode Manual"))
(kill-buffer "*info*")))))
+(ert-deftest test-org/open-at-point/radio-target ()
+ "Test `org-open-at-point' on radio targets."
+ (should
+ (org-test-with-temp-text "<<<target>>> <point>target"
+ (org-update-radio-target-regexp)
+ (org-open-at-point)
+ (eq (org-element-type (org-element-context)) 'radio-target))))
+
;;; Node Properties