From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill Newsgroups: gmane.emacs.devel Subject: Re: Missing features in c-ts-mode Date: Wed, 15 Feb 2023 20:59:13 +0100 Message-ID: <871qmq7l9q.fsf@thornhill.no> References: <83wn4iajyy.fsf@gnu.org> <87fsb67pfj.fsf@thornhill.no> <83lekyagwy.fsf@gnu.org> <87a61e7n5j.fsf@thornhill.no> <877cwi7mju.fsf@thornhill.no> <83bkluaevv.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23619"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Feb 15 21:00:15 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pSNwt-00060d-4y for ged-emacs-devel@m.gmane-mx.org; Wed, 15 Feb 2023 21:00:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSNw4-0006EH-Nx; Wed, 15 Feb 2023 14:59:25 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSNw1-0006Df-3u for emacs-devel@gnu.org; Wed, 15 Feb 2023 14:59:21 -0500 Original-Received: from out-12.mta0.migadu.com ([91.218.175.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSNvy-000587-Pa for emacs-devel@gnu.org; Wed, 15 Feb 2023 14:59:20 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1676491154; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XRH/pvlsxH/NqsD31WPVMtI6U7758Qa/rNci0DCMqhw=; b=qjrY6nmPnAEcMXBE898V2I6LFe0L/biXnKWWPdskfgAoQB70JYKVulwWc5PIr9KxDVHmH3 rWml9o4vxsHkRlxfBpP9FropbcLNU5zRCvCfl5SNoUSGPQn7WGF9nP/rM9CIMRrDNvfQgW TUfe4GjtBvKRuC05UyWdV31dsTiXz7XkeD5yviP+LuR7xnRGFZk+RJnYFeKsZdqz1ezLZs biYE3uFLKgSTGrXXRds/g+eZh0zSMYjqfgolppvA3ZkdhZCdFLfuv+OSt6Us53e3NnO9BX 4YJ65qABGptg71xNdxch22sY7dYgBx3aCcGhvXCHX40cfxUL4pt4PVijviuSag== In-Reply-To: <83bkluaevv.fsf@gnu.org> X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=91.218.175.12; envelope-from=theo@thornhill.no; helo=out-12.mta0.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:303339 Archived-At: Eli Zaretskii writes: >> From: Theodor Thornhill >> 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