How to programmatically set a user variable in Emacs Lisp?

In Emacs, some variables have special tuning behavior using Mx tuning, which do not start when you set the same variable via setq . Is there a programmatic way to set such variables so that the special behavior works as if the user set the variable through the setting?

Also, is there a function for programmatically storing a value in a user user file? I am trying to implement functionality to re-add default items to a list without deleting user-added items as well.

+6
source share
2 answers

customize-set-variable is what you want, not custom-set-variables (not necessary here).

In general, itโ€™s nice to also look at defcustom for a variable (user option) to see what its slot does :set , etc. Not necessary, but useful to know before trying to set the value programmatically.

This answer to the help-gnu-emacs@gnu.org question may also help: http://lists.gnu.org/archive/html/help-gnu-emacs/2013-08/msg00544.html

+6
source

Using the default-value function, followed by the mentioned custom-set-variable , can do this.

0
source

Source: https://habr.com/ru/post/952860/


All Articles