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

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

Re: elisp from CL transition guide


From: Tassilo Horn
Subject: Re: elisp from CL transition guide
Date: Thu, 16 Aug 2007 14:58:04 +0200
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1.50 (gnu/linux)

Tamas Papp <tkpapp@gmail.com> writes:

Hi Tamas,

> One thing I don't understand yet is namespaces in Elisp: if I set
> fill-column in a buffer (setq fill-column 80), that doesn't seem to
> affect fill-column in other buffers.

Yes, `fill-column' is always buffer-local when set.

,----[ C-h v fill-column RET ]
| fill-column is a variable defined in `C source code'.
| Its value is 72
| Local in buffer *followup to Tamas Papp on gnu.emacs.help*; global value is 79
| Automatically becomes buffer-local when set in any fashion.
| 
| 
| This variable is safe as a file local variable if its value satisfies
| the predicate `integerp'.
| 
| Documentation:
| *Column beyond which automatic line-wrapping should happen.
| Interactively, you can set the buffer local value using C-x f.
`----

To set its default value for all buffers use `setq-default'.

> But if I set some other variable eg (setq foo 12), foo will evaluate
> to 12 in other buffers.

If you do

  (set (make-local-variable 'foo) 12)

I'll be twelve only in that buffer.

> What would be a correct mental model for this?

Some variables like `fill-column' always are buffer-local, but every
variable can be buffer-local.

See

,----[ (info "(elisp)Buffer-Local Variables") ]
| Global and local variable bindings are found in most programming
| languages in one form or another.  Emacs, however, also supports
| additional, unusual kinds of variable binding: "buffer-local"
| bindings, which apply only in one buffer, and "frame-local" bindings,
| which apply only in one frame.  Having different values for a variable
| in different buffers and/or frames is an important customization
| method.
`----

Bye,
Tassilo
-- 
If programmers deserve to  be rewarded for creating innovative programs,
by the same  token they deserve to be punished if  they restrict the use
of these programs. (Richard M. Stallman)


reply via email to

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