helpful

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

commit eb27d77e35f19b2b2e31d6954d57b446f8864559
parent baf708581c6414277f048881e03438477d3e64ca
Author: Wilfred Hughes <me@wilfred.me.uk>
Date:   Sun, 10 Dec 2017 23:52:09 +0000

Don't crash on edebugged functions

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

diff --git a/CHANGELOG.md b/CHANGELOG.md @@ -12,7 +12,8 @@ Ensure we can find (and jump to) the definition of functions even if the source buffer has narrowing in effect. Fixed an issue where calling helpful commands on interactively defined -functions would overwrite unrelated buffers. +functions would overwrite unrelated buffers. Fixed a crash with +interactively defined functions being edebugged. # v0.3 diff --git a/helpful.el b/helpful.el @@ -415,7 +415,7 @@ for killing the newly created buffer." (unless buf-and-pos ;; If it's defined interactively, it may have an edebug property ;; that tells us where it's defined. - (-when-let (marker (get sym 'edebug)) + (-when-let (marker (car (get sym 'edebug))) (setq buf-and-pos (cons (marker-buffer marker) (marker-position marker)))))) diff --git a/test/unit-test.el b/test/unit-test.el @@ -1,4 +1,5 @@ (require 'ert) +(require 'edebug) (require 'helpful) (defun test-foo () @@ -47,6 +48,16 @@ (helpful-function #'test-foo-defined-interactively) (should (equal (buffer-name) "*helpful function: test-foo-defined-interactively*")))) +(ert-deftest helpful--edebug-fn () + "We should not crash on a function with edebug enabled." + (let ((edebug-all-forms t) + (edebug-all-defs t)) + (with-temp-buffer + (insert "(defun test-foo-edebug () 44)") + (goto-char (point-min)) + (eval (eval-sexp-add-defvars (edebug-read-top-level-form)) t))) + (helpful-function #'test-foo-edebug)) + (defun test-foo-usage-docstring () "\n\n(fn &rest ARGS)" nil)