[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re[2]: Multiple major modes

From: Eric M. Ludlam
Subject: Re[2]: Multiple major modes
Date: Mon, 18 Jun 2007 22:09:12 -0400

>>> Richard Stallman <address@hidden> seems to think that:
>    This tools has a spiff macro `with-mode-local', which lets you run a
>    bunch of code as if some other mode were active.
>Can you explain, in a nutshell, how the mechanism works?

The mode-local system ignores all variables set for the mode outside
the scope of mode-local.

Step 1:

  Define all your variables with `defvar-mode-local'.
  If changing a default value, use `setq-mode-local'

Step 2:

  For a program, use `define-overload' to specify a function that
  can have a mode specific override.  Supply a default body for modes
  that accept the default.

Step 3:

  The mode-local system will automatically assign buffer-local values
  to mode-local defined variables.

  If a function is called created with `define-overload', then a mode
  specific behavior will be run.

Ok, now if you use `with-mode-local', it will just substitute the old
local variables defined in the current mode with those from the new
mode, deleting any that don't exist in the new mode.

When exiting body (from with-mode-local macro) then it will just
reverse the process.

This is a key piece of abstraction for my semantic tool which provides
language independent access to tagging information, which needs
mode-specific values for parser information and many other functions.



          Eric Ludlam:                 address@hidden, address@hidden
   Home: http://www.ludlam.net            Siege: www.siege-engine.com
Emacs: http://cedet.sourceforge.net               GNU: www.gnu.org

reply via email to

[Prev in Thread] Current Thread [Next in Thread]