all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: robert.thorpe@antenova.com
Subject: Re: setq and setq-default
Date: 14 Sep 2006 11:42:04 -0700	[thread overview]
Message-ID: <1158259324.283308.136850@d34g2000cwd.googlegroups.com> (raw)
In-Reply-To: <ee9iga$doq$1@news.yaako.com>

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.

  reply	other threads:[~2006-09-14 18:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=1158259324.283308.136850@d34g2000cwd.googlegroups.com \
    --to=robert.thorpe@antenova.com \
    /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.