org.el (org-open-at-point): Also open links in comment blocks
* org.el (org-open-at-point): Also open links in comment blocks.
This commit is contained in:
parent
44aaaad8c0
commit
8b7b2f6600
37
lisp/org.el
37
lisp/org.el
|
@ -10621,8 +10621,8 @@ 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 open
|
On top of syntactically correct links, this function will open
|
||||||
the link at point in comments and the first link in a property
|
the link at point in comments or comment blocks and the first
|
||||||
drawer line."
|
link in a property drawer line."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
;; On a code block, open block's results.
|
;; On a code block, open block's results.
|
||||||
(unless (call-interactively 'org-babel-open-src-block-result)
|
(unless (call-interactively 'org-babel-open-src-block-result)
|
||||||
|
@ -10635,7 +10635,8 @@ drawer line."
|
||||||
;; On an unsupported type, check if point is contained within
|
;; On an unsupported type, check if point is contained within
|
||||||
;; a support one.
|
;; a support one.
|
||||||
(while (and (not (memq (setq type (org-element-type context))
|
(while (and (not (memq (setq type (org-element-type context))
|
||||||
'(comment headline inlinetask link
|
'(comment comment-block
|
||||||
|
headline inlinetask link
|
||||||
footnote-definition footnote-reference
|
footnote-definition footnote-reference
|
||||||
node-property timestamp)))
|
node-property timestamp)))
|
||||||
(setq context (org-element-property :parent context))))
|
(setq context (org-element-property :parent context))))
|
||||||
|
@ -10649,20 +10650,22 @@ drawer line."
|
||||||
(and (string-match org-any-link-re value)
|
(and (string-match org-any-link-re value)
|
||||||
(match-string-no-properties 0 value))))
|
(match-string-no-properties 0 value))))
|
||||||
;; Exception n°2: links in comments.
|
;; Exception n°2: links in comments.
|
||||||
((eq type 'comment)
|
((memq type '(comment comment-block))
|
||||||
(let ((string-rear (replace-regexp-in-string
|
(save-excursion
|
||||||
"^[ \t]*# [ \t]*" ""
|
(skip-chars-forward "\\S-" (point-at-eol))
|
||||||
(buffer-substring (point) (line-beginning-position))))
|
(let ((string-rear (replace-regexp-in-string
|
||||||
(string-front (buffer-substring (point) (line-end-position))))
|
"^[ \t]*# [ \t]*" ""
|
||||||
(with-temp-buffer
|
(buffer-substring (point) (line-beginning-position))))
|
||||||
(let ((org-inhibit-startup t)) (org-mode))
|
(string-front (buffer-substring (point) (line-end-position))))
|
||||||
(insert value)
|
(with-temp-buffer
|
||||||
(goto-char (point-min))
|
(let ((org-inhibit-startup t)) (org-mode))
|
||||||
(when (and (search-forward string-rear nil t)
|
(insert value)
|
||||||
(search-forward string-front (line-end-position) t))
|
(goto-char (point-min))
|
||||||
(goto-char (match-beginning 0))
|
(when (and (search-forward string-rear nil t)
|
||||||
(org-open-at-point)
|
(search-forward string-front (line-end-position) t))
|
||||||
(when (string= string-rear "") (forward-char))))))
|
(goto-char (match-beginning 0))
|
||||||
|
(org-open-at-point)
|
||||||
|
(when (string= string-rear "") (forward-char)))))))
|
||||||
;; 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 or on tags.
|
;; a link, a footnote reference or on tags.
|
||||||
((and (memq type '(headline inlinetask))
|
((and (memq type '(headline inlinetask))
|
||||||
|
|
Loading…
Reference in New Issue