1

How can I programmatically check if a customize group exists?

Interactively I can use M-x customize-group and use completion to see if a specific group exists or not. But that's not what I need.

If I evaluate:

(customize-group "some-invalid-non-existing-group" nil)

Emacs will open a *Customize Group* buffer stating that the requested group is missing.

I'm writing code that programmatically opens a *Customize Group* buffer but I'd like to do that only if the group exists. So i'd need to check if a specific group name (held in a string) exists prior to programatically calling the customize-group function.

How to do that?

Drew
  • 75,699
  • 9
  • 109
  • 225
PRouleau
  • 744
  • 3
  • 10

1 Answers1

3

Cribbing from cus-edit.el gets you this:

(let (custom-groups)
  (mapatoms (lambda (symbol)
              (when (or (and (get symbol 'custom-loads)
                           (not (get symbol 'custom-autoload)))
                      (get symbol 'custom-group))
                (push symbol custom-groups))))
  custom-groups)
Drew
  • 75,699
  • 9
  • 109
  • 225
rpluim
  • 4,605
  • 8
  • 22