summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-08-10 12:42:51 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-08-10 12:42:51 +0200
commit829ffa977c6f7030dbc837589fd3dec8b597a13f (patch)
treee6f99eef8139b3122bb6aad3f29c6cbab2dbfb69
parent8ab9a82be2a6178063e395a6ab3d2b9e083059c3 (diff)
parentfebab2fedb93b8b589e91e6e733ffbd7e2937e7b (diff)
downloadorg-mode-829ffa977c6f7030dbc837589fd3dec8b597a13f.tar.gz
Merge branch 'maint'
-rw-r--r--lisp/org.el43
-rw-r--r--testing/lisp/test-org.el17
2 files changed, 35 insertions, 25 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 2d98ba8..05e4456 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10616,23 +10616,24 @@ a timestamp or a link."
(value (org-element-property :value context)))
(cond
;; On a headline or an inlinetask, but not on a timestamp,
- ;; a link, a footnote reference or on tags.
- ((and (memq type '(headline inlinetask))
- ;; Not on tags.
- (let ((case-fold-search nil))
- (and (org-match-line org-complex-heading-regexp)
- (or (not (match-beginning 5))
- (< (point) (match-beginning 5))))))
- (let* ((data (org-offer-links-in-entry (current-buffer) (point) arg))
- (links (car data))
- (links-end (cdr data)))
- (if links
- (dolist (link (if (stringp links) (list links) links))
- (search-forward link nil links-end)
- (goto-char (match-beginning 0))
- (org-open-at-point))
- (require 'org-attach)
- (org-attach-reveal 'if-exists))))
+ ;; a link, a footnote reference.
+ ((memq type '(headline inlinetask))
+ (org-match-line org-complex-heading-regexp)
+ (if (and (match-beginning 5)
+ (>= (point) (match-beginning 5))
+ (< (point) (match-end 5)))
+ ;; On tags.
+ (org-tags-view arg (substring (match-string 5) 0 -1))
+ ;; Not on tags.
+ (pcase (org-offer-links-in-entry (current-buffer) (point) arg)
+ (`(nil . ,_)
+ (require 'org-attach)
+ (org-attach-reveal 'if-exists))
+ (`(,links . ,links-end)
+ (dolist (link (if (stringp links) (list links) links))
+ (search-forward link nil links-end)
+ (goto-char (match-beginning 0))
+ (org-open-at-point))))))
;; On a footnote reference or at definition's label.
((or (eq type 'footnote-reference)
(and (eq type 'footnote-definition)
@@ -10668,14 +10669,6 @@ a timestamp or a link."
(point)))
(user-error "No link found"))
((eq type 'timestamp) (org-follow-timestamp-link))
- ;; On tags within a headline or an inlinetask.
- ((and (memq type '(headline inlinetask))
- (let ((case-fold-search nil))
- (save-excursion (beginning-of-line)
- (looking-at org-complex-heading-regexp))
- (and (match-beginning 5)
- (>= (point) (match-beginning 5)))))
- (org-tags-view arg (substring (match-string 5) 0 -1)))
((eq type 'link)
(let ((type (org-element-property :type context))
(path (org-link-unescape (org-element-property :path context))))
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 372bf69..50b4a9d 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -2468,6 +2468,23 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/"
(org-open-at-point)
(eq (org-element-type (org-element-context)) 'radio-target))))
+(ert-deftest test-org/open-at-point/tag ()
+ "Test `org-open-at-point' on tags."
+ (should
+ (org-test-with-temp-text "* H :<point>tag:"
+ (catch :result
+ (cl-letf (((symbol-function 'org-tags-view)
+ (lambda (&rest args) (throw :result t))))
+ (org-open-at-point)
+ nil))))
+ (should-not
+ (org-test-with-temp-text-in-file "* H<point> :tag:"
+ (catch :result
+ (cl-letf (((symbol-function 'org-tags-view)
+ (lambda (&rest args) (throw :result t))))
+ (org-open-at-point)
+ nil)))))
+
;;;; Stored links
(ert-deftest test-org/store-link ()