1

I have a problem that variables defined with defcustom in elisp files under ~/.elisp do not appear in the Customize UI.

In particular, I use word-count-mode from https://github.com/tomaszskutnik/word-count-mode/blob/master/word-count.el. Since it contains

(defcustom word-count-word-regexp "[a-z0-9_-]+"
  "Regexp what is counted as words.")

I would have thought that I should then be able to do M-x customize-apropos word-count-word-regexp, for example, and be able to customize this variable. But nothing appears as "word-" at all.

The manual at https://www.gnu.org/software/emacs/manual/html_node/elisp/Variable-Definitions.html seems to indicate that they should?

1
  • ~/.elisp is an unusual directory name. Can you please confirm that you've actually added that to your load-path ?
    – phils
    Commented Nov 13, 2021 at 12:02

1 Answer 1

1

Just because something is defined in an Elisp file, that doesn't mean that that file ever gets loaded. And if it doesn't get loaded then its contents are unknown to Emacs.

To use M-x customize-option to customize an option, you must load the file that contains the defcustom that defines that option.

To load a file, put it in your load-path, then require it in your init file. Putting it in your load-path means adding its directory to the value of variable load-path, which you can do with `add-to-list.

For example, this will make all files in directory ~/.elisp (but not in subdirectories) loadable using require:

(add-to-list 'load-path "~/.elisp")

If the defcustom is autoloaded (it has an autoload cookie (;;;###autoload or other autoload declaration), and if an autoloads file that has been generated to include it has been loaded, then you don't need to explicitly load the file with the defcustom - it will be loaded automatically. But that doesn't seem to be the case for your `defcustom.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.