From 8b2d3645ac655f734d4c9812dd80520330b2edbc Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 27 Feb 2014 18:28:46 +0100 Subject: [PATCH] Ignore `org-open-at-point' when point is on white spaces * lisp/org.el (org-open-at-point): Do not do anything when point is on white spaces after an object. * testing/lisp/test-org.el (test-org/custom-id): Modify test. --- lisp/org.el | 11 +++++++++++ testing/lisp/test-org.el | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 3800d80b9..836935f35 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -10482,6 +10482,17 @@ is used internally by `org-open-link-from-string'." (require 'org-attach) (org-attach-reveal 'if-exists)))) ((run-hook-with-args-until-success 'org-open-at-point-functions)) + ;; 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)) + (user-error "No link found")) ((eq type 'timestamp) (org-follow-timestamp-link)) ;; On tags within a headline or an inlinetask. ((save-excursion (beginning-of-line) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 57e3d53dc..e3436e6ab 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 (point-max)) + (goto-char (1- (point-max))) (org-open-at-point) (org-looking-at-p "\\* H1")))) -- 2.11.4.GIT