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

bug: defcustom's :key-value should be :value-type #614

Closed
1 task done
shirakami-chigusa opened this issue Jul 9, 2024 · 3 comments
Closed
1 task done

bug: defcustom's :key-value should be :value-type #614

shirakami-chigusa opened this issue Jul 9, 2024 · 3 comments

Comments

@shirakami-chigusa
Copy link

shirakami-chigusa commented Jul 9, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Issue description

When I try to change custom values ​​using setopt in init.el, I get a warning.

setopt also checks whether the value is valid for the user option. For instance, using setopt to set a user option defined with a number type to a string will signal an error.

GNU Emacs Lisp Reference Manual - setopt

  (setopt
   meow-selection-command-fallback
   '((meow-change . meow-change-char)
     (meow-kill . meow-kill-whole-line)
     (meow-cancel-selection . keyboard-quit)
     (meow-pop-selection . meow-pop-grab)
     (meow-beacon-change . meow-beacon-change-char)))

⛔ Warning (emacs): Value '(((meow-change . meow-change-char) (meow-kill . meow-kill-whole-line) (meow-cancel-selection . keyboard-quit) (meow-pop-selection . meow-pop-grab) (meow-beacon-change . meow-beacon-change-char)))' for 'meow-selection-command-fallback' does not match type (alist :key-type (function :tag Command) :key-value (function :tag Fallback))

meow/meow-var.el

Lines 49 to 58 in bc05b04

(defcustom meow-selection-command-fallback
'((meow-change . meow-change-char)
(meow-kill . meow-C-k)
(meow-cancel-selection . keyboard-quit)
(meow-pop-selection . meow-pop-grab)
(meow-beacon-change . meow-beacon-change-char))
"Fallback commands for selection commands when there is no available selection."
:group 'meow
:type '(alist :key-type (function :tag "Command")
:key-value (function :tag "Fallback")))

I think :key-value is wrong and :value-type is correct.

Composite Types (GNU Emacs Lisp Reference Manual)

(alist :key-type key-type :value-type value-type)

All defcustom defined in meow-var.el have the same problem.

@eshrh eshrh closed this as completed in 552412f Jul 9, 2024
@eshrh
Copy link
Member

eshrh commented Jul 9, 2024

I can't actually reproduce this exact error... i think it's because the value-type defaults to "sexp" if not specified. What version of emacs are you using?

Anyway, good catch, thanks!

@shirakami-chigusa
Copy link
Author

shirakami-chigusa commented Jul 10, 2024

I'm using Emacs 29.3 (setopt is a feature implemented in emacs 29.1, setopt does type checking).

https://github.com/emacs-mirror/emacs/blob/ae8f815613c2e072e92aa8fe7b4bcf2fdabc7408/lisp/cus-edit.el#L1051-L1078

defcustom values from all other packages can be used without warning.

I think There is no type called :key-value.
value-type is a expected type name. Is there the type :key-value?

Composite Types (GNU Emacs Lisp Reference Manual)

@shirakami-chigusa
Copy link
Author

shirakami-chigusa commented Jul 10, 2024

i think it's because the value-type defaults to "sexp" if not specified.

Ah, I found out why the warning appeared.

The code that causes the warning is as follows:

 (setopt meow-selection-command-fallback
   '((meow-change . meow-change-char)
     (meow-kill . meow-kill-whole-line)
     (meow-cancel-selection . keyboard-quit)
     (meow-pop-selection . meow-pop-grab)
     (meow-beacon-change . meow-beacon-change-char)))
 (require 'meow)

The correct code is below.

 (require 'meow)
 (setopt meow-selection-command-fallback
   '((meow-change . meow-change-char)
     (meow-kill . meow-kill-whole-line)
     (meow-cancel-selection . keyboard-quit)
     (meow-pop-selection . meow-pop-grab)
     (meow-beacon-change . meow-beacon-change-char)))

Because I used setopt before require, the defcustom type definitions were not loaded yet.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants