helpful

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

commit f06fe10b07c8011290488db92653beb910e7cfac
parent e6d32d519ef98389eed822052ebc1e24e5d66294
Author: Wilfred Hughes <me@wilfred.me.uk>
Date:   Thu, 29 Mar 2018 08:56:46 +0100

Handle 'info anchor' references too

Diffstat:
MCHANGELOG.md | 3+++
Mhelpful.el | 8+++++---
Mtest/unit-test.el | 24++++++++++++++++++++++++
3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md @@ -13,6 +13,9 @@ definition buffer without the user requesting it. Wording polish for finding references of primitives. +Fixed some corner cases in references to info manual sections not +being linkified. + # v0.8 Added setting `helpful-switch-buffer-function` to allow users to diff --git a/helpful.el b/helpful.el @@ -633,8 +633,10 @@ blank line afterwards." "Convert info references in docstrings to buttons." (replace-regexp-in-string ;; Replace all text of the form `foo'. - (rx "Info node" - (group (+ whitespace)) + (rx "Info " + (group + (or "anchor" "node") + (+ whitespace)) "`" (group (+ (not (in "'")))) "'") @@ -643,7 +645,7 @@ blank line afterwards." (let ((space (match-string 1 it)) (info-node (match-string 2 it))) (concat - "Info node" + "Info " space (helpful--button info-node diff --git a/test/unit-test.el b/test/unit-test.el @@ -205,6 +205,30 @@ symbol (not a form)." (should (s-contains-p "run-python" formatted)))) +(ert-deftest helpful--format-docstring--info () + "Ensure we propertize references to the info manual." + ;; This is the typical format. + (let* ((formatted (helpful--format-docstring "Info node `(elisp)foo'")) + (paren-position (s-index-of "(" formatted))) + (should + (string-equal formatted "Info node (elisp)foo")) + (should + (get-text-property paren-position 'button formatted))) + ;; Some functions, such as `signal', use 'anchor'. + (let* ((formatted (helpful--format-docstring "Info anchor `(elisp)foo'")) + (paren-position (s-index-of "(" formatted))) + (should + (string-equal formatted "Info anchor (elisp)foo")) + (should + (get-text-property paren-position 'button formatted))) + ;; Ensure we handle wrapped lines too, e.g. in `org-odt-pixels-per-inch'. + (let* ((formatted (helpful--format-docstring "Info node `(elisp)foo \nbar'")) + (paren-position (s-index-of "(" formatted))) + (should + (string-equal formatted "Info node (elisp)foo \nbar")) + (should + (get-text-property paren-position 'button formatted)))) + (ert-deftest helpful--definition-c-vars () "Handle definitions of variables in C source code." (let* ((emacs-src-path (f-join default-directory "emacs-25.3" "src")))