unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Confused about buffer-local variables
@ 2014-03-31 16:41 Thorsten Jolitz
  2014-03-31 19:47 ` Nicolas Richard
  0 siblings, 1 reply; 5+ messages in thread
From: Thorsten Jolitz @ 2014-03-31 16:41 UTC (permalink / raw)
  To: help-gnu-emacs


Hi List, 

assume function `foo' is defined in library A and uses variable `bar'
defined in that library with value "X". Now I call function `foo' from a
buffer where variable `bar' is set as a buffer-local variable to a
different value "Y".

Which value is `foo' going to use - "X" or "Y"? I would have said "Y"
but feel a bit confused right now ...

-- 
cheers,
Thorsten





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

* Re: Confused about buffer-local variables
  2014-03-31 16:41 Confused about buffer-local variables Thorsten Jolitz
@ 2014-03-31 19:47 ` Nicolas Richard
  2014-03-31 21:10   ` Thorsten Jolitz
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Richard @ 2014-03-31 19:47 UTC (permalink / raw)
  To: Thorsten Jolitz; +Cc: help-gnu-emacs

Thorsten Jolitz <tjolitz@gmail.com> writes:
> assume function `foo' is defined in library A and uses variable `bar'
> defined in that library with value "X". Now I call function `foo' from a
> buffer where variable `bar' is set as a buffer-local variable to a
> different value "Y".
>
> Which value is `foo' going to use - "X" or "Y"? I would have said "Y"
> but feel a bit confused right now ...

I'd say 'Y' also, but maybe I'm confused and I do not know it. Do you
have any code sample that doesn't do what you expected ?

-- 
Nico.



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

* Re: Confused about buffer-local variables
  2014-03-31 19:47 ` Nicolas Richard
@ 2014-03-31 21:10   ` Thorsten Jolitz
  2014-04-01 10:11     ` Nicolas Richard
  0 siblings, 1 reply; 5+ messages in thread
From: Thorsten Jolitz @ 2014-03-31 21:10 UTC (permalink / raw)
  To: help-gnu-emacs

Nicolas Richard <theonewiththeevillook@yahoo.fr> writes:

> Thorsten Jolitz <tjolitz@gmail.com> writes:
>> assume function `foo' is defined in library A and uses variable `bar'
>> defined in that library with value "X". Now I call function `foo' from a
>> buffer where variable `bar' is set as a buffer-local variable to a
>> different value "Y".
>>
>> Which value is `foo' going to use - "X" or "Y"? I would have said "Y"
>> but feel a bit confused right now ...
>
> I'd say 'Y' also, but maybe I'm confused and I do not know it. Do you
> have any code sample that doesn't do what you expected ?

You are right, I should have rather tested it:

Evaluating library mylib.el:

,--------------------------
| (defvar mylib-bar "X")
| 
| (defun mylib-foo ()
|   (print mylib-bar))
`--------------------------

after opening buffer local-var-test.org:

,---------------------
| * 1st Level
| 
| Lorem Ipsum
| 
|   # Local Variables:
|   # mylib-bar: "Y"
|   # End:
`---------------------

does not change the expected result when doing 

,----------------------
| M-: (mylib-foo)
`----------------------

with point in buffer local-var-test.org:

,----
| "Y"
`----

-- 
cheers,
Thorsten




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

* Re: Confused about buffer-local variables
  2014-03-31 21:10   ` Thorsten Jolitz
@ 2014-04-01 10:11     ` Nicolas Richard
  2014-04-01 10:33       ` Thorsten Jolitz
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Richard @ 2014-04-01 10:11 UTC (permalink / raw)
  To: Thorsten Jolitz; +Cc: help-gnu-emacs

Thorsten Jolitz <tjolitz@gmail.com> writes:
> Nicolas Richard <theonewiththeevillook@yahoo.fr> writes:
>> Thorsten Jolitz <tjolitz@gmail.com> writes:
>>> assume function `foo' is defined in library A and uses variable `bar'
>>> defined in that library with value "X". Now I call function `foo' from a
>>> buffer where variable `bar' is set as a buffer-local variable to a
>>> different value "Y".
>>>
>>> Which value is `foo' going to use - "X" or "Y"? I would have said "Y"
>>> but feel a bit confused right now ...
>>
>> I'd say 'Y' also, but maybe I'm confused and I do not know it. Do you
>> have any code sample that doesn't do what you expected ?

> with point in buffer local-var-test.org:
>
> ,----
> | "Y"
> `----

Sorry, I don't see how that is unexpected : it matches both your and my
expectation. I tried your recipe to check and I also get "Y".

-- 
Nico.



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

* Re: Confused about buffer-local variables
  2014-04-01 10:11     ` Nicolas Richard
@ 2014-04-01 10:33       ` Thorsten Jolitz
  0 siblings, 0 replies; 5+ messages in thread
From: Thorsten Jolitz @ 2014-04-01 10:33 UTC (permalink / raw)
  To: help-gnu-emacs

Nicolas Richard <theonewiththeevillook@yahoo.fr> writes:

> Thorsten Jolitz <tjolitz@gmail.com> writes:
>> Nicolas Richard <theonewiththeevillook@yahoo.fr> writes:
>>> Thorsten Jolitz <tjolitz@gmail.com> writes:
>>>> assume function `foo' is defined in library A and uses variable `bar'
>>>> defined in that library with value "X". Now I call function `foo'
>>>> from a
>>>> buffer where variable `bar' is set as a buffer-local variable to a
>>>> different value "Y".
>>>>
>>>> Which value is `foo' going to use - "X" or "Y"? I would have said "Y"
>>>> but feel a bit confused right now ...
>>>
>>> I'd say 'Y' also, but maybe I'm confused and I do not know it. Do you
>>> have any code sample that doesn't do what you expected ?
>
>> with point in buffer local-var-test.org:
>>
>> ,----
>> | "Y"
>> `----
>
> Sorry, I don't see how that is unexpected : it matches both your and my
> expectation. I tried your recipe to check and I also get "Y".

It is as expected, I meant I should have just tried it instead of asking
a question. Sorry for being unclear ...

-- 
cheers,
Thorsten




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

end of thread, other threads:[~2014-04-01 10:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-31 16:41 Confused about buffer-local variables Thorsten Jolitz
2014-03-31 19:47 ` Nicolas Richard
2014-03-31 21:10   ` Thorsten Jolitz
2014-04-01 10:11     ` Nicolas Richard
2014-04-01 10:33       ` Thorsten Jolitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).