I am using
repeat for now. But I don't know how to have the same for
EDIT: I want INS and DEL options like in
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
restricted-sexp. It accepts a Lisp value that must fit the
:match-alternatives restriction that you specify -- in this case that the value must satisfy
vectorp and each of the vector's elements must satisfy
(defcustom foo ["a" "bb" "ccc"] "Foo's doc." :type '(restricted-sexp :tag "Vector" :match-alternatives (lambda (xs) (and (vectorp xs) (seq-every-p #'stringp xs)))) :group 'convenience)
See the Elisp manual, node Composite Types.
If you want to specify a fixed vector length then you can use a
(vector string string string) etc. instead.
restricted-sexp doesn't satisfy you (e.g., because you don't get
DEL buttons) then you can define your own custom type - see (elisp) Defining New Types.
Another possibility, if you really want
DEL buttons, is to define the option value as a list, using
repeat, and then in your code that uses it convert to a vector. In that case, be sure to use
defcustom (with a setter that converts the new list value to a vector), so that whenever someone customizes the value you reconvert list to vector.
When I say "convert", I mean that you would have the option for a list value and a separate, internal variable for that list value converted to a vector. Users would see
DEL in Customize, and would thus configure a list value, but you would have a
:set function on the
defcustom which would both (1) set the option value according to the user's edit (as usual, using the default setter function) and (2) set the internal variable's value to the new value of the option, after converting that new list value to a vector.
(defcustom my-opt '("a" "bb" "ccc") "`my-opt's doc." :type '(repeat string) :group 'convenience :set (lambda (sym defs) (custom-set-default sym defs) (setq my-var (vconcat my-opt)))) (defvar my-var  "`my-var's doc.")
repeat is only for lists, and it is the only predefined
:type construct that gives you
DEL buttons. The doc explicitly calls out these buttons in its description of