all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Getting custom variables in a group
@ 2018-04-30 22:25 Eric Abrahamsen
  2018-05-01  0:34 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Abrahamsen @ 2018-04-30 22:25 UTC (permalink / raw)
  To: emacs-devel

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)




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Getting custom variables in a group
  2018-04-30 22:25 Getting custom variables in a group Eric Abrahamsen
@ 2018-05-01  0:34 ` Stefan Monnier
  2018-05-01  1:24   ` Eric Abrahamsen
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2018-05-01  0:34 UTC (permalink / raw)
  To: emacs-devel

> 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.

> 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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Getting custom variables in a group
  2018-05-01  0:34 ` Stefan Monnier
@ 2018-05-01  1:24   ` Eric Abrahamsen
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Abrahamsen @ 2018-05-01  1:24 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> 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.

>> 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!

> 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.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-01  1:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-30 22:25 Getting custom variables in a group Eric Abrahamsen
2018-05-01  0:34 ` Stefan Monnier
2018-05-01  1:24   ` Eric Abrahamsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.