mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-12-02 08:22:16 +00:00
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.
This commit is contained in:
parent
83a55c6f5b
commit
d6d1f25429
@ -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))
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user