[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Extending define-derived-mode
From: |
Yuan Fu |
Subject: |
Re: Extending define-derived-mode |
Date: |
Thu, 8 Jun 2023 00:25:53 -0700 |
> On Jun 5, 2023, at 4:33 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> From: Yuan Fu <casouri@gmail.com>
>> Date: Mon, 5 Jun 2023 00:31:02 -0700
>> Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
>> emacs-devel <emacs-devel@gnu.org>,
>> Mickey Petersen <mickey@masteringemacs.org>,
>> Theodor Thornhill <theo@thornhill.no>,
>> dgutov@yandex.ru
>>
>>> For users to be able to share stuff like electric-quote-local-mode
>>> we'd need to rewrite those supporting modes to allow that. When one
>>> of the two modes uses regexps and syntax tables, whereas the other
>>> uses treesit-based parsers, this is not a trivial task. I invite you
>>> to audit the various electric modes we have and see how many of them
>>> can be shared with minimum effort between non-TS and TS modes.
>>
>> I’m talking about sharing the sharable config. Electric modes already work
>> the same in ts and non-ts modes: electric-pair-mode and electric-quote-mode
>> inserts matching pairs and quotes and aren’t affected by tree-sitter,
>> electric-indent-mode uses the standard indent-line-function which both ts
>> and non-ts modes confront to. Is there any other electric modes?
>
> For one prominent example, see the node "Electric Keys" in the CC Mode
> manual, and the minor modes described in "Minor Modes" there.
Ok, but they are CC mode’s features, not Emacs-wide features like
electric-quote/pair/indent-mode.
>
>> Also, ts modes generally have the same syntax table as non-ts modes. So if
>> some package uses the syntax table they are largely not affected either.
>
> But it makes little sense to me to have part of a mode use our syntax
> tables, and another part use the results of parsing the code by a
> parser library. I can guarantee inconsistencies.
Not really used by the mode itself, but some generic third-party package.
Having correct information in the syntax table is better than not. Also some ts
modes enhances the syntax table information, making it more accurate, by adding
appropriate syntax-table text property on some chars, like the angle brackets
in C++ and Rust.
Yuan
Re: Extending define-derived-mode, Yuan Fu, 2023/06/02