summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2014-03-21 14:51:34 +0100
committerNicolas Goaziou <n.goaziou@gmail.com>2014-03-21 14:51:34 +0100
commitd6d1f25429dce2abdd26fba004c6c496d00eeb9d (patch)
tree5e45587180284acad7401572a24d94c76d02c1f7
parent83a55c6f5b14b3f48afba05c737ab07d2e3dc3d1 (diff)
downloadorg-mode-d6d1f25429dce2abdd26fba004c6c496d00eeb9d.tar.gz
Fix `org-open-at-point'
* lisp/org.el (org-open-at-point): Correctly open fuzzy links when path is hexified. * testing/lisp/test-org.el (test-org/coderef): New test. (test-org/fuzzy-links): Add test.
-rw-r--r--lisp/org.el8
-rw-r--r--testing/lisp/test-org.el30
2 files changed, 30 insertions, 8 deletions
diff --git a/lisp/org.el b/lisp/org.el
index b3be342..2608fc8 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10641,9 +10641,11 @@ is used internally by `org-open-link-from-string'."
(switch-to-buffer-other-window
(org-get-buffer-for-internal-link (current-buffer))))
(let ((cmd `(org-link-search
- ,(org-element-property :raw-link context)
- ,(cond ((equal arg '(4)) ''occur)
- ((equal arg '(16)) ''org-occur))
+ ,(if (member type '("custom-id" "coderef"))
+ (org-element-property :raw-link context)
+ path)
+ ,(cond ((equal arg '(4)) 'occur)
+ ((equal arg '(16)) 'org-occur))
,(org-element-property :begin context))))
(condition-case nil
(let ((org-link-search-inhibit-query t))
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 57e3d53..949392e 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -546,6 +546,20 @@
;;; Links
+;;;; Coderefs
+
+(ert-deftest test-org/coderef ()
+ "Test coderef links specifications."
+ (should
+ (org-test-with-temp-text "
+#+BEGIN_SRC emacs-lisp
+\(+ 1 1) (ref:sc)
+#+END_SRC
+\[[(sc)]]"
+ (goto-char (point-max))
+ (org-open-at-point)
+ (looking-at "(ref:sc)"))))
+
;;;; Custom ID
(ert-deftest test-org/custom-id ()
@@ -564,30 +578,36 @@
(ert-deftest test-org/fuzzy-links ()
"Test fuzzy links specifications."
- ;; 1. Fuzzy link goes in priority to a matching target.
+ ;; Fuzzy link goes in priority to a matching target.
(should
(org-test-with-temp-text "#+NAME: Test\n|a|b|\n<<Test>>\n* Test\n[[Test]]"
(goto-line 5)
(org-open-at-point)
(looking-at "<<Test>>")))
- ;; 2. Then fuzzy link points to an element with a given name.
+ ;; Then fuzzy link points to an element with a given name.
(should
(org-test-with-temp-text "Test\n#+NAME: Test\n|a|b|\n* Test\n[[Test]]"
(goto-line 5)
(org-open-at-point)
(looking-at "#\\+NAME: Test")))
- ;; 3. A target still lead to a matching headline otherwise.
+ ;; A target still lead to a matching headline otherwise.
(should
(org-test-with-temp-text "* Head1\n* Head2\n*Head3\n[[Head2]]"
(goto-line 4)
(org-open-at-point)
(looking-at "\\* Head2")))
- ;; 4. With a leading star in link, enforce heading match.
+ ;; With a leading star in link, enforce heading match.
(should
(org-test-with-temp-text "* Test\n<<Test>>\n[[*Test]]"
(goto-line 3)
(org-open-at-point)
- (looking-at "\\* Test"))))
+ (looking-at "\\* Test")))
+ ;; Correctly un-hexify fuzzy links.
+ (should
+ (org-test-with-temp-text "* With space\n[[*With%20space][With space]]"
+ (goto-char (point-max))
+ (org-open-at-point)
+ (bobp))))
;;;; Link Escaping