From d75fa9febc676af4893fba9e4d53d5babbb801aa Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 2 Mar 2014 10:32:51 +0100 Subject: [PATCH] `org-open-at-point' right after an object still open it * lisp/org.el (org-open-at-point): White spaces after an object are usually ignored by the function. Though, when point is right after the object, still activate it. * testing/lisp/test-org.el (test-org/custom-id): Fix test. --- lisp/org.el | 18 ++++++++---------- testing/lisp/test-org.el | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 52f7fbfba..f0f9f0505 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -10480,6 +10480,7 @@ is used internally by `org-open-link-from-string'." footnote-reference timestamp))) (setq context (org-element-property :parent context)))) (cond + ;; Unsupported context: return an error. ((not context) (user-error "No link found")) ;; On a headline or an inlinetask, but not on a timestamp, ;; a link, a footnote reference or on tags. @@ -10499,16 +10500,13 @@ is used internally by `org-open-link-from-string'." (org-open-at-point)) (require 'org-attach) (org-attach-reveal 'if-exists)))) - ;; Do nothing on white spaces after an object. - ((let ((end (org-element-property :end context))) - (= (save-excursion - ;; Make sure we're not on invisible text, as it would - ;; make the check unpredictable on object's borders. - (when (invisible-p (point)) - (goto-char - (next-single-property-change (point) 'invisible nil end))) - (skip-chars-forward " \t" end) (point)) - end)) + ;; Do nothing on white spaces after an object, unless point + ;; is right after it. + ((> (point) + (save-excursion + (goto-char (org-element-property :end context)) + (skip-chars-backward " \t") + (point))) (user-error "No link found")) ((eq type 'timestamp) (org-follow-timestamp-link)) ;; On tags within a headline or an inlinetask. diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index e3436e6ab..57e3d53dc 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -553,7 +553,7 @@ (should (org-test-with-temp-text "* H1\n:PROPERTIES:\n:CUSTOM_ID: custom\n:END:\n* H2\n[[#custom]]" - (goto-char (1- (point-max))) + (goto-char (point-max)) (org-open-at-point) (org-looking-at-p "\\* H1"))))