summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-01-16 14:50:25 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-01-16 14:50:25 +0100
commit6e57a371ff92b47bb0876db853158c1e73d4d586 (patch)
tree6c4ee186aec97c13f50bd29160fa41921951def3
parent671ed99d23ac479b01e1ddf8ab2796d6b3601264 (diff)
downloadorg-mode-6e57a371ff92b47bb0876db853158c1e73d4d586.tar.gz
Fix tags looking like plain links
* lisp/org-element.el (org-element-context): Do not look for objects within TODO keyword, priority cookie, comment keyword or tags. * lisp/org.el (org-activate-tags): Fix regexp. * testing/lisp/test-org-element.el (test-org-element/context): Add test. Reported-by: John Kitchin <jkitchin@andrew.cmu.edu>
-rw-r--r--lisp/org-element.el12
-rwxr-xr-xlisp/org.el16
-rw-r--r--testing/lisp/test-org-element.el9
3 files changed, 25 insertions, 12 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 33514ce..b22c5ad 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -5773,10 +5773,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))
diff --git a/lisp/org.el b/lisp/org.el
index 9a1e46c..f741d5e 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6240,14 +6240,14 @@ done, nil otherwise."
(font-lock-mode 1)))
(defun org-activate-tags (limit)
- (if (re-search-forward (org-re "^\\*+.*[ \t]\\(:[[:alnum:]_@#%:]+:\\)[ \r\n]") limit t)
- (progn
- (org-remove-flyspell-overlays-in (match-beginning 1) (match-end 1))
- (add-text-properties (match-beginning 1) (match-end 1)
- (list 'mouse-face 'highlight
- 'keymap org-mouse-map))
- (org-rear-nonsticky-at (match-end 1))
- 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
+ 'keymap org-mouse-map))
+ (org-rear-nonsticky-at (match-end 1))
+ t))
(defun org-outline-level ()
"Compute the outline level of the heading at point.
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index 6347e87..4d4adec 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -3422,6 +3422,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))))))