summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2018-04-08 18:35:40 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-04-08 18:35:40 +0200
commitf05c2eae3394afa5d8075ccac38b94163acda9e7 (patch)
tree8c18670730ffb324cb7a31107f0d9fc9e2f519a6
parent8e5d74ca4c132af4df2a6d330633809866f202b5 (diff)
downloadorg-mode-f05c2eae3394afa5d8075ccac38b94163acda9e7.tar.gz
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>
-rw-r--r--lisp/org.el9
-rw-r--r--testing/lisp/test-org.el15
2 files changed, 23 insertions, 1 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 1373861..e3a9c6b 100644
--- a/lisp/org.el
+++ b/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))
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 59fd902..64d72ed 100644
--- a/testing/lisp/test-org.el
+++ b/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>> |"