From 4718b6f77daa4aa3ea15f35e9d2ff392df0f0573 Mon Sep 17 00:00:00 2001 From: kovan Date: Fri, 27 Feb 2026 01:16:30 +0100 Subject: [PATCH] feat: render implicit Info node references as clickable buttons Backtick-quoted Info node references like `(elisp)Foo Bar' now render as clickable buttons that open the corresponding Info page, matching the behavior of describe-function. Fix: #362 Co-authored-by: Claude Opus 4.6 --- helpful.el | 14 ++++++++++++++ test/helpful-unit-test.el | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/helpful.el b/helpful.el index 9516e46..51247fe 100644 --- a/helpful.el +++ b/helpful.el @@ -1081,6 +1081,20 @@ unescaping too." ((s-contains-p "\\[" contents) (delete-region start-pos end-pos) (insert (helpful--format-commands contents keymap))) + ;; Implicit Info node references like `(elisp)Foo Bar'. + ;; These appear in docstrings and should be rendered as + ;; clickable links, matching describe-function behavior. + ((string-match + (rx string-start + "(" (group (one-or-more (not (any ")")))) ")" + (group (one-or-more anything)) + string-end) + contents) + (delete-region start-pos end-pos) + (insert (helpful--button + contents + 'helpful-info-button + 'info-node contents))) ;; Highlight a normal `foo', extracting the surrounding ;; text so we can detect e.g. "function `foo'". (t diff --git a/test/helpful-unit-test.el b/test/helpful-unit-test.el index bdfdfc1..1b20b0a 100644 --- a/test/helpful-unit-test.el +++ b/test/helpful-unit-test.el @@ -114,6 +114,21 @@ bar") bar"))) +(ert-deftest helpful--docstring-info-node () + "Implicit Info node references should become buttons." + ;; A backtick-quoted Info node reference like `(elisp)Foo Bar' + ;; should be rendered as a clickable button. + (let* ((formatted (helpful--format-docstring "`(elisp)Foo Bar'"))) + (should (equal formatted "(elisp)Foo Bar")) + (should (get-text-property 0 'button formatted))) + ;; A reference with a different manual should also work. + (let* ((formatted (helpful--format-docstring "`(cl)Loop Facility'"))) + (should (equal formatted "(cl)Loop Facility")) + (should (get-text-property 0 'button formatted))) + ;; Regular symbol references should not be affected. + (let* ((formatted (helpful--format-docstring "`message'"))) + (should (equal formatted "message")))) + (ert-deftest helpful--docstring-advice () "Get the docstring on advised functions." (should