[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#75122: Treesit support for show-paren-mode
From: |
Juri Linkov |
Subject: |
bug#75122: Treesit support for show-paren-mode |
Date: |
Fri, 27 Dec 2024 09:37:50 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) |
>> +(defun treesit-show-paren-data ()
>> + "A function suitable for `show-paren-data-function' (which see)."
>> + (let* ((node (treesit-thing-at (point) 'sexp-list))
>> + (beg (when node (treesit-node-start node)))
>> + (end (when node (treesit-node-end node))))
>> + ;; When after the closing node, try the previous position inside the
>> node
>
> The comment doesn't seem to correspond to the code, or anyway to all the
> cases the code might be handling? I might misunderstand, though.
Sorry for the unclear comment. I meant that when detecting
the opening node we should use (point). But for detecting
the closing node we need to check (1- (point)) that is
inside the balanced node at the end of the node.
>> + (unless (or (eq (point) beg) (eq (point) end) (bobp))
>> + (setq node (treesit-thing-at (1- (point)) 'sexp-list)
>> + beg (when node (treesit-node-start node))
>> + end (when node (treesit-node-end node))))
>
> Without getting into more details, it seems the user options
> show-paren-when-point-inside-paren and show-paren-when-point-in-periphery
> are not handled (don't have any effect).
Thanks for referencing these options. I didn't dig deeper since
I didn't see these options in the SMIE implementation. But
these options definitely should be consulted to adjust the location
used in '(treesit-thing-at (1- (point)) ...'
> Not sure what's needed for that, but FWIW SMIE's show-paren integration
> seems to react to the value of the first of these options (even though it's
> never referenced directly in smie.el), while the second one is not
> supported there either.
This is strange since neither is referenced in smie.el.
Ok, need to investigate more.