gonewest818/dimmer.el

dimmer-command-hook: wrong-number-of-arguments ... when alert package is used

Closed this issue · 13 comments

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]

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

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

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))"

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.

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.

(dimmer-invert-p)          ; nil
(face-foreground 'default) ; "#b4b4b4"
(face-background 'default) ; "#161616"

Giving the fresh cask env a try now.

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.

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

@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.

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

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)

Thanks!

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!