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: Stefan Monnier
Subject: Re: antlr-mode.el - need some support by python.el
Date: Mon, 16 Feb 2015 14:23:25 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

>>>> Not necessarily: the submode can just go to the end of the previous
>>>> chunk, compute some state at that position and use that state as initial
>>>> context at MIN.
>>> ... if scan-lists, mode-specific skip-comments etc are prepared for this.
>> That's the responsibility of the sub-mode.
> To get support by the authors of potential sub-modes, I would really
> like to keep the effort for the sub-modes small.
> Given that the indentation code of many prog-modes is probably the most
> complex part, I would understand if the authors do not want to change it
> considerably just to support some special-topic major mode.

But it's not like there are many other options.  The options are either:
- the submode doesn't know how to use previous chunks, so it doesn't
  work correctly when the code is split into related chunks.
- the submode does know how to parse and connect the various chunks.
In either case, the outer mode can't do anything more than provide the
boundaries and relationships between the various chunks (e.g. in the
case of antlr, I guess the relationship is that each chunk for an action
is independent) because the outer mode can't know what info the submode
might need to propagate from one chunk to the other.

IOW, what I stated is not a design choice, it's just a fact of life.

>  4. SUB provides a function which creates a valid value for
>     `SUB-extra-indentation-context' - valid arguments for that function
>     would either be a string, or a list of buffer ranges.

>     For C (assuming that a valid value for `c-extra-indentation-context'
>     would look like the return value of `c-guess-basic-syntax'), this
>     function could simply put the string / buffer chunks into a
>     temporary buffer and call `c-guess-basic-syntax' at eob.

>     In my use case, I would run this function once - in the literate
>     programming case, you would run it whenever you delegate the
>     indentation to the sub mode.

>  5. If SUB decides that it can support the "multi-chunk case" directly
>     in the indentation code (e.g. for performance improvements), it can
>     do so without any change in the call by the main mode - the function
>     introduced in stage 4 would then simply return the buffer-positions.

I don't see much difference between 4 and 5: basically, the difference
is between putting the code in the outer-mode or in the submode, but
it'll be the same code.  And since this code is submode-specific, I'd
rather skip the step 4.  If the submode can't be modified (e.g. the
author doesn't want to cooperate or you want your outer mode to work
with older versions), then we can use with-eval-after-load, add-hook,
add-advice and friends to get the effect of 4 without having explicit
support for it.

In any case your patch looks good, feel free to install it.


        Stefan



reply via email to

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