Emacs lisp: type "Falling" for defcustom.

TL DR

Is there some kind of standard reverse processing in the customize system to handle partially invalid composite settings variables, for example. alist where one entry is not a minus?

Long version

The emacs configuration mechanism is powerful enough using compound arguments :type for defcustom provides an excellent unified interface for setting variables.

However, when for some reason one variable entry is incorrect, the whole system breaks up and it just shows the bare s-expressions. Then there is no help in correcting this expectation for deleting settings, hoping that the default value matches the type description.

At least this is what I have experienced so far.

If I have a configuration variable that is complex structure information, is there some mechanism that allows me to show only the damaged part of the variable as a bare s-expression?

Think for example. about

 (defcustom x '((org-mode . "a\\|b") (text-mode . "b\\|c")) "Some variable" :group 'x :type '(repeat (cons :tag "Entry" (function :tag "Mode" :value text-mode) (regexp)))) 

Normally, Mx customize-variable x does not display a nice input mask.

 Hide X: INS DEL Entry: Mode: org-mode Regexp: a\|b INS DEL Entry: Mode: text-mode Regexp: b\|c INS State : STANDARD. Some variable Groups: X 

When i do now

 (add-to-list 'x 1) 

the mask becomes significantly less user friendly

 Hide x: '(1 (org-mode . "a\\|b") (text-mode . "b\\|c")) State : CHANGED outside Customize. (mismatch) Some variable Groups: X 

Now, of course, I can enable the fallback option by changing the definition somehow like

 (defcustom x '((org-mode . "a\\|b") (text-mode . "b\\|c")) "Some variable" :group 'x :type '(repeat (choice (cons :tag "Entry" (function :tag "Mode" :value text-mode) (regexp)) (sexp :tag "MISMATCHED ENTRY!")))) 

which gives a settings mask

 Hide X: INS DEL Choice: Value Menu MISMATCHED ENTRY!: 1 INS DEL Choice: Value Menu Entry: Mode: org-mode Regexp: a\|b INS DEL Choice: Value Menu Entry: Mode: text-mode Regexp: b\|c INS State : CHANGED outside Customize. Some variable Groups: X 

However, this now includes an inconvenient drop-down menu that gives the user a choice between a record and an invalid value. Most likely, I would have a reduced default value and only be shown when there is a mismatch with a valid option. As a user, my first thought, seeing that it will be along the line ".".

Is there any standard way in the setup system to handle partially invalid values? I could not find in the documentation.ยน


ยน http://www.gnu.org/software/emacs/manual/html_node/elisp/Customization-Types.html#Customization-Types

+4
source share
1 answer

You can edit (and save) the displayed raw sex. I agree that it would be even better if the real part was displayed using ordinary widgets, and only the invalid part was displayed as raw sex. Patches are welcome.

0
source

Source: https://habr.com/ru/post/1488499/


All Articles