[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Missing features in c-ts-mode
From: |
Theodor Thornhill |
Subject: |
Re: Missing features in c-ts-mode |
Date: |
Wed, 15 Feb 2023 20:59:13 +0100 |
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Theodor Thornhill <theo@thornhill.no>
>> Cc: casouri@gmail.com, emacs-devel@gnu.org
>> Date: Wed, 15 Feb 2023 20:31:33 +0100
>>
>> This patch adds some support for this- but I'm not really satisfied yet.
>> It will electrically indent if you've typed "#i", or if you insert "#"
>> before say, "if". The reason it behaves this way right now is that the
>> parser returns an (ERROR (ERROR)) node when only # is inserted. I'll
>> see if I can find some workaround for it.
>
> Thank you for working on this.
Ok so I found a way which will probably work well. I just need to
figure out if there are any other cases where we get the (ERROR (ERROR))
pattern. If not I'll add some tests and also this:
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 020f2642ac2..a60c464093e 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -219,6 +219,7 @@ c-ts-mode--indent-styles
MODE is either `c' or `cpp'."
(let ((common
`(((parent-is "translation_unit") point-min 0)
+ ((query "(ERROR (ERROR)) @indent") point-min 0)
((node-is ")") parent 1)
((node-is "]") parent-bol 0)
((node-is "else") parent-bol 0)
@@ -785,7 +786,7 @@ c-ts-base-mode
;; Electric
(setq-local electric-indent-chars
- (append "{}():;," electric-indent-chars))
+ (append "{}():;,#" electric-indent-chars))
;; Imenu.
(setq-local treesit-simple-imenu-settings
- Missing features in c-ts-mode, Eli Zaretskii, 2023/02/15
- Re: Missing features in c-ts-mode, Theodor Thornhill, 2023/02/15
- Re: Missing features in c-ts-mode, Eli Zaretskii, 2023/02/15
- Re: Missing features in c-ts-mode, Theodor Thornhill, 2023/02/15
- Re: Missing features in c-ts-mode, Theodor Thornhill, 2023/02/15
- Re: Missing features in c-ts-mode, Eli Zaretskii, 2023/02/15
- Re: Missing features in c-ts-mode,
Theodor Thornhill <=
- Re: Missing features in c-ts-mode, Theodor Thornhill, 2023/02/16
- Re: Missing features in c-ts-mode, Eli Zaretskii, 2023/02/16
- Re: Missing features in c-ts-mode, Theodor Thornhill, 2023/02/16
- Re: Missing features in c-ts-mode, Ergus, 2023/02/17
- Re: Missing features in c-ts-mode, Eli Zaretskii, 2023/02/17
- Re: Missing features in c-ts-mode, Theodor Thornhill, 2023/02/17
- Re: Missing features in c-ts-mode, Eli Zaretskii, 2023/02/17
- Re: Missing features in c-ts-mode, Ergus, 2023/02/17
- Re: Missing features in c-ts-mode, Theodor Thornhill, 2023/02/17
- Re: Missing features in c-ts-mode, Ergus, 2023/02/17