* setq and setq-default
@ 2006-09-13 15:03 jronald
2006-09-13 16:29 ` robert.thorpe
0 siblings, 1 reply; 7+ messages in thread
From: jronald @ 2006-09-13 15:03 UTC (permalink / raw)
I studied them for a while, but without details and examples.
For example, what is the difference of the two below:
(setq-default tab-width 8)
(setq default-tab-width 8)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: setq and setq-default
[not found] <ee94hs$48u$1@news.yaako.com>
@ 2006-09-13 15:31 ` Reiner Steib
0 siblings, 0 replies; 7+ messages in thread
From: Reiner Steib @ 2006-09-13 15:31 UTC (permalink / raw)
On Wed, Sep 13 2006, jronald wrote:
> I studied them for a while, but without details and examples.
>
> For example, what is the difference of the two below:
> (setq-default tab-width 8)
> (setq default-tab-width 8)
Wrong list/newsgroup: This is a question about Emacs, not about Gnus
-> Crosspost & Followup-To: gnu.emacs.help
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: setq and setq-default
2006-09-13 15:03 setq and setq-default jronald
@ 2006-09-13 16:29 ` robert.thorpe
2006-09-13 18:26 ` jronald
0 siblings, 1 reply; 7+ messages in thread
From: robert.thorpe @ 2006-09-13 16:29 UTC (permalink / raw)
jronald wrote:
> I studied them for a while, but without details and examples.
>
> For example, what is the difference of the two below:
> (setq-default tab-width 8)
This is the general way to set the default value of a variable. If you
put (setq-default foo 9) then in the context of every buffer you create
foo will be 9 unless the buffer has it's own value for that variable.
> (setq default-tab-width 8)
This means the same thing, except it is a mechanism specific to
tab-width, not all variables have a special "default" form associated
with them. Only a handful have them, I don't know why, perhaps
setq-default didn't exist in very early Emacs.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: setq and setq-default
2006-09-13 16:29 ` robert.thorpe
@ 2006-09-13 18:26 ` jronald
2006-09-14 18:42 ` robert.thorpe
0 siblings, 1 reply; 7+ messages in thread
From: jronald @ 2006-09-13 18:26 UTC (permalink / raw)
I think setq-default set a global variable, and setq set a variable in its
scope, which may override the global one.
If so, can setq set a global variable when it is in the global scope.
If tab-width and default-tab-width both exsists, what is the priority emacs
treats them?
<robert.thorpe@antenova.com>
??????:1158164996.335560.182180@i3g2000cwc.googlegroups.com...
> jronald wrote:
>> I studied them for a while, but without details and examples.
>>
>> For example, what is the difference of the two below:
>> (setq-default tab-width 8)
>
> This is the general way to set the default value of a variable. If you
> put (setq-default foo 9) then in the context of every buffer you create
> foo will be 9 unless the buffer has it's own value for that variable.
>
>> (setq default-tab-width 8)
>
> This means the same thing, except it is a mechanism specific to
> tab-width, not all variables have a special "default" form associated
> with them. Only a handful have them, I don't know why, perhaps
> setq-default didn't exist in very early Emacs.
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: setq and setq-default
2006-09-13 18:26 ` jronald
@ 2006-09-14 18:42 ` robert.thorpe
2006-09-14 18:57 ` David Kastrup
0 siblings, 1 reply; 7+ messages in thread
From: robert.thorpe @ 2006-09-14 18:42 UTC (permalink / raw)
jronald wrote:
> I think setq-default set a global variable, and setq set a variable in its
> scope,
Yes.
> which may override the global one.
> If so, can setq set a global variable when it is in the global scope.
If there is no local variable called "foo" then you will set the global
value of foo by doing:-
(setq foo 56)
If there is a local var with that name then setq will set that.
If you were able to write elisp in the global scope then setq would
always update the global variable. However all emacs code exists in
the context of some mode.
> If tab-width and default-tab-width both exsists, what is the priority emacs
> treats them?
They have no priority, both update the same variable. If you do
(setq-default tab-width 29) then open a new buffer tabs will be 29
spaces. If you do (setq default-tab-width 10) and open some more new
buffers tabs will be 10 spaces in those.
Emacs is rather like an object orientated system. To a C++ person it's
best described in those terms:
Fundamental-mode is the basic editing class. Things like CC-mode are
classes derived from fundamental-mode. C-mode and Java-mode are classes
derived in turn from CC-mode. Each open buffer is an instance of some
class/mode.
The buffer local variables are fields local to each object instance (ie
buffer). Global variables, like those defined with setq-default are
the same as "class variables".
Things like mode-hooks are rather like virtual methods for use by the
user.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: setq and setq-default
2006-09-14 18:42 ` robert.thorpe
@ 2006-09-14 18:57 ` David Kastrup
2006-09-15 11:00 ` robert.thorpe
0 siblings, 1 reply; 7+ messages in thread
From: David Kastrup @ 2006-09-14 18:57 UTC (permalink / raw)
robert.thorpe@antenova.com writes:
> Emacs is rather like an object orientated system.
Proud claim. Probably means something like: if it breaks, you get to
keep the pieces, and each of them may further break in its own way.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: setq and setq-default
2006-09-14 18:57 ` David Kastrup
@ 2006-09-15 11:00 ` robert.thorpe
0 siblings, 0 replies; 7+ messages in thread
From: robert.thorpe @ 2006-09-15 11:00 UTC (permalink / raw)
David Kastrup wrote:
> robert.thorpe@antenova.com writes:
>
> > Emacs is rather like an object orientated system.
>
> Proud claim.
I said "rather like". I was trying to analogise it to something the OP
may be familiar with.
> Probably means something like: if it breaks, you get to
> keep the pieces, and each of them may further break in its own way.
Don't we get to keep the bits? ;)
I could have said it was an object disorientated system or an "objects
are theft" system. But I was trying to be restrained.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-09-15 11:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-13 15:03 setq and setq-default jronald
2006-09-13 16:29 ` robert.thorpe
2006-09-13 18:26 ` jronald
2006-09-14 18:42 ` robert.thorpe
2006-09-14 18:57 ` David Kastrup
2006-09-15 11:00 ` robert.thorpe
[not found] <ee94hs$48u$1@news.yaako.com>
2006-09-13 15:31 ` Reiner Steib
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.