Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
davep opened this issue Mar 16, 2020 · 13 comments
Assignees
Labels
bug a feature isn't working

Comments

@davep
Copy link

davep commented Mar 16, 2020

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.

davep added a commit to davep/.emacs.d that referenced this issue Mar 16, 2020
This is a temporary change as there appears to be a small issue in dimmer.el
where, when switching away from the frame, all windows get dimmed (which is
fair -- I can see this making sense and I like the idea), but when switching
back, all windows that are configured to be ignored by dimmer don't get
un-dimmed.

See gonewest818/dimmer.el#43 for the issue I
raised about this.
@gonewest818
Copy link
Owner

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
Copy link
Author

davep commented Mar 16, 2020

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.

@gonewest818 gonewest818 added the bug a feature isn't working label Mar 16, 2020
@maronin
Copy link

maronin commented Mar 18, 2020

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
Copy link
Author

davep commented Mar 18, 2020

@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 added a commit that referenced this issue Mar 23, 2020
This is a candidate fix for #43.

When regaining focus, we need to force the processing of all buffers
and restore not only the current buffer, but also every buffer that
was previously filtered due to the dimmer predicates.
@gonewest818
Copy link
Owner

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?

@gonewest818 gonewest818 self-assigned this Mar 23, 2020
@davep
Copy link
Author

davep commented Mar 23, 2020

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
Copy link
Owner

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 added a commit to davep/.emacs.d that referenced this issue Mar 24, 2020
@davep
Copy link
Author

davep commented Mar 24, 2020

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
Copy link
Owner

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
Copy link
Owner

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

davep added a commit to davep/.emacs.d that referenced this issue Mar 26, 2020
Backing out f56ba1e now that I'm running
with the version of dimmer.el that has the fix.

gonewest818/dimmer.el#43
@davep
Copy link
Author

davep commented Mar 26, 2020

@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 added a commit that referenced this issue Mar 29, 2020
fix #43

When regaining focus, force the processing of all buffers to restore
to "undimmed" the current buffer as well as every buffer that was
previously filtered by dimmer predicates.
@gonewest818
Copy link
Owner

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
Copy link
Author

davep commented Mar 29, 2020

Thanks again. Really appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug a feature isn't working
Projects
None yet
Development

No branches or pull requests

3 participants