3

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?

2 Answers 2

2

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).

Sign up to request clarification or add additional context in comments.

Comments

0

You can set a default like so:

(setq-default w3m-lnum-mode t)

For fine-grained control, use a hook as RNAer suggests. As far as I can tell though, this is not a normal local variable but a minor mode variable. You actually probably want to do (w3m-lnum-mode 1).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.