Discussion:
Getting custom variables in a group
(too old to reply)
Eric Abrahamsen
2018-04-30 22:25:45 UTC
Permalink
I'm having an oddly hard time finding out programatically all the custom
variables in a custom group (recursively), or which group a custom
variable belongs to. I would have thought the latter would be a symbol
property, but it isn't.

Obviously `customize-group' must be able to find out, but when I
followed the code, the trail went cold in the widget jungle. I simply
don't see how it gets the list of options to display.

Right now I'm doing this, which I guess works okay, but it seems a bit hacky:

(let (target-syms)
(mapatoms
(lambda (sym)
(when (and (custom-variable-p sym)
(string-match-p "^gnus-\\|^message-"
(symbol-name sym)))
(push sym target-syms))))
target-syms)
Stefan Monnier
2018-05-01 00:34:42 UTC
Permalink
Post by Eric Abrahamsen
I'm having an oddly hard time finding out programatically all the custom
variables in a custom group (recursively),
The variables and subgroups of a custom group are stored in the
`custom-group` property of the group's symbol.
Post by Eric Abrahamsen
or which group a custom variable belongs to.
For this one you're going to have to mapatom to enumerate all symbols,
looking for the var in the `custom-group` property.

You can look at custom-add-parent-links to find inspiration (and feel
free to refector this function so you can reuse part of its code rather
than duplicate it).


Stefan
Eric Abrahamsen
2018-05-01 01:24:40 UTC
Permalink
Post by Stefan Monnier
Post by Eric Abrahamsen
I'm having an oddly hard time finding out programatically all the custom
variables in a custom group (recursively),
The variables and subgroups of a custom group are stored in the
`custom-group` property of the group's symbol.
I'd started with 'gnus and so only saw more custom-groups, I didn't
realize you eventually got down to custom-variables. That's exactly what
I needed, thanks.
Post by Stefan Monnier
Post by Eric Abrahamsen
or which group a custom variable belongs to.
For this one you're going to have to mapatom to enumerate all symbols,
looking for the var in the `custom-group` property.
Easier to come in through the other end!
Post by Stefan Monnier
You can look at custom-add-parent-links to find inspiration (and feel
free to refector this function so you can reuse part of its code rather
than duplicate it).
Okay, this is starting to make sense. Seems like it might be useful to
have generalized `custom-find-parents' and `custom-find-children'
functions. I'll take a look.

Loading...