5

I don't understand how setq-mode-local works (mode-local is a package from cedet). The macro's documentation says:

setq-mode-local is a Lisp macro in `mode-local.el'.

(setq-mode-local MODE &rest ARGS)

Assign new values to variables local in MODE.
MODE must be a major mode symbol.
ARGS is a list (SYM VAL SYM VAL ...).
The symbols SYM are variables; they are literal (not evaluated).
The values VAL are expressions; they are evaluated.
Set each SYM to the value of its VAL, locally in buffers already in
MODE, or in buffers switched to that mode.
Return the value of the last VAL.

  1. Does the mode need to be loaded?
  2. How does this differ from just adding a setq-local call to a mode-hook?
  • I look at the source code and it's quite complex. So it's probably more sophisticated than adding a setq-local to a hook. But I don't know what the difference is. – Malabarba Oct 18 '14 at 19:33
4

The immediate difference is that setq-mode-local will also affect already existing buffers, whereas adding a setq-local to the mode hook will only affect future buffers.

Of course, there are other differences due to the underlying mechanisms used, but I think to a first approximation, this is the only real difference.

  • 3
    setq-mode-local doesn't work for me if I enable the appropriate mode in a non-file buffer. It does work for file buffers though. Is this intended? – abo-abo Apr 22 '15 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.