浏览代码

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.
Nicolas Goaziou 11 年之前
父节点
当前提交
8b2d3645ac
共有 2 个文件被更改,包括 12 次插入1 次删除
  1. 11 0
      lisp/org.el
  2. 1 1
      testing/lisp/test-org.el

+ 11 - 0
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)

+ 1 - 1
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"))))