summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2019-04-04 15:52:12 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2019-04-04 15:52:41 +0200
commit3375f039dd6836d8ecb2955cdd31100ea927cd4d (patch)
treec058e3ad6e99cd55546ce6482870f45e7f8bab98
parent50c5c2ac4dc4b9693e6bb5da50b73b1021b3fedf (diff)
downloadorg-mode-3375f039dd6836d8ecb2955cdd31100ea927cd4d.tar.gz
ol: Fix `org-next-link' in an item tag
* lisp/ol.el (org-next-link): Fix `org-next-link' in an item tag. * testing/lisp/test-ol.el (test-ol/next-link): Add test.
-rw-r--r--lisp/ol.el15
-rw-r--r--testing/lisp/test-ol.el8
2 files changed, 16 insertions, 7 deletions
diff --git a/lisp/ol.el b/lisp/ol.el
index 92c438e..2dd171e 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1307,12 +1307,15 @@ is non-nil, move backward."
(setq org-link--search-failed nil)
(catch :found
(while (funcall search-fun org-link-any-re nil t)
- (pcase (org-element-lineage (org-element-context) '(link) t)
- (`nil nil)
- (link
- (goto-char (org-element-property :begin link))
- (when (org-invisible-p) (org-show-context))
- (throw :found t))))
+ (let ((context (save-excursion
+ (forward-char -1)
+ (org-element-context))))
+ (pcase (org-element-lineage context '(link) t)
+ (`nil nil)
+ (link
+ (goto-char (org-element-property :begin link))
+ (when (org-invisible-p) (org-show-context))
+ (throw :found t)))))
(goto-char pos)
(setq org-link--search-failed t)
(message "No further link found"))))
diff --git a/testing/lisp/test-ol.el b/testing/lisp/test-ol.el
index 995da85..c7c4703 100644
--- a/testing/lisp/test-ol.el
+++ b/testing/lisp/test-ol.el
@@ -320,7 +320,13 @@
(let* ((this-command 'org-next-link)
(last-command this-command))
(org-next-link))
- (buffer-substring (point) (line-end-position))))))
+ (buffer-substring (point) (line-end-position)))))
+ ;; Find links with item tags.
+ (should
+ (equal "[[link1]]"
+ (org-test-with-temp-text "- tag [[link1]] :: description"
+ (org-next-link)
+ (buffer-substring (point) (search-forward "]]" nil t))))))
(ert-deftest test-ol/previous-link ()
"Test `org-previous-link' specifications."