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.
This commit is contained in:
Bastien 2018-04-26 21:50:37 +02:00
parent d561b3d0b9
commit b64f31abd2
1 changed files with 17 additions and 11 deletions

View File

@ -9976,18 +9976,24 @@ This is saved in case the need arises to restore it.")
;;;###autoload ;;;###autoload
(defun org-open-at-point-global () (defun org-open-at-point-global ()
"Follow a link or time-stamp like Org mode does. "Follow a link or a time-stamp like Org mode does.
This command can be called in any mode to follow an external link Also follow links and emails as seen by `thing-at-point'.
or a time-stamp that has Org mode syntax. Its behavior is This command can be called in any mode to follow an external
undefined when called on internal links (e.g., fuzzy links). link or a time-stamp that has Org mode syntax. Its behavior
Raise an error when there is nothing to follow. " is undefined when called on internal links like fuzzy links.
Raise a user error when there is nothing to follow."
(interactive) (interactive)
(cond ((org-in-regexp org-any-link-re) (let ((tap-url (thing-at-point 'url))
(org-open-link-from-string (match-string-no-properties 0))) (tap-email (thing-at-point 'email)))
((or (org-in-regexp org-ts-regexp-both nil t) (cond ((org-in-regexp org-any-link-re)
(org-in-regexp org-tsr-regexp-both nil t)) (org-open-link-from-string (match-string-no-properties 0)))
(org-follow-timestamp-link)) ((or (org-in-regexp org-ts-regexp-both nil t)
(t (user-error "No link found")))) (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 ;;;###autoload
(defun org-open-link-from-string (s &optional arg reference-buffer) (defun org-open-link-from-string (s &optional arg reference-buffer)