Procházet zdrojové kódy

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>
Nicolas Goaziou před 6 roky
rodič
revize
09a1a24b73
2 změnil soubory, kde provedl 6 přidání a 1 odebrání
  1. 1 1
      lisp/ol.el
  2. 5 0
      testing/lisp/test-ol.el

+ 1 - 1
lisp/ol.el

@@ -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)

+ 5 - 0
testing/lisp/test-ol.el

@@ -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]]"