From: Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: difference between setq and setq-local
Date: Mon, 27 Sep 2021 05:26:28 +0200 [thread overview]
Message-ID: <87sfxqr95n.fsf@zoho.eu> (raw)
In-Reply-To: 87czou67pj.fsf@codeisgreat.org
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
next prev parent reply other threads:[~2021-09-27 3:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2021-09-28 3:02 ` Pankaj Jangid
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sfxqr95n.fsf@zoho.eu \
--to=help-gnu-emacs@gnu.org \
--cc=moasenwood@zoho.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.