reddit / emacs

Customize variable

GidiomGates · 2022-10-22 15:00
I have been trying to customize width variable in treemacs. In the source code the variabe is defined like this (defcustom treemacs-width 35 :type 'integer : group 'treemacs-window) I want customize this variable from config.el and not from source code. Im using doom emacs and i have tried with: (setq 'treemacs-width 25) but don't work. Im new using emacs and all this notation is little confusing to me. How i should customize the variabe?
takeonrules · 2022-10-22 15:52
Have you tried `(setq treemacs-width 25)`? Further, have you tried `M-x customize-variable` then provide `treemacs-width` and set the value to 35?
GidiomGates · 2022-10-22 16:27
Yes, the first option worked for me, thanks. It's just not clear to me when I should use quotes to call the variable. Thank you :)
takeonrules · 2022-10-22 16:34
I can provide another explanation that might help: - `'treemacs-width` is the symbol - `treemacs-width` is the variable You can't set a symbol; it is immutable. You can set a variable. Let's use an analogy of delivering a physical package. You have a package that you want delivered to your home. Conceptually the symbol is the "address" of your home and the variable is the "building" where you keep your stuff (e.g. your home). You deliver the package to the building and open that package in that building. The delivery person uses the address to find their way to the building.
eleven_cupfuls · 2022-10-22 17:24
In this case, `setq` is short for "set quoted", meaning that it in effect does the quoting for you. (It can do this because it's a macro, not a regular function, but that's another topic.) So `(setq foo '(bar baz))` is equivalent to `(set 'foo '(bar baz))`, where `set` is the built-in function that actually changes the value.
thetemp_ · 2022-10-22 18:09
If you do "M-x customize-variable RET treemacs-width RET", it should bring up an interface you can use to set and save the variable without even touching any code.