2

Is it possible to specify that a defcustom can only take the value of a mode?

More specifically, I've got a variable that's a map from major modes to lists of strings, and I wants users to be able to configure this map. So conceptually I want something like this: (defcustom my-type-map :type '(alist :key-type 'mode :value-type '(repeat string)))

Is this possible, or do I just need to use documentation?

3

Since major modes happen to be functions, you can use the function type to allow completion of functions. There is the composite type restricted-sexp which allows you to use a predicate to allow even more specific types, however it wouldn't make much sense to use it since there is no predicate or way to determine whether a function is a major mode (despite the convention of them ending in "-mode" it could very well be a minor mode).

Therefore I'd recommend going for functions and adding a descriptive docstring instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.