emacs-devel
[Top][All Lists]
Advanced

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

Re: C Mode: acceleration in brace deserts.


From: Alan Mackenzie
Subject: Re: C Mode: acceleration in brace deserts.
Date: Thu, 3 Dec 2009 19:39:18 +0000
User-agent: Mutt/1.5.9i

Hi, Lennart!

On Thu, Dec 03, 2009 at 06:22:02PM +0100, Lennart Borgman wrote:
> Hi Alan,

> On Thu, Dec 3, 2009 at 5:59 PM, Alan Mackenzie <address@hidden> wrote:
> > Hi, Lennart!

> > On Thu, Dec 03, 2009 at 05:26:57PM +0100, Lennart Borgman wrote:
> >> Hi Alan,

> >> Can you tell me how the cache [c-parse-state] is implemented so I can
> >> support it in MuMaMo?

> > Short brusque answer: no - it's ~1300 lines of code, much of it arcane.


> I need only a very short answer. I need to know how you store this
> data so I do not destroy it when switching major mode in MuMaMo.

Sorry, I misunderstood you.  I thought you were wanting to copy the
algorithm.

The state of this cache is held entirely in the variables (all of them
buffer local) initialised thusly:

(defun c-state-cache-init ()
  (setq c-state-cache nil
        c-state-cache-good-pos 1
        c-state-nonlit-pos-cache nil
        c-state-nonlit-pos-cache-limit 1
        c-state-brace-pair-desert nil
        c-state-point-min 1
        c-state-point-min-lit-type nil
        c-state-point-min-lit-start nil
        c-state-min-scan-pos 1
        c-state-old-cpp-beg nil
        c-state-old-cpp-end nil)
  (c-state-mark-point-min-literal))

, where `c-state-mark-point-min-literal' merely sets 3 variables already
named.  I don't honestly see a way MuMaMo could disturb this state by
accident.

> In the current situation I can only try to do that since the different
> major modes may stamp on each other (I need some more Emacs support to
> avoid that). But I can try. In some situations it is needed (for
> example php may be split up in several parts (which html code between)
> where the indentation in the next part should be aligned to that in
> the prev part).

> If you store it in a buffer local variable I am happy since all I have
> to do then is to make that survive major mode switching. If you store
> it in text properties I will be a bit more sad.

Ah, yes.  I use text properties, too.  On each C macro, #if, etc., I set
a category property on the "#" and one on (usually) the newline that
terminates it.  I also put category properties on "<" and ">" to mark
them as C++ template or Java generic delimiters.  Does this cause you
problems at all?

--
Alan Mackenzie (Nuremberg, Germany).




reply via email to

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