ol: Fix `org-previous-link' skipping links

* lisp/ol.el (org-next-link): Do not skip links when searching
  backwards.

Reported-by: stardiviner <numbchild@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2019-04/msg00022.html>
This commit is contained in:
Nicolas Goaziou 2019-04-10 15:26:46 +02:00
parent ea4876869c
commit 09a1a24b73
2 changed files with 6 additions and 1 deletions

View File

@ -1308,7 +1308,7 @@ is non-nil, move backward."
(catch :found
(while (funcall search-fun org-link-any-re nil t)
(let ((context (save-excursion
(forward-char -1)
(unless search-backward (forward-char -1))
(org-element-context))))
(pcase (org-element-lineage context '(link) t)
(`nil nil)

View File

@ -352,6 +352,11 @@
(org-test-with-temp-text "[[link1]]\n[[link2<point>]]"
(org-previous-link)
(buffer-substring (point) (line-end-position)))))
(should
(equal "[[link1]]"
(org-test-with-temp-text "line\n[[link1]]\n[[link2<point>]]"
(org-previous-link)
(buffer-substring (point) (line-end-position)))))
;; Ignore fake links.
(should
(equal "[[truelink]]"