3

I have a defcustom with :type variable, and I would like to constrain the variable name to comply to a pattern.

How would I do that?

for instance let say I want the custom to only accept a variable name starting with some prefix.

Drew
  • 75,699
  • 9
  • 109
  • 225
AdrieanKhisbe
  • 209
  • 1
  • 10

1 Answers1

4

Don't use type variable. Use type restricted-sexp.

The predicate checks for a symbolp that is boundp (i.e., a variable) and whose symbol-name is matched by your chosen prefix.

See the Elisp manual, node Composite Types.

Drew
  • 75,699
  • 9
  • 109
  • 225