Pārlūkot izejas kodu

Merge branch 'maint'

Nicolas Goaziou 9 gadi atpakaļ
vecāks
revīzija
1c8ed102e9
3 mainītis faili ar 19 papildinājumiem un 5 dzēšanām
  1. 8 4
      lisp/org-element.el
  2. 2 1
      lisp/org.el
  3. 9 0
      testing/lisp/test-org-element.el

+ 8 - 4
lisp/org-element.el

@@ -5741,10 +5741,14 @@ Providing it allows for quicker computation."
 	;; At an headline or inlinetask, objects are in title.
 	((memq type '(headline inlinetask))
 	 (goto-char (org-element-property :begin element))
-	 (skip-chars-forward "*")
-	 (if (and (> pos (point)) (< pos (line-end-position)))
-	     (narrow-to-region (point) (line-end-position))
-	   (throw 'objects-forbidden element)))
+	 (looking-at org-complex-heading-regexp)
+	 (let ((end (match-end 4)))
+	   (if (not end) (throw 'objects-forbidden element)
+	     (goto-char (match-beginning 4))
+	     (when (let (case-fold-search) (looking-at org-comment-string))
+	       (goto-char (match-end 0)))
+	     (if (>= (point) end) (throw 'objects-forbidden element)
+	       (narrow-to-region (point) end)))))
 	;; At a paragraph, a table-row or a verse block, objects are
 	;; located within their contents.
 	((memq type '(paragraph table-row verse-block))

+ 2 - 1
lisp/org.el

@@ -6192,7 +6192,8 @@ done, nil otherwise."
     (font-lock-mode 1)))
 
 (defun org-activate-tags (limit)
-  (when (re-search-forward (org-re "^\\*+.*[ \t]\\(:[[:alnum:]_@#%:]+:\\)[ \r\n]") limit t)
+  (when (re-search-forward
+	 (org-re "^\\*+.*[ \t]\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") limit t)
     (org-remove-flyspell-overlays-in (match-beginning 1) (match-end 1))
     (add-text-properties (match-beginning 1) (match-end 1)
 			 (list 'mouse-face 'highlight

+ 9 - 0
testing/lisp/test-org-element.el

@@ -3409,6 +3409,15 @@ Text
   (should
    (eq 'link
        (org-test-with-temp-text "[fn::[[<point>http://orgmode.org]]]"
+	 (org-element-type (org-element-context)))))
+  ;; Special case: tags looking like a link.
+  (should-not
+   (eq 'link
+       (org-test-with-temp-text "* Headline :file<point>:tags:"
+	 (org-element-type (org-element-context)))))
+  (should
+   (eq 'link
+       (org-test-with-temp-text "* Headline :file<point>:tags: :real:tag:"
 	 (org-element-type (org-element-context))))))