all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* difference between setq and setq-local
@ 2021-09-27  3:03 Pankaj Jangid
  2021-09-27  3:26 ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 3+ messages in thread
From: Pankaj Jangid @ 2021-09-27  3:03 UTC (permalink / raw)
  To: Emacs Help

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.

What am I missing? In which scenarios the three functions behave
differently from each other?



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: difference between setq and setq-local
  2021-09-27  3:03 difference between setq and setq-local Pankaj Jangid
@ 2021-09-27  3:26 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-09-28  3:02   ` Pankaj Jangid
  0 siblings, 1 reply; 3+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-09-27  3:26 UTC (permalink / raw)
  To: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: difference between setq and setq-local
  2021-09-27  3:26 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-09-28  3:02   ` Pankaj Jangid
  0 siblings, 0 replies; 3+ messages in thread
From: Pankaj Jangid @ 2021-09-28  3:02 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> 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!

Thanks for this primer on ‘setq-’ functions. It is permanently inscribed
now. And it is absolutely clear.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-28  3:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-27  3:03 difference between setq and setq-local Pankaj Jangid
2021-09-27  3:26 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-28  3:02   ` Pankaj Jangid

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.