emacs-devel
[Top][All Lists]
Advanced

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

RE: antlr-mode.el - need some support by python.el


From: Wedler, Christoph
Subject: RE: antlr-mode.el - need some support by python.el
Date: Mon, 8 Jun 2015 09:12:35 +0000

>> Many modes use more than the current line / code chunk in their
>> indentation calculations.  For example, in `c-guess-basic-syntax', the
>> outer language constructs are also considered.  If the indentation
>> engine of the inner mode just see the code chunks, there is a potential
>> problem...

> I think the string value is not ideal, because then the inner mode can't 
> cache syntactic information, and reuse it between chunks. This is 
> something we probably want to facilitate.

Originally, I had some inner mode dependent value here.  Stefan had
objections, because mode-specific stuff in a generic value is not that
nice (agreed) and the outer mode would need to know inner mode internals.

For caching, I can imagine the following:

 - the inner mode does at least cache the syntactic info for the last
   string (for the grammar case, you would almost ever have a cache hit)

 - the inner mode is encouraged to change PREVIOUS-CHUNKS inside
   `prog-indentation-context' to the inner mode specific value.  The
   outer mode can retrieve the value after the call and use it for
   further calls.

> Adapting the current major mode indentation code to work with either 
> kind of PREVIOUS-CHUNKS value, looks non-trivial as well.

For the string value (for grammars = the case I am interested in):
looks manageable

 - I could later add a corresponding patch to cc-mode, see below

 - in general, the inner mode could insert the string at START inside a
   `call-with-transparent-undo' (XEmacs, whatever the Emacs equivalent
   is)

The get-previous-chunk function case (for literate programming = the
case Stefan and you, Dmitry, were interested in): I agree, this is
non-trivial (see my remarks back in Feb/Mar).

> I don't currently have a better suggestion, though. But this proposal 
> could use a corresponding patch to cc-mode.

Well, I really like to see something included in Emacs before I spend
more time on this.

My suggestion:

 1.  Stefan tells me what he had against the "should" in the docstring
    of `prog-widen' (and/or sends me a corrected docstring).

    I reduce the patch to NOT include PREVIOUS-CHUNKS (and use the
    widen-feature of narrow-to-region ;-))

 2. If that is included, I reintroduce PREVIOUS-CHUNKS and include a
    corresponding patch to cc-mode - but only for the "string/grammar
    case"

-- Christoph



reply via email to

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