gonewest818 / dimmer.el

Interactively highlight which buffer is active by dimming the others.
GNU General Public License v3.0
267 stars 14 forks source link

Windows that match `dimmer-buffer-exclusion-regexps` never un-dim when you switch back to Emacs #43

Closed davep closed 4 years ago

davep commented 4 years ago

I have dimmer configured to ignore my NeoTree window. I'm finding that if I switch away from Emacs altogether, all buffers dim (presumably down to dimmer-watch-frame-focus-events being t -- which is fine), including those that match dimmer-buffer-exclusion-regexps. As such, even the NeoTree buffer dims (which I think makes sense).

However, when switching back, the NeoTree buffer doesn't un-dim. The upshot of this seems to be that when dimmer-watch-frame-focus-events is t, and when you switch away from Emacs and back again, any window that is a match for dimmer-buffer-exclusion-regexps will stay dim.

I'm experiencing this with:

;; Version: 0.4.2
;; Package-Version: 20200308.2331

using GNU Emacs 26.3.

gonewest818 commented 4 years ago

Hey, good catch. Thank you for this report.

I can imagine what that bug would be. The un-dimming handlers work from a buffer list that was pre-filtered with those regexps and predicates. However the "lost focus" handler dims every buffer without filtering. Solutions would be either: (a) continue dimming every buffer when focus is lost but force the re-processing of every buffer when focus is regained, or (b) filter which buffers are dimmed when focus is lost.

Option (b) is simple to do but Option (a) seems more logical to me -- if focus is completely lost then (arguably) you aren't working on any emacs buffer and they should all be dimmed.

Thoughts?

davep commented 4 years ago

Yeah, I think option (a) makes a lot more sense to me. The idea of having some buffers not dim when I'm moving around the frame, but every buffer dim when I move away from the frame to a different application or something sits well logically. I'd use it that way.

maronin commented 4 years ago

Just confirming the bug. Even having dimmer-watch-frame-focus-events set to nil doesn't work for me. All buffers still dim when I un-focus my Emacs, including the ones I said not to dim using dimmer-buffer-exclusion-regexps

davep commented 4 years ago

@maronin Did you restart Emacs after toggling dimmer-watch-frame-focus-events? I had the same effect as you when I first tried this, and the I noticed in the doc-string for that setting that a restart is required.

gonewest818 commented 4 years ago

I pushed a candidate fix for this on the "focus-fix" branch. I'll running this branch locally for a while to see if everything behaves well, and when I'm satisfied I'll merge it in.

If you happen to use a package manager like quelpa or straight, can install from this branch and check if it works for you?

davep commented 4 years ago

I generally do everything with use-package and am pulling dimmer from melpa, so not quite so straightforward. When I get some down time from work I'll see about grabbing it and installing it locally.

gonewest818 commented 4 years ago

Okay, thank you. Something like this should work:

(use-package quelpa
  :ensure t)

(use-package quelpa-use-package
  :ensure t)

(use-package dimmer
  :quelpa (dimmer
           :fetcher github
           :repo "gonewest818/dimmer.el"
           :branch "focus-fix")
  :ensure t
  :config
  ;; ... and copy your config here.
)

If you want, you can keep your existing declaration for (use-package dimmer ...) and just add a :disabled t for now. You might need to rm -rf ~/.emacs.d/elpa/dimmer-* to ensure quelpa grabs and installs this test branch.

davep commented 4 years ago

I tried getting this going (throwing "quelpa" into the mix, I mean) with my config but it caused a few problems so I've had to back out for now. Sorry. I'll try and come back to it when I next get some downtime.

gonewest818 commented 4 years ago

thank you for putting in the time. In my testing so far the fix seems stable, so that’s encouraging. I’ll keep folks updated here.

gonewest818 commented 4 years ago

I just pushed an update to the branch that fixes some cases I hadn't considered earlier. Still, things are looking good.

davep commented 4 years ago

@gonewest818 Dived in again and got quelpa working just fine with my config this time. Pulled dimmer.el from the branch you mentioned and it all looks good from here. Thanks again for this (and for the pointer to quelpa and the heads-up on how to use it to pull this version of dimmer in), very much appreciate it.

gonewest818 commented 4 years ago

I just merged the focus-fix branch to master. Wait for MELPA to pick up the change (an hour or two, typically), and then you can revert your config to retrieve from the repo. Thanks!

davep commented 4 years ago

Thanks again. Really appreciate it.