helpful

a fork of Wilfred's helpful
git clone https://git.trogloxene.org/helpful.git
Log | Files | Refs | README

commit 83b915b88f5a50abe496be23112e23a608949eef
parent 99ee4bec41c7fc82c3f96c54ca79fa649451074e
Author: Wilfred Hughes <me@wilfred.me.uk>
Date:   Tue, 19 Jun 2018 00:16:07 +0100

Handle another docstring URL syntax

Diffstat:
MCHANGELOG.md | 2++
Mhelpful.el | 4++--
Mtest/unit-test.el | 7+++++++
3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md @@ -14,6 +14,8 @@ prompted about file variables. Fixed a crash when a docstring referenced a non-existent keymap. +Linkify docstring URLs of the form `<http://foo>`. + # v0.10 When visiting a reference, the occurrences of the symbol are diff --git a/helpful.el b/helpful.el @@ -883,10 +883,10 @@ unescaping too." (defun helpful--propertize-bare-links (docstring) "Convert URL links in docstrings to buttons." (replace-regexp-in-string - (rx (group (or string-start space)) + (rx (group (or string-start space "<")) (group "http" (? "s") "://" (+? (not (any space)))) (group (? (any "." ">" ")")) - (or space string-end))) + (or space string-end ">"))) (lambda (match) (let ((space-before (match-string 1 match)) (url (match-string 2 match)) diff --git a/test/unit-test.el b/test/unit-test.el @@ -269,6 +269,13 @@ symbol (not a form)." (should (equal (get-text-property url-position 'url formatted) + "http://example.com"))) + ;; Format markdown-style links. + (let* ((formatted (helpful--format-docstring "See <http://example.com>.")) + (url-position (s-index-of "h" formatted))) + (should + (equal + (get-text-property url-position 'url formatted) "http://example.com")))) (ert-deftest helpful--definition-c-vars ()