TransWikia.com

How to check if a customize group exists in Emacs Lisp code?

Emacs Asked by PRouleau on September 2, 2021

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?

One Answer

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)

Correct answer by rpluim on September 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP