summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien <bzg@gnu.org>2018-04-26 21:50:37 +0200
committerBastien <bzg@gnu.org>2018-04-26 21:50:37 +0200
commitb64f31abd236e12fd2cf699e5be8008e7a696333 (patch)
tree7869ef09511ad7e7f661b657ba0597d07be078a4
parentd561b3d0b93be303be6f896c56d8da7cd4214f73 (diff)
downloadorg-mode-b64f31abd236e12fd2cf699e5be8008e7a696333.tar.gz
org.el: Tiny enhancements for `org-open-at-point-global'
* lisp/org.el (org-open-at-point-global): Use `thing-at-point' to match possibly more urls and emails. Enhance docstring.
-rw-r--r--lisp/org.el28
1 files changed, 17 insertions, 11 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 9ecf271..7db7f5d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9976,18 +9976,24 @@ This is saved in case the need arises to restore it.")
;;;###autoload
(defun org-open-at-point-global ()
- "Follow a link or time-stamp like Org mode does.
-This command can be called in any mode to follow an external link
-or a time-stamp that has Org mode syntax. Its behavior is
-undefined when called on internal links (e.g., fuzzy links).
-Raise an error when there is nothing to follow. "
+ "Follow a link or a time-stamp like Org mode does.
+Also follow links and emails as seen by `thing-at-point'.
+This command can be called in any mode to follow an external
+link or a time-stamp that has Org mode syntax. Its behavior
+is undefined when called on internal links like fuzzy links.
+Raise a user error when there is nothing to follow."
(interactive)
- (cond ((org-in-regexp org-any-link-re)
- (org-open-link-from-string (match-string-no-properties 0)))
- ((or (org-in-regexp org-ts-regexp-both nil t)
- (org-in-regexp org-tsr-regexp-both nil t))
- (org-follow-timestamp-link))
- (t (user-error "No link found"))))
+ (let ((tap-url (thing-at-point 'url))
+ (tap-email (thing-at-point 'email)))
+ (cond ((org-in-regexp org-any-link-re)
+ (org-open-link-from-string (match-string-no-properties 0)))
+ ((or (org-in-regexp org-ts-regexp-both nil t)
+ (org-in-regexp org-tsr-regexp-both nil t))
+ (org-follow-timestamp-link))
+ (tap-url (org-open-link-from-string tap-url))
+ (tap-email (org-open-link-from-string
+ (concat "mailto:" tap-email)))
+ (t (user-error "No link found")))))
;;;###autoload
(defun org-open-link-from-string (s &optional arg reference-buffer)