Again, you can use C-h f
to look up the documentation for each of these functions. When you do, you will find that setq-local
makes a variable buffer–local and then sets the value of that variable in the current buffer. It would work just fine for you, but since the variables you care about are already buffer–local, it isn’t necessary.
setq-default
sets the default value for a buffer–local variable, which is the global value that is used when a buffer has no specific value for a variable. Since this would affect many buffers rather than a specific one, this isn’t what you want.
99% of the time you just want setq
. This is one of those times. It sets the buffer–local value of the variable, if the variable is buffer–local, and otherwise sets the global value if the variable isn’t buffer–local.
Note that there are many other ways to set variables that you didn’t mention. The most primitive version is actually set
. setq
adds the ability to set multiple variables at a time: (setq VAR1 VAL1 VAR2 VAL2 VAR3 VAL3…)
. Another favorite is setf
, which builds upon setq
to allow you to set the value of any PLACE, rather than just any variable. A PLACE expression is any expression that would retrieve a value. The canonical example is that (car x)
retrieves the first element of x
, so (setf (car x) 42)
sets that first element to 42.
Finally, there is the customization system. You can type M-x customize
to get a nice UI that lists all of Emacs’s variables that you might want to change, grouped into categories and sub–categories and presented alongside their documentation. Customize lets you see the current value, edit the value, and save the value for future Emacs sessions without actually opening up your init file and writing any Lisp. It also validates the values that you input, and for most variables can provide a much nicer editing experience than raw lisp.