* The operation of default-value @ 2022-12-01 22:47 Heime 2022-12-01 23:16 ` [External] : " Drew Adams 0 siblings, 1 reply; 6+ messages in thread From: Heime @ 2022-12-01 22:47 UTC (permalink / raw) To: Heime via Users list for the GNU Emacs text editor I am struggling to understand the operation of "default-value". The documentation states that "This is the value that is seen in buffers that do not have their own values for this variable. The default value is meaningful for variables with local bindings in certain buffers." Take for instance the variable "mode-line-format". When do buffer variables have their own values, and when do they not have them? How can one figure out what has been set or not (whether buffers have variable values or not)?. ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [External] : The operation of default-value 2022-12-01 22:47 The operation of default-value Heime @ 2022-12-01 23:16 ` Drew Adams 2022-12-01 23:35 ` Heime 0 siblings, 1 reply; 6+ messages in thread From: Drew Adams @ 2022-12-01 23:16 UTC (permalink / raw) To: Heime, 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)' [-- Attachment #1: Type: text/plain, Size: 1083 bytes --] > The documentation states that > > "This is the value that is seen in buffers that > do not have their own values for this variable. > The default value is meaningful for variables > with local bindings in certain buffers." Good to see you are looking at the doc now! Did you read the nodes previous to that one, in the same chapter (Buffer-Local Variables)? I think they answer your questions. > When do buffer variables have their own values, > and when do they not have them? I think node `Creating Buffer-Local' explains this. If you don't create/set a buffer-local value in buffer A for a variable then its global, "default" value applies in buffer A. It's as simple as that. > How can one figure out what has been set or not (whether buffers have > variable values or not)?. Check whether (buffer-local-value THE-VAR) is the same as (default-value THE-VAR). Again, this is explained in the node that precedes the node you quoted from. I suggest starting at the beginning of chapter Buffer-Local Variables, and reading from there. [-- Attachment #2: winmail.dat --] [-- Type: application/ms-tnef, Size: 13836 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [External] : The operation of default-value 2022-12-01 23:16 ` [External] : " Drew Adams @ 2022-12-01 23:35 ` Heime 2022-12-02 2:49 ` Drew Adams 0 siblings, 1 reply; 6+ messages in thread From: Heime @ 2022-12-01 23:35 UTC (permalink / raw) To: Drew Adams; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)' ------- Original Message ------- On Thursday, December 1st, 2022 at 11:16 PM, Drew Adams <drew.adams@oracle.com> wrote: > > The documentation states that > > > > "This is the value that is seen in buffers that > > do not have their own values for this variable. > > The default value is meaningful for variables > > with local bindings in certain buffers." > > > Good to see you are looking at the doc now! > > Did you read the nodes previous to that one, > in the same chapter (Buffer-Local Variables)? > I think they answer your questions. > > > When do buffer variables have their own values, > > and when do they not have them? > > > I think node `Creating Buffer-Local' explains this. > > If you don't create/set a buffer-local value in > buffer A for a variable then its global, "default" > value applies in buffer A. It's as simple as that. Meaning that a package can change the buffer-local variable, with the default-value being different. Thusly, the variable used in the buffer is either the default value when the local value is nil, or the local value when they differ. Meaning that I cannot rely completely on default-value, because the local value might be set up differently. > > How can one figure out what has been set or not (whether buffers have > > variable values or not)?. > > > Check whether (buffer-local-value THE-VAR) is the > same as (default-value THE-VAR). > > Again, this is explained in the node that precedes > the node you quoted from. > > I suggest starting at the beginning of chapter > Buffer-Local Variables, and reading from there. ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [External] : The operation of default-value 2022-12-01 23:35 ` Heime @ 2022-12-02 2:49 ` Drew Adams 2022-12-02 2:57 ` Emanuel Berg 0 siblings, 1 reply; 6+ messages in thread From: Drew Adams @ 2022-12-02 2:49 UTC (permalink / raw) To: Heime; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)' > > I think node `Creating Buffer-Local' explains this. > > > > If you don't create/set a buffer-local value in > > buffer A for a variable then its global, "default" > > value applies in buffer A. It's as simple as that. > > Meaning that a package can change the buffer-local variable, > with the default-value being different. A package, or anything else, can set a buffer-local value, yes. > Thusly, the variable used in the buffer is either > the default value when the local > value is nil, or the local value when they differ. You can think of it being a different variable, yes. Or you can think of it as being the same variable, with both (1) a default value and (2) a buffer-local value; that is, with two kinds of _bindings_. The doc generally speaks of it in this second way: “buffer-local” bindings, which apply only in one buffer. Having different values for a variable in different buffers But it also talks about "buffer-local variables" (not just buffer-local variable bindings): A buffer-local variable has a buffer-local binding associated with a particular buffer. "Buffer-local variable" refers to the buffer-local binding of a variable. `setq-local' sets the buffer-local value for the current buffer. So does `setq', if the variable has already been made buffer-local in the buffer. `make-local-variable' makes a variable's value be buffer-local in the current buffer. `make-variable-buffer-local' makes a variable always be buffer-local, in every buffer. If you look at the definition of `setq-local' you'll see that it's just this, since `make-local-variable' conveniently returns the variable (symbol). (set (make-local-variable 'VARIABLE VALUE)) > Meaning that I cannot rely completely on default-value, > because the local value might be set up differently. As usual, your meaning isn't clear. Specify what you mean by "rely completely on". Even when a variable has a buffer-local value, you can always access -- get or set -- its default value. Functions `default-value' and `setq-default' do that, respectively. If this explanation helps, I suggest you reread the doc that covers this subject. With the added understanding you may get more out of it on a second reading. If this didn't help, hopefully someone else can help better. But you really owe it to yourself, as well as those who try to help you, to make clearer what you're asking. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [External] : The operation of default-value 2022-12-02 2:49 ` Drew Adams @ 2022-12-02 2:57 ` Emanuel Berg 2022-12-02 3:03 ` Emanuel Berg 0 siblings, 1 reply; 6+ messages in thread From: Emanuel Berg @ 2022-12-02 2:57 UTC (permalink / raw) To: help-gnu-emacs Drew Adams wrote: > `setq-local' sets the buffer-local value for the current > buffer. So does `setq', if the variable has already been > made buffer-local in the buffer. `setq-local' - always local `setq-default' - always global `setq' - local if local is present, global if global is present and local isn't, and if none are present, global, unless the variable automatically becomes buffer-local when set? I agree, pretty confusing ... -- underground experts united https://dataswamp.org/~incal ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [External] : The operation of default-value 2022-12-02 2:57 ` Emanuel Berg @ 2022-12-02 3:03 ` Emanuel Berg 0 siblings, 0 replies; 6+ messages in thread From: Emanuel Berg @ 2022-12-02 3:03 UTC (permalink / raw) To: help-gnu-emacs Nope, it's like this: `setq-local' - always local `setq' - local if local is present; local if the var is auto-local; oterwise global `setq-default' - always global -- underground experts united https://dataswamp.org/~incal ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-12-02 3:03 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-12-01 22:47 The operation of default-value Heime 2022-12-01 23:16 ` [External] : " Drew Adams 2022-12-01 23:35 ` Heime 2022-12-02 2:49 ` Drew Adams 2022-12-02 2:57 ` Emanuel Berg 2022-12-02 3:03 ` Emanuel Berg
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.