jdtsmith / indent-bars

Fast, configurable indentation guide-bars for Emacs
GNU General Public License v3.0
272 stars 7 forks source link

`Debugger entered--Lisp error: (error "Selecting deleted buffer") ` from `(indent-bars--cleanup-stipple-remaps #<killed buffer>)` #44

Closed hab25 closed 2 months ago

hab25 commented 2 months ago

Unfortunately, not sure what the conditions to reproduce this are.

I think it might have to do with consult-recent-file which makes temporary buffers that do run prog-mode-hook (from which I call (indent-bars-mode)). However, I was unable to consistently reproduce.

Nonetheless, it's probably trivially-implemented good practice (at least because it'll avoid similar issues) to just cancel this https://github.com/jdtsmith/indent-bars/blob/4974f6c16c7fcc8bbe53fbcd93c74794877287a1/indent-bars.el#L1394C5-L1396C79 timer on kill-buffer-hook, no?

Here's a backtrace (n.b. I use a few customizations to backtrace, the most notable being (setopt backtrace-view '(:show-flags t :show-locals t)); if it is unintelligible I can probably provide it uncustomized):

Debugger entered--Lisp error: (error "Selecting deleted buffer")

(indent-bars--cleanup-stipple-remaps #<killed buffer>)

debugger-may-continue = t

inhibit-redisplay = nil

inhibit-debugger = t

inhibit-changing-match-data = nil

(apply indent-bars--cleanup-stipple-remaps #<killed buffer>)

[no locals]
(#[128 "\302\301\303\300\4\"\"\207"
       [(#<killed buffer>)
        indent-bars--cleanup-stipple-remaps
        apply
        append]
       6 "\n\n(fn &rest ARGS2)"])

[no locals]
(apply #[128 \302\301\303\300 "" \207
             [(#<killed buffer>)
              indent-bars--cleanup-stipple-remaps
              apply
              append]
             6

             (fn &rest ARGS2)]
       nil)

[no locals]
(timer-event-handler
 [t
  0 1 0 nil
  #[128 \302\301\303\300 "" \207
        [(#<killed buffer>)
         indent-bars--cleanup-stipple-remaps
         apply
         append]
        6

        (fn &rest ARGS2)]
  nil idle 0 nil])

inhibit-quit = t
jdtsmith commented 2 months ago

I pushed a small change to guard against this; please give it a test.

hab25 commented 2 months ago

@jdtsmith thank you; I've noticed no problems with it so far. Will report back if I do.

hab25 commented 1 month ago

@jdtsmith I encountered the same error from the same function again; I think the last expression in that function, i.e. (setf (buffer-local-value 'indent-bars--needs-cleanup buf) nil) needs to be moved into the when-let so that it is not called with a killed buffer.

jdtsmith commented 1 month ago

Good catch, check 48c8f7e.