emacs-devel
[Top][All Lists]
Advanced

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

Re: [Emacs-diffs] scratch/widen-less a4ba846: Replace prog-widen with co


From: Wedler, Christoph
Subject: Re: [Emacs-diffs] scratch/widen-less a4ba846: Replace prog-widen with consolidating widen calls
Date: Mon, 18 Dec 2017 12:39:09 +0000
User-agent: Microsoft-MacOutlook/f.29.0.171205

Dmitry Gutov wrote:

> Is there a reason why you called narrow-to-region in
> antlr-python-indent-action-line anyway, even when using
> prog-indentation-context?  Because you do that, though, the "new way"
> should work with your code automatically.

Prophesy, I guess ;-)

> I'm attaching a patch with some minor cleanup, though.

To be honest, I am not so sure about the cleanup.  I think it is better
to dynamically bind `syntax-ppss-cache' and `syntax-ppss-last' while
letting python-mode do its thing: neither should python-mode use the
cache state set from the ANTLR syntax, nor should antlr-mode later use
the syntax state set by pathon-mode.  Or do I miss something?

> Please try it with a build of Emacs from the 'widen-less' branch. Do you 
> know how to build it?

It seems to have worked, even on a MacOS - good!  To do it without much
Additional installation for the moment, I used
    ./configure --with-ns --without-makeinfo --with-gnutls=no

>> I you want to try some ANTLR grammar examples yourself, I would
>> recommend:
>>   - antlr-mode 3.1.4
>>     from https://sourceforge.net/projects/antlr-mode/files/
>>   - example grammar files, especially lines 46 to 51 in
>>     https://github.com/antlr/examples-v3/blob/master/Python/C/C.g
>>   - and others in that repo (mentioned in line 100 of antlr-mode.el)

> antlr-mode.el says these examples are to see the syntax highlighting. 
> Any particular file and place to see how indentation works out? I 
> couldn't find one from a cursory search.

Are you sure that you use antlr-mode 3.1.5 (not the one from Emacs)?
Everything works for me with Emacs-26.0.90, too – I also tried an empty
init.el…

>> Now to a mode with non-widening indentation function: emacs-lisp mode:
>> Consider the following code
>>      (defun foo ()
>>        (+ 1 3))
>>
>> I would assume that the indentation of line 2 does not change
>> when I narrow to line 2 - but Emacs-25.1.1 now deletes the first 2
>> spaces of line 2...  (yes; I also need to update to a newer Emacs)

> Try out the widen-less branch!

Ehem, still the same...

> And also, can we get your help with the manual? It still says:

> Examples include
>  @dfn{literate programming} source files that combine documentation and
>  snippets of source code, Yacc/Bison programs that include snippets of
>  plain C code, etc.  To correctly indent the embedded chunks, the primary
>  mode needs to delegate the indentation to another mode's indentation
>  engine (e.g., call @code{c-indent-defun} for C code or
>  @code{python-indent-line} for Python)

> I.e., it still mentions C and c-indent-defun (?). But c-indent-defun 
> does not work for embedded chunks (yet)!

> Can we replace that mentions with JS and js-indent-line, for instance? 
> Would that still make sense?

Yes, using `js-indent-line' is a better example.
`c-indent-line' (c-indent-defun looks like a typo) is tricky - see my
ugly function `antlr-indent-line' (but I have a TODO...)

P.S. I will probably "borrow" (aka "steal") from mhtml-mode.el later...




reply via email to

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