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: Lennart Borgman
Subject: Re: C Mode: acceleration in brace deserts.
Date: Fri, 4 Dec 2009 12:03:27 +0100

On Fri, Dec 4, 2009 at 11:34 AM, Lennart Borgman
<address@hidden> wrote:
> Hi again Alan,
>
> On Thu, Dec 3, 2009 at 8:57 PM, Lennart Borgman
> <address@hidden> wrote:
>> Hi Alan,
>>
>> On Thu, Dec 3, 2009 at 8:39 PM, Alan Mackenzie <address@hidden> wrote:
>>> Hi, Lennart!
>>>
>>> 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.
>>
>>
>> Thanks. Mumamo needs to know because it switches major mode and that
>> normally kills buffer local variables.
>
>
> I have a bit trouble with this. I believe there is a simple solution,
> but it requires some low level changes to Emacs. Your changes here
> illustrates very well why such a change may be desireable to support
> mult major modes.
>
> You are parsing the buffer from the beginning to find a state at a
> point (this state is here "in literal or not"). This of course breaks
> if there are chunks with different major modes in the buffer.
>
> All parsers naturally behave like this (unless they are not
> specifically taught about multi major modes and its implementation).
> js2, semantic, font-lock are other examples.
>
> I think the easiest cure for this is to let them just see the parts of
> the buffers that are in the programming language they know of at the
> moment. (This is perhaps not enough but a good start that covers most
> possibilities - and can be used for all parsers.)
>
> This must however be implemented on a low level. All C primitives
> reading the buffer must know about it. It is probably in most cases
> straightforward to implement it. A level between the buffer reading
> primitives and the buffer content is needed.  This hides the parts
> that should not be seen.
>
>
> It is probably possible to support your changes in MuMaMo now, but it
> is not easy while it will perhaps break easily instead. I have done
> something similar to syntax-ppss. I wish we could have the low level
> change instead.


Just a question I forgot: Why are you not using syntax-ppss here? Are
you not looking for the same thing (ie inside comment or string).

If you did it that way then it would already be supported by MuMaMo.




reply via email to

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