Limit `org-open-at-point'
* lisp/org.el (org-open-at-point): Do not open everything that looks like a link, in particular in verbatim or code objects. However, still conveniently open links in comments, node properties and keywords.
This commit is contained in:
parent
120f871f41
commit
d3774fba77
24
lisp/org.el
24
lisp/org.el
|
@ -10136,10 +10136,10 @@ When optional argument REFERENCE-BUFFER is non-nil, it should
|
||||||
specify a buffer from where the link search should happen. This
|
specify a buffer from where the link search should happen. This
|
||||||
is used internally by `org-open-link-from-string'.
|
is used internally by `org-open-link-from-string'.
|
||||||
|
|
||||||
On top of syntactically correct links, this function will also
|
On top of syntactically correct links, this function also tries
|
||||||
try to open links and time-stamps in comments, example
|
to open links and time-stamps in comments, node properties, and
|
||||||
blocks... i.e., whenever point is on something looking like
|
keywords if point is on something looking like a timestamp or
|
||||||
a timestamp or a link."
|
a link."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(org-load-modules-maybe)
|
(org-load-modules-maybe)
|
||||||
(setq org-window-config-before-follow-link (current-window-configuration))
|
(setq org-window-config-before-follow-link (current-window-configuration))
|
||||||
|
@ -10150,12 +10150,18 @@ a timestamp or a link."
|
||||||
;; closest one.
|
;; closest one.
|
||||||
(org-element-lineage
|
(org-element-lineage
|
||||||
(org-element-context)
|
(org-element-context)
|
||||||
'(clock footnote-definition footnote-reference headline
|
'(clock comment comment-block footnote-definition
|
||||||
inline-src-block inlinetask link src-block timestamp)
|
footnote-reference headline inline-src-block inlinetask
|
||||||
|
keyword link node-property src-block timestamp)
|
||||||
t))
|
t))
|
||||||
(type (org-element-type context))
|
(type (org-element-type context))
|
||||||
(value (org-element-property :value context)))
|
(value (org-element-property :value context)))
|
||||||
(cond
|
(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,
|
;; On a headline or an inlinetask, but not on a timestamp,
|
||||||
;; a link, a footnote reference.
|
;; a link, a footnote reference.
|
||||||
((memq type '(headline inlinetask))
|
((memq type '(headline inlinetask))
|
||||||
|
@ -10189,12 +10195,6 @@ a timestamp or a link."
|
||||||
(= (org-element-property :post-affiliated context)
|
(= (org-element-property :post-affiliated context)
|
||||||
(line-beginning-position)))))))
|
(line-beginning-position)))))))
|
||||||
(org-footnote-action))
|
(org-footnote-action))
|
||||||
;; No valid context. Ignore catch-all types like `headline'.
|
|
||||||
;; If point is on something looking like a link or
|
|
||||||
;; a time-stamp, try opening it. It may be useful in comments,
|
|
||||||
;; example blocks...
|
|
||||||
((memq type '(footnote-definition headline inlinetask nil))
|
|
||||||
(call-interactively #'org-open-at-point-global))
|
|
||||||
;; On a clock line, make sure point is on the timestamp
|
;; On a clock line, make sure point is on the timestamp
|
||||||
;; before opening it.
|
;; before opening it.
|
||||||
((and (eq type 'clock)
|
((and (eq type 'clock)
|
||||||
|
|
Loading…
Reference in New Issue