all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "João Távora" <joaotavora@gmail.com>
Cc: casouri@gmail.com, spacibba@aol.com, emacs-devel@gnu.org
Subject: Re: c-ts-mode
Date: Thu, 07 Sep 2023 20:10:09 +0300	[thread overview]
Message-ID: <83y1hhykni.fsf@gnu.org> (raw)
In-Reply-To: <CALDnm538YLwn=JeKaHANsDp2AMBDSHNYtmPHB0gcHriFLqrUPA@mail.gmail.com> (message from João Távora on Thu, 7 Sep 2023 16:58:29 +0100)

> From: João Távora <joaotavora@gmail.com>
> Date: Thu, 7 Sep 2023 16:58:29 +0100
> Cc: casouri@gmail.com, spacibba@aol.com, emacs-devel@gnu.org
> 
> On Thu, Sep 7, 2023 at 10:37 AM Eli Zaretskii <eliz@gnu.org> wrote:
> 
> > Some of the styles are already supported.  The rest should also be
> > possible (at least most of them), but someone will have to write the
> > code.  It is not a simple matter of "importing", since CC Mode
> > implements these features based on infrastructure that either doesn't
> > exist or makes no sense in treesit-supported modes.
> 
> Thanks for clarifying.  My current cc-mode user style is very
> simple (I think) it inherits from the 'gnu' style and adds
> minimal things.
> 
> (c-add-style "user"
>              '("gnu"
>                (c-special-indent-hook)
>                (c-offsets-alist
>                 (substatement-open . 0)
>                 (namespace-open . -2)
>                 (innamespace . -2)
>                 (extern-lang-open . -2)
>                 (inextern-lang . -2))))
> 
> Basically I'd just like to keep code inside top-level
> C++ namespaces and extern blocks unindented.
> As to substatement-open I don't even know what
> the purpose is anymore.
> 
> I see that c++-ts-mode already has a gnu user style, so
> I would just need to add my preferences.  Is there a manual
> entry somewhere for learning how to do this?

I think c-ts-mode--indent-styles needs to be refactored toallow fine
control on the indentation parameters that are currently hard-coded
for each supported style.  They will need to have different names,
because tree-sitter doesn't use the CC Mode terminology for the
syntactical constructs.  Also, there seem to be many more parameters
than in CC Mode.

> Also, if I may go on a tangent:  Is the forward-sexp-function
> for c++-ts-mode currently undergoing work on master?  It
> doesn't seem to work and all C-M-foo navigation is broken as
> a result.
> 
> Debugger entered--Lisp error: (treesit-invalid-predicate nil)
>   treesit-node-match-p(#<treesit-node ";" in 41-42> sexp t)
>   #f(compiled-function (node) #<bytecode
> 0x197a9d284470c5e2>)(#<treesit-node ";" in 41-42>)
>   treesit-node-top-level(#<treesit-node ";" in 41-42>
> #f(compiled-function (node) #<bytecode 0x197a9d284470c5e2>) t)
>   treesit--things-around(47 sexp)
>   treesit--navigate-thing(47 1 end sexp restricted)
>   treesit-end-of-thing(sexp 1 restricted)
>   treesit-forward-sexp(1)

First, please submit a bug report about this with all the details.

And second, I don't seem to be able to reproduce this, assuming that
by C-M-foo you meant C-M-f and C-M-b.  Maybe this needs some
particular source file to reproduce?  (I tried with one C file and one
C++ file.)

> Setting the variable to nil brings me to more familar
> and satisfactory terrain where, and I suppose the non-treesit
> syntax table is being used for that.  Is there any big
> advantage in switching to treesitter's forward-sexp-function?

Yes, see treesit-defun-tactic.



  reply	other threads:[~2023-09-07 17:10 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <r6t7xfcchagyl72ltdrcavncbpvba7badcoh4yimleoynmzfvb.ref@elkspm3vozuv>
2023-08-30 23:52 ` c-ts-mode Ergus
2023-09-01  4:14   ` c-ts-mode Yuan Fu
2023-09-07  9:25     ` c-ts-mode João Távora
2023-09-07  9:37       ` c-ts-mode Eli Zaretskii
2023-09-07 15:58         ` c-ts-mode João Távora
2023-09-07 17:10           ` Eli Zaretskii [this message]
2023-09-07 17:53             ` c-ts-mode João Távora
2023-09-07 18:13               ` c-ts-mode Eli Zaretskii
2023-09-07 18:23                 ` c-ts-mode João Távora
2023-09-07 18:32                   ` c-ts-mode Eli Zaretskii
2023-09-07 22:01                     ` c-ts-mode João Távora
2023-09-08  6:14                       ` c-ts-mode Eli Zaretskii
2023-09-08  7:25                         ` c-ts-mode João Távora
2023-09-08 11:25                           ` c-ts-mode Eli Zaretskii
2023-09-08 12:38                             ` c-ts-mode João Távora
2023-09-08 13:11                               ` c-ts-mode Eli Zaretskii
2023-09-08 13:32                                 ` c-ts-mode Eli Zaretskii
2023-09-08 15:15                                   ` c-ts-mode João Távora
2023-09-08 15:34                                     ` c-ts-mode Eli Zaretskii
2023-09-08 15:56                                       ` c-ts-mode João Távora
2023-09-08 18:23                                         ` c-ts-mode Eli Zaretskii
2023-09-08 18:30                                           ` c-ts-mode João Távora
2023-09-08 18:54                                             ` c-ts-mode Eli Zaretskii
2023-09-08 19:42                                               ` c-ts-mode João Távora
2023-09-09  6:09                                                 ` c-ts-mode Eli Zaretskii
2023-09-08 19:58                               ` c-ts-mode Petteri Hintsanen
2023-09-08 20:27                                 ` c-ts-mode João Távora
2023-09-09  6:19                                 ` c-ts-mode Eli Zaretskii
2023-09-13 16:15                                   ` c-ts-mode Petteri Hintsanen
2023-09-12  0:34                             ` c-ts-mode Yuan Fu
2023-09-12  7:45                               ` c-ts-mode João Távora
2023-09-12  8:00                                 ` c-ts-mode Po Lu
2023-09-12  9:51                                   ` c-ts-mode João Távora

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83y1hhykni.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=casouri@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=joaotavora@gmail.com \
    --cc=spacibba@aol.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.