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

dimmer-configure-company-box isn't working #48

Open WhatDothLife opened 3 years ago

WhatDothLife commented 3 years ago

I just installed company-box and for me the above mentioned function doesn't prevent dimmer from dimming the current buffer I'm editing. Providing screenshots isn't possible, since it resets the dimming configuration. Is anyone able to reproduce this?

gonewest818 commented 3 years ago

My personal configuration is a bit unstable because I'm finally getting around to setting up emacs-lsp, pyls, and clangd, also upgraded to 27.1, and I'm working on Windows for the first time in years ... but let me make sure I have company-box enabled and I'll report back what happens for me.

gonewest818 commented 3 years ago

And as expected my configuration is just broken enough that I can't confirm this easily ... it's the middle of a work day and then a holiday weekend so I'll get back to you next week.

WhatDothLife commented 3 years ago

Ok, there's no hurry.

sebmiq commented 3 years ago

I've run into a (maybe) similar problem with company-posframe. The issue is that the company popup triggers window-configuration-change-hook which calls (dimmer-process-all t) with the force argument set.

I've hacked this function into the following, which fixed my issue. I haven't noticed any downsides so far (though there probably are some).

(defun dimmer-process-all (&optional force)
  "Process all buffers and dim or un-dim each.

When FORCE is true some special logic applies.  Namely, we must
process all buffers regardless of the various dimming predicates.
While performing this scan, any buffer that would have been
excluded due to the predicates before should be un-dimmed now."
  (dimmer--dbg-buffers 1 "dimmer-process-all")
  (let* ((selected (current-buffer))
         (ignore   (cl-some (lambda (f) (and (fboundp f) (funcall f)))
                            dimmer-prevent-dimming-predicates))
         (visbufs  (dimmer-visible-buffer-list))
         (filtbufs (dimmer-filtered-buffer-list visbufs)))
    (dimmer--dbg 1 "dimmer-process-all: force %s" force)
    (when (or force (not ignore))
      (dolist (buf (if force visbufs filtbufs))
        (dimmer--dbg 2 "dimmer-process-all: buf %s" buf)
        (if (or (eq buf selected)
                (and force (not (memq buf filtbufs)))
        (and (eq buf dimmer-last-buffer) (not (memq selected filtbufs)))) ;; changed
            (dimmer-restore-buffer buf)
          (dimmer-dim-buffer buf dimmer-fraction))))
    (setq dimmer-last-buffer selected))) ;; changed
gonewest818 commented 3 years ago

Somewhere along the way I added lsp, lsp-pyright and company-box to my configuration and I'm definitely seeing this. Still need to find time to address but at least I am living with the reproducible case all day long.

gonewest818 commented 3 years ago

Leaving a note here that its possible window-configuration-change-hook is too general, and what I really need to do is take a moment to inspect what specifically has changed before forcing dimmer-process-all. For instance, a size change doesn't matter, nor does a change of the buffer contents. But changing which frame or window was selected definitely does matter. That sort of thing.

https://www.gnu.org/software/emacs/manual/html_node/elisp/Window-Hooks.html