浏览代码

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

+ 8 - 10
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.

+ 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 (1- (point-max)))
+     (goto-char (point-max))
      (org-open-at-point)
      (org-looking-at-p "\\* H1"))))