Function: org-open-at-point
org-open-at-point is an interactive and byte-compiled function defined
in org.el.gz.
Signature
(org-open-at-point &optional ARG)
Documentation
Open thing at point.
The thing can be a link, citation, timestamp, footnote, src-block or tags.
When point is on a link, follow it. Normally, files will be opened by
an appropriate application (see org-file-apps). If the optional prefix
argument ARG is non-nil, Emacs will visit the file. With a double
prefix argument, try to open outside of Emacs, in the application the
system uses for this file type.
When point is on a timestamp, open the agenda at the day specified.
When point is a footnote definition, move to the first reference found. If it is on a reference, move to the associated definition.
When point is on a src-block of inline src-block, open its result.
When point is on a citation, follow it.
When point is on a headline, display a list of every link in the
entry, so it is possible to pick one, or all, of them. If point
is on a tag, call org-tags-view instead.
On top of syntactically correct links, this function also tries to open links and timestamps in comments, node properties, and keywords if point is on something looking like a timestamp or a link.
This function has :around advice: org--mouse-open-at-point.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-open-at-point (&optional arg)
"Open thing at point.
The thing can be a link, citation, timestamp, footnote, src-block or
tags.
When point is on a link, follow it. Normally, files will be opened by
an appropriate application (see `org-file-apps'). If the optional prefix
argument ARG is non-nil, Emacs will visit the file. With a double
prefix argument, try to open outside of Emacs, in the application the
system uses for this file type.
When point is on a timestamp, open the agenda at the day
specified.
When point is a footnote definition, move to the first reference
found. If it is on a reference, move to the associated
definition.
When point is on a src-block of inline src-block, open its result.
When point is on a citation, follow it.
When point is on a headline, display a list of every link in the
entry, so it is possible to pick one, or all, of them. If point
is on a tag, call `org-tags-view' instead.
On top of syntactically correct links, this function also tries
to open links and timestamps in comments, node properties, and
keywords if point is on something looking like a timestamp or
a link."
(interactive "P")
(org-load-modules-maybe)
(setq org-window-config-before-follow-link (current-window-configuration))
(org-remove-occur-highlights nil nil t)
(unless (run-hook-with-args-until-success 'org-open-at-point-functions)
(let* ((context
;; Only consider supported types, even if they are not the
;; closest one.
(org-element-lineage
(org-element-context)
'(citation citation-reference clock comment comment-block
footnote-definition footnote-reference headline
inline-src-block inlinetask keyword link node-property
planning src-block timestamp)
t))
(type (org-element-type context))
(value (org-element-property :value context)))
(cond
((not type) (user-error "No link found"))
;; No valid link at point. For convenience, look if something
;; looks like a link under point in some specific places.
((memq type '(comment comment-block node-property keyword))
(call-interactively #'org-open-at-point-global))
;; On a headline or an inlinetask, but not on a timestamp,
;; a link, a footnote reference or a citation.
((memq type '(headline inlinetask))
(org-match-line org-complex-heading-regexp)
(let ((tags-beg (match-beginning 5))
(tags-end (match-end 5)))
(if (and tags-beg (>= (point) tags-beg) (< (point) tags-end))
;; On tags.
(org-tags-view
arg
(save-excursion
(let* ((beg-tag (or (search-backward ":" tags-beg 'at-limit) (point)))
(end-tag (search-forward ":" tags-end nil 2)))
(buffer-substring (1+ beg-tag) (1- end-tag)))))
;; Not on tags.
(pcase (org-offer-links-in-entry (current-buffer) (point) arg)
(`(nil . ,_)
(require 'org-attach)
(when (org-attach-dir)
(message "Opening attachment")
(if (equal arg '(4))
(org-attach-reveal-in-emacs)
(org-attach-reveal))))
(`(,links . ,links-end)
(let ((link-marker (make-marker))
(last-moved-marker (point-marker)))
(dolist (link (if (stringp links) (list links) links))
(search-forward link nil links-end)
(goto-char (match-beginning 0))
(move-marker link-marker (point))
(save-excursion
(org-open-at-point arg)
(unless (equal (point-marker) link-marker)
(move-marker last-moved-marker (point-marker)))))
;; If any of the links moved point in current buffer,
;; move to the point corresponding to such latest link.
;; Otherwise, restore the original point position.
(goto-char last-moved-marker)))))))
;; On a footnote reference or at definition's label.
((or (eq type 'footnote-reference)
(and (eq type 'footnote-definition)
(save-excursion
;; Do not validate action when point is on the
;; spaces right after the footnote label, in order
;; to be on par with behavior on links.
(skip-chars-forward " \t")
(let ((begin
(org-element-contents-begin context)))
(if begin (< (point) begin)
(= (org-element-post-affiliated context)
(line-beginning-position)))))))
(org-footnote-action))
;; On a planning line. Check if we are really on a timestamp.
((and (eq type 'planning)
(org-in-regexp org-ts-regexp-both nil t))
(org-follow-timestamp-link))
;; On a clock line, make sure point is on the timestamp
;; before opening it.
((and (eq type 'clock)
value
(>= (point) (org-element-begin value))
(<= (point) (org-element-end value)))
(org-follow-timestamp-link))
((eq type 'src-block) (org-babel-open-src-block-result))
;; Do nothing on white spaces after an object.
((>= (point)
(save-excursion
(goto-char (org-element-end context))
(skip-chars-backward " \t")
(point)))
(user-error "No link found"))
((eq type 'inline-src-block) (org-babel-open-src-block-result))
((eq type 'timestamp) (org-follow-timestamp-link))
((eq type 'link) (org-link-open context arg))
((memq type '(citation citation-reference)) (org-cite-follow context arg))
(t (user-error "No link found")))))
(run-hook-with-args 'org-follow-link-hook))