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-command-hook: wrong-number-of-arguments ... when alert package is used #6

Closed leppert closed 6 years ago

leppert commented 6 years ago

I'm getting:

Error in post-command-hook (dimmer-command-hook): (wrong-number-of-arguments (3 . 3) 0)

Any ideas? What can I provide to be helpful?

[edit: debugging revealed what appears to be an interaction with the Alert package ... so I'm renaming the issue accordingly -- Neil]

gonewest818 commented 6 years ago

Hmm. Can you please post the version of dimmer and which build of emacs?

leppert commented 6 years ago

Using the current Homebrew version of Mituharu's (by way of Railwaycat) build: https://github.com/railwaycat/homebrew-emacsmacport

GNU Emacs 25.3.1 (x86_64-apple-darwin17.0.0, Carbon Version 158 AppKit 1561)
 of 2017-10-22

Dimmer version: 20180101.1022

gonewest818 commented 6 years ago

The code never actually calls dimmer-command-hook directly, so I'm not sure how this is happening. My guesses at this point would be: (a) something unique to railwaycat (I have not tested that build) or (b) an interaction with another package in your config.

Do you mind testing with no other packages enabled, i.e. something like

$ mkdir foo
$ cd foo
$ cat <<END >Cask
(source melpa)
(depends-on "dimmer")
END
$ cask install
$ cask emacs -q --eval "(progn (require 'dimmer) (setq dimmer-percent 0.5) (dimmer-mode))"
gonewest818 commented 6 years ago

Ok, well folks on #emacs have explained to me that error can mean any function invoked by dimmer-command-hook with the wrong number of arguments can produce that error... So let me take a look through the code to see if anything jumps out at me.

gonewest818 commented 6 years ago

On a hunch, can you try evaluating each of the following in the *scratch* buffer

(dimmer-invert-p)          ; should yield t or nil
(face-foreground 'default) ; should be a  color, like "#0c0c0c"
(face-background 'default)

thanks.

leppert commented 6 years ago
(dimmer-invert-p)          ; nil
(face-foreground 'default) ; "#b4b4b4"
(face-background 'default) ; "#161616"

Giving the fresh cask env a try now.

leppert commented 6 years ago

Works just fine with a fresh env. I think you're right: must be an interaction with another package in my config. I'll poke around and see if I can track it down.

gonewest818 commented 6 years ago

...would you let me know if you figure out which package? At least I can add that information to the readme. Thanks!

leppert commented 6 years ago

@gonewest818 Disabling the Alert package fixes it for me.

https://github.com/jwiegley/alert

Not sure what the interaction is here, but simply running (require 'alert) without any further configuration is enough to cause the conflict.

gonewest818 commented 6 years ago

Ok, thank you for finding that. Looks like I can reproduce the error here...

gonewest818 commented 6 years ago

Ok, I found it.

alert.el defines a face named alert-trivial-face but it has an invalid foreground color Dark Purple that can't be converted to an rgb value. See https://github.com/jwiegley/alert/blob/master/alert.el#L402

So the wrong-number-of-arguments is where I'm computing the adjusted rgb value, and I've got a nil instead of a list of r, g, b. That should be easy to detect (and ignore), and I should be more careful about bad colors anyway. I'll also open a ticket with the other project.

In the meantime, you could override that face to be "Dark Violet" which is presumably what he meant... This works for me:

(defface alert-trivial-face
         '((t (:foreground "Dark Violet")))
         "Trivial alert face"
         :group 'alert)
(require 'alert)
leppert commented 6 years ago

Thanks!

gonewest818 commented 6 years ago

I just pushed a fix to master. When the new build appears on MELPA, grab it and let me know if you see any further interactions with alert. Thanks for the bug report!