Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I start iswitchb-mode this way?

According to the emacs info page, here's how you enable iswitchb-mode:

To enable Iswitchb mode, type M-x iswitchb-mode, or customize the variable iswitchb-mode to t

So I put the following in my .emacs:

(setq iswitchb-mode t)

However, this doesn't seem to work. After searching the emacs wiki, I found that I need to use this:

(iswitchb-mode 1)

Could someone explain why I need to enable it this way? I'd like to get a better understanding of elisp rather than just copying and pasting things from places.

like image 787
Jason Baker Avatar asked Sep 14 '09 13:09

Jason Baker


1 Answers

Typically a mode will define both a variable and a function with the same name. The function will set the variable properly when it's called, but it's the function that turns on the mode, not just the variable (that only tracks the mode's state).

In your specific case, you were told told customize the variable, but you simply set it instead. The difference is that when the value of the variable changes, custom knows to do something and `setq' knows nothing of this. If you look at the help for this variable (C-h v iswitchb-mode) you'd get:

iswitchb-mode is a variable defined in `iswitchb.el'.
Its value is t

Documentation:
Non-nil if Iswitchb mode is enabled.
See the command `iswitchb-mode' for a description of this minor mode.
Setting this variable directly does not take effect;
either customize it (see the info node `Easy Customization')
or call the function `iswitchb-mode'.

You can customize this variable.
like image 66
Joe Casadonte Avatar answered Sep 28 '22 04:09

Joe Casadonte