* `make-local-variable' and `add-hook'
@ 2008-04-02 20:05 Sebastian P. Luque
2008-04-02 21:02 ` Reiner Steib
0 siblings, 1 reply; 2+ messages in thread
From: Sebastian P. Luque @ 2008-04-02 20:05 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: `make-local-variable' and `add-hook'
2008-04-02 20:05 `make-local-variable' and `add-hook' Sebastian P. Luque
@ 2008-04-02 21:02 ` Reiner Steib
0 siblings, 0 replies; 2+ messages in thread
From: Reiner Steib @ 2008-04-02 21:02 UTC (permalink / raw)
To: help-gnu-emacs
On Wed, Apr 02 2008, Sebastian P. Luque wrote:
> 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)))
`truncate-lines' is already buffer-local:
,----[ <f1> v truncate-lines RET ]
| truncate-lines is a variable defined in `C source code'.
| Its value is nil
|
| Automatically becomes buffer-local when set in any fashion.
`----
> ---<---------------cut here---------------end---------------->---
>
> ? I'm a bit confused about the last paragraph in the docs:
>
> ,-----[ C-h f make-local-variable RET ]
[...]
> | Do not use `make-local-variable' to make a hook variable buffer-local.
> | Instead, use `add-hook' and specify t for the LOCAL argument.
> `-----
This paragraph would be relevant if you'd like to make
`sql-interactive-mode-hook' buffer-local.
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-04-02 21:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-02 20:05 `make-local-variable' and `add-hook' Sebastian P. Luque
2008-04-02 21:02 ` Reiner Steib
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.