From a7d2098dfd71f948340f63bb4ba84115725529e3 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Sun, 3 Mar 2019 23:12:27 +0000 Subject: Fix docstring rendering when keymap references have their own line Previously, we'd render "\\\n" as "\n", leading to an unwanted blank line in the output. See `org-capture` (on MELPA) for an example. --- CHANGELOG.md | 3 ++- helpful.el | 3 ++- test/helpful-unit-test.el | 11 +++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a65421..b2d4866 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # v0.17 (unreleased) -No changes yet. +Fixed a minor docstring formatting issue when keymap references were +on their own line. # v0.16 diff --git a/helpful.el b/helpful.el index 171b84b..05239f0 100644 --- a/helpful.el +++ b/helpful.el @@ -972,7 +972,8 @@ unescaping too." (forward-char 1)) ((looking-at ;; Text of the form \\ - (rx "\\<" (group (+ (not (in ">")))) ">")) + (rx "\\<" (group (+ (not (in ">")))) ">" + (? "\n"))) (let* ((symbol-with-parens (match-string 0)) (symbol-name (match-string 1))) ;; Remove the original string. diff --git a/test/helpful-unit-test.el b/test/helpful-unit-test.el index 0e660bb..b2653e4 100644 --- a/test/helpful-unit-test.el +++ b/test/helpful-unit-test.el @@ -75,6 +75,17 @@ (should (string-equal formatted-docstring "M-n")))) +(ert-deftest helpful--docstring-keymap-newline () + "If a keymap reference is on its own line, remove the entire line." + (should + (string-equal + (helpful--format-docstring "Foo. +\\ +bar") + "Foo. + +bar"))) + (ert-deftest helpful--docstring-advice () "Get the docstring on advised functions." (should -- cgit v1.0