소스 검색

Fix RET on multi-line links

* lisp/org.el (org-return): Follow multi-line links.
* testing/lisp/test-org.el (test-org/return): Add tests.

Reported-by: Brent Goodrick <bgoodr@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2018-04/msg00105.html>
Nicolas Goaziou 7 년 전
부모
커밋
f05c2eae33
2개의 변경된 파일23개의 추가작업 그리고 1개의 파일을 삭제
  1. 8 1
      lisp/org.el
  2. 15 0
      testing/lisp/test-org.el

+ 8 - 1
lisp/org.el

@@ -21080,7 +21080,14 @@ object (e.g., within a comment).  In these case, you need to use
      ;; `org-return-follows-link' allows it.  Tolerate fuzzy
      ;; locations, e.g., in a comment, as `org-open-at-point'.
      ((and org-return-follows-link
-	   (or (org-in-regexp org-ts-regexp-both nil t)
+	   (or (and (eq 'link (org-element-type context))
+		    ;; Ensure point is not on the white spaces after
+		    ;; the link.
+		    (let ((origin (point)))
+		      (org-with-point-at (org-element-property :end context)
+			(skip-chars-backward " \t")
+			(> (point) origin))))
+	       (org-in-regexp org-ts-regexp-both nil t)
 	       (org-in-regexp org-tsr-regexp-both nil  t)
 	       (org-in-regexp org-any-link-re nil t)))
       (call-interactively #'org-open-at-point))

+ 15 - 0
testing/lisp/test-org.el

@@ -1121,6 +1121,21 @@
 	   (org-link-search-must-match-exact-headline nil))
        (org-return))
      (looking-at-p "<<target>>")))
+  ;; `org-return-follows-link' handle multi-line lines.
+  (should
+   (org-test-with-temp-text
+       "[[target][This is a very\n long description<point>]]\n <<target>>"
+     (let ((org-return-follows-link t)
+	   (org-link-search-must-match-exact-headline nil))
+       (org-return))
+     (looking-at-p "<<target>>")))
+  (should-not
+   (org-test-with-temp-text
+       "[[target][This is a very\n long description]]<point>\n <<target>>"
+     (let ((org-return-follows-link t)
+	   (org-link-search-must-match-exact-headline nil))
+       (org-return))
+     (looking-at-p "<<target>>")))
   ;; However, do not open link when point is in a table.
   (should
    (org-test-with-temp-text "| [[target<point>]] |\n| between |\n| <<target>> |"