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

handle company-box popups properly #37

Closed gonewest818 closed 4 years ago

gonewest818 commented 4 years ago

@TheBB wrote: "Is there a company predicate suitable for the prevention list? Some company frontends pop up a child frame with another buffer (company-box for example), but company--active-p doesn't seem to do the trick."

https://www.reddit.com/r/emacs/comments/falwp7/ann_dimmerel_new_features_and_fixes_available_on/fizyhpu/

gonewest818 commented 4 years ago
(defun company--active-p ()
  company-candidates)

where

(defvar-local company-candidates nil)

If the implementation of company--active-p depends on a buffer-local variable, then the predicate will answer differently depending on the context. One thing to try, although it might be too expensive, is to walk buffer-list and test that predicate in each buffer?

(defun company--active-anywhere-p ()
  (cl-some (lambda (buf) (buffer-local-value company-candidates buf)) (buffer-list)))
TheBB commented 4 years ago

Thanks for reporting this. I was a bit slow. :-P

I got it working with this

(defun bb-dimmer-predicate ()
  (string-prefix-p " *company-box-" (buffer-name)))

It helped to realize that the predicates are evaluated after a buffer switch. Of course it's not generic enough for arbitrary child frames but it suffices for me.

gonewest818 commented 4 years ago

Glad to hear. Out of curiosity, that didn’t work as a regexp?

(add-to-list 'dimmer-exclusion-regexp-list "^ \\*company-box.*")

Or maybe even

(add-to-list 'dimmer-exclusion-regexp-list "^ \\*company-.*")

There’s a subtle difference between the dimmer regexp and the predicate functions. With the regexp you’re saying “this buffer should not be dimmed.” With the predicate you’re saying “when this predicate is true, none of the buffers should be dimmed or in-dimmed”.

TheBB commented 4 years ago

I saw that difference, so assumed it wouldn't work as expected. The problem was that the 'home' buffer was being dimmed when company popped up. Not that the company buffer itself was being dimmed.

gonewest818 commented 4 years ago

Ok, good.

On Feb 29, 2020, at 8:22 AM, Eivind Fonn notifications@github.com wrote:

I saw that difference, so assumed it wouldn't work as expected. The problem was that the 'home' buffer was being dimmed when company popped up. Not that the company buffer itself was being dimmed.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/gonewest818/dimmer.el/issues/37?email_source=notifications&email_token=AASYZ5USWVDOJRCJ33DVLATRFE25XA5CNFSM4K6BAWP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENL6ERY#issuecomment-592962119, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASYZ5SUHNL2RPP3F7NXSHDRFE25XANCNFSM4K6BAWPQ.

gonewest818 commented 4 years ago

Hey, thanks for working this out! I'm about to push an update to dimmer which provides a function dimmer-configure-company-box that implements the configuration you are using, making it easier for other company-box users in the future.