summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2015-10-18 09:49:15 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2015-10-18 09:49:15 +0200
commitaf4e11887054c77cf52e6b6846da6382eb51758a (patch)
tree0687df6986d592471d95476372b60edd6f5a421d
parent486d9477613b5db5bb9fb9c147593795fa1099fe (diff)
parent4e864643bdb6bba3e000ea51fb746a26e40b1f77 (diff)
downloadorg-mode-af4e11887054c77cf52e6b6846da6382eb51758a.tar.gz
Merge branch 'maint'
-rwxr-xr-xlisp/org.el20
-rw-r--r--testing/lisp/test-org.el19
2 files changed, 25 insertions, 14 deletions
diff --git a/lisp/org.el b/lisp/org.el
index b1475b8..f26ee69 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -21334,25 +21334,23 @@ will not happen if point is in a table or on a \"dead\"
object (e.g., within a comment). In these case, you need to use
`org-open-at-point' directly."
(interactive)
- (let* ((context (if org-return-follows-link (org-element-context)
- (org-element-at-point)))
- (type (org-element-type context)))
+ (let ((context (if org-return-follows-link (org-element-context)
+ (org-element-at-point))))
(cond
;; In a table, call `org-table-next-row'.
- ((or (and (eq type 'table)
+ ((or (and (eq (org-element-type context) 'table)
(>= (point) (org-element-property :contents-begin context))
(< (point) (org-element-property :contents-end context)))
(org-element-lineage context '(table-row table-cell) t))
(org-table-justify-field-maybe)
(call-interactively #'org-table-next-row))
- ;; On a link or a timestamp but not on white spaces after it,
- ;; call `org-open-line' if `org-return-follows-link' allows it.
+ ;; On a link or a timestamp, call `org-open-line' if
+ ;; `org-return-follows-link' allows it. Tolerate fuzzy
+ ;; locations, e.g., in a comment, as `org-open-line'.
((and org-return-follows-link
- (memq type '(link timestamp))
- (< (point)
- (save-excursion (goto-char (org-element-property :end context))
- (skip-chars-backward " \t")
- (point))))
+ (or (org-at-timestamp-p t)
+ (org-at-date-range-p t)
+ (org-in-regexp org-any-link-re)))
(call-interactively #'org-open-at-point))
;; Insert newline in heading, but preserve tags.
((and (not (bolp))
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 453d106..c29c799 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -976,18 +976,31 @@
(should
(org-test-with-temp-text "Link [[target<point>]] <<target>>"
(let ((org-return-follows-link t)
- (org-link-search-must-match-exact-headline nil)) (org-return))
+ (org-link-search-must-match-exact-headline nil))
+ (org-return))
(org-looking-at-p "<<target>>")))
(should-not
(org-test-with-temp-text "Link [[target<point>]] <<target>>"
(let ((org-return-follows-link nil)) (org-return))
(org-looking-at-p "<<target>>")))
- ;; Link in heading should also be opened when
- ;; `org-return-follows-link` is non-nil.
(should
(org-test-with-temp-text "* [[b][a<point>]]\n* b"
(let ((org-return-follows-link t)) (org-return))
(org-looking-at-p "* b")))
+ (should
+ (org-test-with-temp-text "Link [[target][/descipt<point>ion/]] <<target>>"
+ (let ((org-return-follows-link t)
+ (org-link-search-must-match-exact-headline nil))
+ (org-return))
+ (org-looking-at-p "<<target>>")))
+ ;; When `org-return-follows-link' is non-nil, tolerate links and
+ ;; timestamps in comments, node properties, etc.
+ (should
+ (org-test-with-temp-text "# Comment [[target<point>]]\n <<target>>"
+ (let ((org-return-follows-link t)
+ (org-link-search-must-match-exact-headline nil))
+ (org-return))
+ (org-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>> |"