Generally, how can I customize the value of a buffer-local variable in Emacs? For example, the variable w3m-lnum-mode
is buffer-local, if I set (setq w3m-lnum-mode t)
in .emacs
, its value in a w3m mode buffer is still nil. How could I set it to t
in w3m major mode?
3
votes
2 Answers
2
votes
Major modes have a hook variable for this sort of thing. Look for w3m-mode-hook
.
(defun my-w3m-hook nil
(setq w3m-lnum-mode t))
(add-hook 'w3m-mode-hook #'my-w3m-hook)
The indirection to hook a separate function is not absolutely necessary, but simplifies the management of the hook functionality (otherwise you'd have to restart Emacs or jump through several hoops to add something to an existing hook; now all you need to do is evaluate a new defun
of the function called from the hook).