help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

`make-local-variable' and `add-hook'


From: Sebastian P. Luque
Subject: `make-local-variable' and `add-hook'
Date: Wed, 02 Apr 2008 15:05:47 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Hi,

Is this the best way to give a buffer-local value to a variable inside a
hook:

---<---------------cut here---------------start-------------->---
(add-hook 'sql-interactive-mode-hook
          (lambda ()
            (setq sql-input-ring-file-name "~/.emacs.d/sql_history")
            (set (make-local-variable 'truncate-lines) t)))
---<---------------cut here---------------end---------------->---

?  I'm a bit confused about the last paragraph in the docs:

,-----[ C-h f make-local-variable RET ]
| make-local-variable is an interactive built-in function in `C source code'.
| 
| 
| (make-local-variable variable)
| 
| Make variable have a separate value in the current buffer.
| Other buffers will continue to share a common default value.
| (The buffer-local value of variable starts out as the same value
| variable previously had.  If variable was void, it remains void.)
| Return variable.
| 
| If the variable is already arranged to become local when set,
| this function causes a local value to exist for this buffer,
| just as setting the variable would do.
| 
| This function returns variable, and therefore
|   (set (make-local-variable 'variable) VALUE-EXP)
| works.
| 
| See also `make-variable-buffer-local'.
| 
| Do not use `make-local-variable' to make a hook variable buffer-local.
| Instead, use `add-hook' and specify t for the LOCAL argument.
`-----


Cheers,

-- 
Seb





reply via email to

[Prev in Thread] Current Thread [Next in Thread]