commit be1a4a892352126fe8d6c7dbc0a49df70cac4cf5 parent f0200aa32c820a8314518c4762da8529958eac97 Author: Wilfred Hughes <me@wilfred.me.uk> Date: Sat, 16 Dec 2017 15:13:56 +0000 Don't crash when the underlying buffer has been killed Diffstat:
| M | helpful.el | | | 2 | ++ |
| M | test/unit-test.el | | | 11 | +++++++++++ |
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/helpful.el b/helpful.el @@ -732,6 +732,8 @@ POSITION-HEADS takes the form ((123 (defun foo)) (456 (defun bar)))." state of the current symbol." (interactive) (cl-assert (not (null helpful--sym))) + (unless (buffer-live-p helpful--associated-buffer) + (setq helpful--associated-buffer nil)) (let* ((inhibit-read-only t) (start-line (line-number-at-pos)) (start-column (current-column)) diff --git a/test/unit-test.el b/test/unit-test.el @@ -195,3 +195,14 @@ buffers lying around." ;; Don't crash on large plists using keywords. (helpful--pretty-print '(:foo foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo :bar bar))) + +(ert-deftest helpful-update-after-killing-buf () + "If we originally looked at a variable in a specific buffer, +and that buffer has been killed, handle it gracefully." + ;; Don't crash if the underlying buffer has been killed. + (let (helpful-buf) + (with-temp-buffer + (helpful-variable 'tab-width) + (setq helpful-buf (current-buffer))) + (with-current-buffer helpful-buf + (helpful-update))))