diff options
| author | Wilfred Hughes <me@wilfred.me.uk> | 2018-04-07 11:50:45 +0100 |
|---|---|---|
| committer | Wilfred Hughes <me@wilfred.me.uk> | 2018-04-07 11:51:07 +0100 |
| commit | fe126eac03e510a47a12dc468f0be70d024e130e (patch) | |
| tree | bd2ceca8e4b5fe9753526ed182792b8b9a13ca4d /helpful.el | |
| parent | 64dee8141ccb47494dc469153ff6447ade948646 (diff) | |
Also linkify bare URLs
Diffstat (limited to 'helpful.el')
| -rw-r--r-- | helpful.el | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -835,6 +835,7 @@ unescaping too." (helpful--split-first-line) (helpful--propertize-info) (helpful--propertize-links) + (helpful--propertize-bare-links) (helpful--propertize-keywords) (helpful--propertize-quoted) (s-trim))) @@ -857,6 +858,26 @@ unescaping too." 'url url)))) docstring)) +(defun helpful--propertize-bare-links (docstring) + "Convert URL links in docstrings to buttons." + (replace-regexp-in-string + (rx (group (or string-start space)) + (group "http" (? "s") "://" (+? (not (any space)))) + (group (? (any "." ">" ")")) + (or space string-end))) + (lambda (match) + (let ((space-before (match-string 1 match)) + (url (match-string 2 match)) + (after (match-string 3 match))) + (concat + space-before + (helpful--button + url + 'helpful-link-button + 'url url) + after))) + docstring)) + (defun helpful--follow-link (button) "Follow the URL specified by BUTTON." (browse-url (button-get button 'url))) |
