[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#19080: 24.4; wish: enable show-paren-mode to highlight matching same
From: |
Yuan Fu |
Subject: |
bug#19080: 24.4; wish: enable show-paren-mode to highlight matching same-level keywords |
Date: |
Fri, 13 May 2022 22:05:51 -0700 |
> On May 12, 2022, at 10:52 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> From: Yuan Fu <casouri@gmail.com>
>> Date: Thu, 12 May 2022 15:52:14 -0700
>> Cc: Lars Ingebrigtsen <larsi@gnus.org>,
>> josh@berdine.net,
>> 19080@debbugs.gnu.org
>>
>>> We could perhaps add a new feature, based on tree-sitter, to highlight
>>> a block of code, where the block is defined by PL rules, not by
>>> parens, braces, and similar simple syntactic elements.
>>>
>>> Yuan, WDYT? Can this be added to the tree-sitter branch perhaps?
>>
>> That sounds interesting, and it should be easy. But what do we want the API
>> be? First of all, should we make a separate mode or extend show-paren-mode?
>> Extending show-paren-mode entails doing some non-trivial refactoring to
>> paren.el.
>
> IMO, it should be a separate minor mode; show-paren-mode is not
> necessarily about program blocks, since parentheses appear not only
> (and mostly not) as block delimiters.
Cool! I can do whatever I want then ;-)
>
> The API should be probably: given a buffer POSITION, return the 2
> positions of the innermost enclosing block, or nil if POSITION is not
> in any block. A possible extension could be to return a list of
> position pairs that provide also the blocks enclosed inside the
> POSITION's block.
Ok.
>
>> I think, that adding tree-sitter “backend” needs refactoring existing code
>> non-trivially.
>
> If show-paren-mode would want to use tree-sitter, it will need
> refactoring, yes. Which other packages you envision could benefit
> from using tree-sitter?
I remember looking at some structured editing tool, but I can’t think of one on
top of my head :-(
Yuan