Before you set any variable, you must know how that variable is to be interpreted. Similarly, before you call any function (inluding those used to toggle minor modes), you must know how the arguments of that function are interpreted.
Use C-hf and C-hv to look at the documentation for the function or variable in question. It should specify the values that are expected.
"Non-nil" means literally anything that is not
nil. This includes
0 and negative numbers.
Let's take a specific example. Type C-hf
blink-cursor-mode and hit RET to see the function documentation for
(blink-cursor-mode &optional ARG)
Toggle cursor blinking (Blink Cursor mode). With a prefix argument
ARG, enable Blink Cursor mode if ARG is positive, and disable it
otherwise. If called from Lisp, enable the mode if ARG is omitted or
We can enable Blink Cursor mode in any of the following ways:
(blink-cursor-mode) ; Omitted argument
(blink-cursor-mode 1) ; Positive argument
(blink-cursor-mode t) ; True argument
(blink-cursor-mode nil) ; nil argument (don't use this)
Notice that an argument of
t will work, even though the doc string didn't specifically mention it. While this is often the case, your safest bet is to use what the doc string tells you to use, which in this case is a positive value.
Also, notice that an argument of
nil will work. I would strongly recommend against
nil in this way because it makes your intention unclear. If I were skimming over your lisp code and I saw a
nil argument, I would assume that you wanted to disable the minor mode.
We can also disable
blink-cursor-mode in the following ways:
(blink-cursor-mode 0) ; Non-positive argument
(blink-cursor-mode -1) ; Negative argument
Notice again that
nil is not one of the ways to disable this minor mode. This is true of almost any minor mode you will encounter.
Now let's look at an example of a variable. Type C-hv
truncate-lines and hit RET to look at the documentation for the variable
truncate-lines is a variable defined in `C source code'.
Non-nil means do not display continuation lines. Instead, give each
line of text just one screen line.
You can turn on truncation in any of the following ways:
(setq truncate-lines t) ; Boolean true value (non-nil)
(setq truncate-lines 1) ; Positive value (non-nil)
(setq truncate-lines 0) ; Zero value (non-nil)
(setq truncate-lines -1) ; Negative value (non-nil)
It may surprise you that the
0 and the
-1 will work. Again, I would recommend against using them because it makes your intentions unclear.
The only way to disable truncation is this:
(setq truncate-lines nil) ; nil value
In other words you can set
truncate-lines equal to numbers, letters, strings, lists, or anything else you want, as long as it does not evaluate to
nil it will enable truncation. (But you should really stick with