emacselisp

Confusing about the Emacs custom system


There are several similar setting functions:

  1. set & setq
  2. set-default
  3. defcustom
  4. custom-set-value
  5. custom-set-variables
  6. customize-set-value
  7. customize-set-variable

so, what's the difference between these functions?

If I want setting my own preferences to an add-on, for these scenario:

  1. If a variable setting by defcustom, which setting-function will be better?
  2. And what about a variable setting by defvar?

Solution

  • The short answer to you question is:

    Below is the long answer.

    The functions that you are going to use are the following:

    The functions that a package writer uses are:

    Setting variables can be done two ways:

    1. if defvar was used, the values can only be set by the user in its .emacs by using the set function (or variants)

    2. if defcustom was used, the values can be set using set (see 1.) OR by using Customize. When using the customize mechanism, emacs will generate some code that it will place in custom-set-variables. The user should not use this function.