alexluigit / dirvish

A polished Dired with batteries included.
GNU General Public License v3.0
769 stars 43 forks source link

[Bug] `'dirvish-open-with-programs` has an incorrect `'custom-type` property #193

Open hab25 opened 1 year ago

hab25 commented 1 year ago

Thank you for the bug report

Bug description

'dirvish-open-with-programs has an incorrect 'custom-type property. This prevents it from being customized via the customize interface, and fails programmatic type-checking (see the Anything else section below).

Steps to reproduce

(customize-variable 'dirvish-open-with-programs)

and see that no customization buttons specific to 'dirvish-open-with-programs show up in the customize buffer and the following message appears in the message buffer:

mapcar: Wrong type argument: symbolp, (repeat string)

OR

(widget-convert (get 'dirvish-open-with-programs 'custom-type))

and see that an error is signaled (my erro callstack is provided below).

Expected behavior

Customize buffer displays properly;

widget-convert works.

OS

Linux

Emacs Version

28

Emacs Configurations

Vanilla

Error callstack

Debugger entered--Lisp error: (wrong-type-argument symbolp (repeat string))
  widget-convert(((repeat string) :tag "File extensions"))
  mapcar(widget-convert (((repeat string) :tag "File extensions") ((repeat string) :tag "External command and args")))
  widget-types-convert-widget((cons :format "%v" :args (((repeat string) :tag "File extensions") ((repeat string) :tag "External command and args"))))
  widget-convert((cons :format "%v" ((repeat string) :tag "File extensions") ((repeat string) :tag "External command and args")))
  mapcar(widget-convert ((cons :format "%v" ((repeat string) :tag "File extensions") ((repeat string) :tag "External command and args"))))
  widget-types-convert-widget((editable-list :inline t :args ((cons :format "%v" ((repeat string) :tag "File extensions") ((repeat string) :tag "External command and args")))))
  widget-convert((editable-list :inline t (cons :format "%v" ((repeat string) :tag "File extensions") ((repeat string) :tag "External command and args"))))
  mapcar(widget-convert ((editable-list :inline t (cons :format "%v" ((repeat string) :tag "File extensions") ((repeat string) :tag "External command and args")))))
  widget-types-convert-widget((alist :key-type ((repeat string) :tag "File extensions") :value-type ((repeat string) :tag "External command and args") :args ((editable-list :inline t (cons :format "%v" ((repeat string) :tag "File extensions") ((repeat string) :tag "External command and args"))))))
  widget-convert((alist :key-type ((repeat string) :tag "File extensions") :value-type ((repeat string) :tag "External command and args")))
  eval-expression((widget-convert (custom-type 'dirvish-open-with-programs)) nil nil 127)

Anything else

I use the #'custom-type and #'custom-value-satisfies-type-p functions of cus-edit-plus (https://github.com/emacsmirror/cus-edit-plus/blob/99b16cb95e1b892e15e3091f124e0be6dd914e16/cus-edit%2B.el#L1073) to type-check any variables I set (if they have a 'custom-type property). This allows me to catch many type errors like this one. Dirvish may want to do something similar.

hab25 commented 11 months ago

I use the #'custom-type and #'custom-value-satisfies-type-p functions of cus-edit-plus (https://github.com/emacsmirror/cus-edit-plus/blob/99b16cb95e1b892e15e3091f124e0be6dd914e16/cus-edit%2B.el#L1073) to type-check any variables I set (if they have a 'custom-type property). This allows me to catch many type errors like this one. Dirvish may want to do something similar.

Emacs 29 comes with similar functionality in the form of the new setopt. I believe that therefore, my usage, as described above, has been made obsolete.