From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Eric M. Ludlam" Newsgroups: gmane.emacs.devel Subject: Re[2]: Multiple major modes Date: Mon, 18 Jun 2007 22:09:12 -0400 Message-ID: <200706190209.l5J29Csr010302@projectile.siege-engine.com> References: <466E7A93.3050705@gmail.com> <466E81AA.3030202@gnu.org> <466E9822.2050508@gmail.com> <466EAB9D.9020408@gnu.org> <466EEA71.2070700@gmail.com> <200706122014.l5CKEKV1021902@projectile.siege-engine.com> NNTP-Posting-Host: lo.gmane.org X-Trace: sea.gmane.org 1182229361 11914 80.91.229.12 (19 Jun 2007 05:02:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 19 Jun 2007 05:02:41 +0000 (UTC) Cc: jasonr@gnu.org, lennart.borgman@gmail.com, sdl.web@gmail.com, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 19 07:02:38 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1I0VrS-0006Qx-I0 for ged-emacs-devel@m.gmane.org; Tue, 19 Jun 2007 07:02:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I0VrS-0005Db-9o for ged-emacs-devel@m.gmane.org; Tue, 19 Jun 2007 01:02:38 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1I0T9k-0002sg-CL for emacs-devel@gnu.org; Mon, 18 Jun 2007 22:09:20 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1I0T9i-0002sU-Tl for emacs-devel@gnu.org; Mon, 18 Jun 2007 22:09:19 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I0T9i-0002sR-My for emacs-devel@gnu.org; Mon, 18 Jun 2007 22:09:18 -0400 Original-Received: from static-71-184-83-10.bstnma.fios.verizon.net ([71.184.83.10] helo=projectile.siege-engine.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1I0T9f-0003od-Fw; Mon, 18 Jun 2007 22:09:15 -0400 Original-Received: from projectile.siege-engine.com (localhost.localdomain [127.0.0.1]) by projectile.siege-engine.com (8.12.8/8.12.8) with ESMTP id l5J29DYE010306; Mon, 18 Jun 2007 22:09:13 -0400 Original-Received: (from zappo@localhost) by projectile.siege-engine.com (8.12.8/8.12.8/Submit) id l5J29Csr010302; Mon, 18 Jun 2007 22:09:12 -0400 In-reply-to: (message from Richard Stallman on Wed, 13 Jun 2007 12:22:39 -0400) X-detected-kernel: Linux 2.4-2.6 X-Mailman-Approved-At: Tue, 19 Jun 2007 01:02:24 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:73270 Archived-At: >>> Richard Stallman 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. http://cedet.sourceforge.net/semantic.shtml Enjoy Eric -- Eric Ludlam: zappo@gnu.org, eric@siege-engine.com Home: http://www.ludlam.net Siege: www.siege-engine.com Emacs: http://cedet.sourceforge.net GNU: www.gnu.org