summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2015-03-15 12:07:40 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2015-03-15 15:49:05 +0100
commit269b68090052fbc92c7a8bff96cbabd1bd736fb4 (patch)
treea7983b16ff5d8df7100534673ef314e23240b7b1
parent7072dba04d6c69ae047992353698d016b670fe4d (diff)
downloadorg-mode-269b68090052fbc92c7a8bff96cbabd1bd736fb4.tar.gz
Fix CUSTOM_ID search
* lisp/org.el (org-link-search): Avoid false positives when searching CUSTOM_ID property. * testing/lisp/test-org.el (test-org/custom-id): Add test.
-rwxr-xr-xlisp/org.el15
-rw-r--r--testing/lisp/test-org.el7
2 files changed, 10 insertions, 12 deletions
diff --git a/lisp/org.el b/lisp/org.el
index f6828f7..dcfea74 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10999,19 +10999,10 @@ variable."
;; First check if there are any special search functions
((run-hook-with-args-until-success 'org-execute-file-search-functions s))
;; Now try the builtin stuff
- ((and (equal (string-to-char s0) ?#)
+ ((and (eq (aref s0 0) ?#)
(> (length s0) 1)
- (save-excursion
- (goto-char (point-min))
- (and
- (re-search-forward
- (concat "^[ \t]*:CUSTOM_ID:[ \t]+"
- (regexp-quote (substring s0 1)) "[ \t]*$") nil t)
- (setq type 'dedicated
- pos (match-beginning 0))))
- ;; There is an exact target for this
- (goto-char pos)
- (org-back-to-heading t)))
+ (let ((match (org-find-property "CUSTOM_ID" (substring s0 1))))
+ (and match (goto-char match) (setf type 'dedicated)))))
((save-excursion
(goto-char (point-min))
(and
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index f936e3d..afe72ae 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -1313,6 +1313,13 @@
"* H1\n:PROPERTIES:\n:CUSTOM_ID: custom\n:END:\n* H2\n[[#custom]]"
(goto-char (point-max))
(org-open-at-point)
+ (org-looking-at-p "\\* H1")))
+ ;; Ignore false positives.
+ (should-not
+ (org-test-with-temp-text
+ "* H1\n:DRAWER:\n:CUSTOM_ID: custom\n:END:\n* H2\n[[#custom]]<point>"
+ (goto-char (point-max))
+ (let (org-link-search-must-match-exact-headline) (org-open-at-point))
(org-looking-at-p "\\* H1"))))
;;;; Fuzzy Links