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

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

Re: difference between setq and setq-local


From: Emanuel Berg
Subject: Re: difference between setq and setq-local
Date: Mon, 27 Sep 2021 05:26:28 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Pankaj Jangid wrote:

> There are three variants of setq; namely - setq, setq-local,
> setq-default. Meaning of setq-local and setq-default is
> clear from the docstring. i.e. changes made by setq-local
> are not visible outside the current buffer. And changes made
> by setq-default are visible in all the buffers in which the
> value is not set (overridden).
>
> What about plain setq? My assumption is that these changes
> are visible in all the buffers if not overridden by
> setq-local. In this case setq acts like setq-default. Or is
> it the opposite? i.e. setq overrides setq-default valuep; in
> which case it acts like setq-local [...]

Stop it, you are making my head spin :)

I'm not 100% but the way I understood it ...

`setq-local' makes the variable buffer-local, after that
`setq' sets the buffer-local variable while `setq-default'
sets the global value, which is used if the value
isn't set somewhere where/when it's used ...

If there isn't a buffer-local variable setq and setq-default
should be equivalent, i.e. they refer to the global variable.

Some variables as you know automatically gets buffer-local
when set, the help says so often enough for everybody to see
it. So there OTOH setq-local and setq are equivalent while
setq-default still does the same thing.

So setq-local always does the same thing.

And setq-default always does the same thing as well.

setq tho is the tricky one, it refers to the buffer-local
variable if it exists ... _or_ acts like `setq-local' for some
specific variables ... _or_ acts like setq-default if the
there isn't buffer-local variable and also the variable
doesn't stipulate it wants to be buffer-local soo bad!

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

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