summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2014-07-28 15:40:49 +0200
committerBastien Guerry <bzg@altern.org>2014-07-28 15:40:49 +0200
commit8b7b2f6600b89f612485d5c2aa3552bfd2eb57a1 (patch)
treebac6246ae0b8226c64007d22bd4cbb3a7cd8cb34
parent44aaaad8c0e347fdfd724090d598ad3a9153058c (diff)
downloadorg-mode-8b7b2f6600b89f612485d5c2aa3552bfd2eb57a1.tar.gz
org.el (org-open-at-point): Also open links in comment blocks
* org.el (org-open-at-point): Also open links in comment blocks.
-rw-r--r--lisp/org.el37
1 files changed, 20 insertions, 17 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 825d76c..cd52535 100644
--- a/lisp/org.el
+++ b/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'.
On top of syntactically correct links, this function will open
-the link at point in comments and the first link in a property
-drawer line."
+the link at point in comments or comment blocks and the first
+link in a property drawer line."
(interactive "P")
;; On a code block, open block's results.
(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
;; a support one.
(while (and (not (memq (setq type (org-element-type context))
- '(comment headline inlinetask link
+ '(comment comment-block
+ headline inlinetask link
footnote-definition footnote-reference
node-property timestamp)))
(setq context (org-element-property :parent context))))
@@ -10649,20 +10650,22 @@ drawer line."
(and (string-match org-any-link-re value)
(match-string-no-properties 0 value))))
;; Exception n°2: links in comments.
- ((eq type 'comment)
- (let ((string-rear (replace-regexp-in-string
- "^[ \t]*# [ \t]*" ""
- (buffer-substring (point) (line-beginning-position))))
- (string-front (buffer-substring (point) (line-end-position))))
- (with-temp-buffer
- (let ((org-inhibit-startup t)) (org-mode))
- (insert value)
- (goto-char (point-min))
- (when (and (search-forward string-rear nil t)
- (search-forward string-front (line-end-position) t))
- (goto-char (match-beginning 0))
- (org-open-at-point)
- (when (string= string-rear "") (forward-char))))))
+ ((memq type '(comment comment-block))
+ (save-excursion
+ (skip-chars-forward "\\S-" (point-at-eol))
+ (let ((string-rear (replace-regexp-in-string
+ "^[ \t]*# [ \t]*" ""
+ (buffer-substring (point) (line-beginning-position))))
+ (string-front (buffer-substring (point) (line-end-position))))
+ (with-temp-buffer
+ (let ((org-inhibit-startup t)) (org-mode))
+ (insert value)
+ (goto-char (point-min))
+ (when (and (search-forward string-rear nil t)
+ (search-forward string-front (line-end-position) t))
+ (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,
;; a link, a footnote reference or on tags.
((and (memq type '(headline inlinetask))