From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 23 16:43:36 2023 Received: (at submit) by debbugs.gnu.org; 23 Mar 2023 20:43:36 +0000 Received: from localhost ([127.0.0.1]:39427 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pfRmZ-0004oN-Dc for submit@debbugs.gnu.org; Thu, 23 Mar 2023 16:43:36 -0400 Received: from lists.gnu.org ([209.51.188.17]:49238) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pfRmX-0004oE-SO for submit@debbugs.gnu.org; Thu, 23 Mar 2023 16:43:34 -0400 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 1pfRmX-0004AO-IB for bug-gnu-emacs@gnu.org; Thu, 23 Mar 2023 16:43:33 -0400 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pfRmU-0006mE-Ri for bug-gnu-emacs@gnu.org; Thu, 23 Mar 2023 16:43:33 -0400 Received: by mail-ed1-x52d.google.com with SMTP id x3so91528edb.10 for ; Thu, 23 Mar 2023 13:43:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679604208; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=/X+F15gsQNGtlnfvKkw++t6y3Mut3uzIlggTy108X/c=; b=f6hmxobeku4Xx/2CUz42A1Q+cEY1iP1IC8pm4XkRlJ/EPkzJsvkiF0zoCFYPlXn/Gj t17LgH5PgyhEfZf28ox6OHJ0KHNO3Bjc4+52UJ1kdYo2Hkjoh0k0XFoF0dXypjFNZuGV fMmaod2uSTusBaLUT5U7/rGNwYPuFHfL4lsNHQO7XS5qTrH7LycjbLyv+qjQZv0A1VUq yXldACYjRCdcvBGGfaKNEPGRayGdhnKhGSE6Y7ON4NIErhU6BBwmd+uLnw+6hHY/1RZ2 DuDYuiZmLshuRXhTlXiFd15ALPL4D8zYN4Vqex5kJ7H1kZxyfLjrGhvOrIYQBaXvEh35 Vcxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679604208; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=/X+F15gsQNGtlnfvKkw++t6y3Mut3uzIlggTy108X/c=; b=Hj8++C6ahPsuGQkp7gKZCvTbGWuhILwKQDcGYiIW6iV7XHo+Rz1nDX7QZzbgdo2IeY pqo8BxhC6+0vfsR1QhIEXK6fTRNMN3HF+7aBuUADvhMFe6w8NXNdYqVprD76V0ds46aM MyacEWCScSARAFPaZtC8yGl9AAVDBCYjuvdrauPQTgx/Ywg2Gv6vRdczYWSl+gxkXJWz pBJEzY7Gx/eoMx7/L4IJnvs0b+AoTroFgKsaaaDpBNCPJE+PzciCNssMNOyMHI8PCX24 CttVELdefGTDqP+ji6xkkcIy2P779ffMisaaDI7CIMHKfdziDfdwUVRN7l4o4/nMTjIg u3Sw== X-Gm-Message-State: AAQBX9f3KZ8+n7pWmHqWoZIFoF7ANoA7XyIOQ34sXG8SzRgF6IB64mHh wxrAfAuCWoO/mpkvLWju7YY4ZShV5CY= X-Google-Smtp-Source: AKy350abch5+LtUnigxAoEiuIfuKI35QrWT3/JBKf+JBBDcDlr2rVqdJlgopln/KMASMrL6sq4tMxQ== X-Received: by 2002:a17:906:9241:b0:932:cec7:6801 with SMTP id c1-20020a170906924100b00932cec76801mr352234ejx.54.1679604208136; Thu, 23 Mar 2023 13:43:28 -0700 (PDT) Received: from [192.168.8.108] (netacc-gpn-204-172-116.pool.yettel.hu. [5.204.172.116]) by smtp.gmail.com with ESMTPSA id 11-20020a170906318b00b008d606b1bbb1sm9088045ejy.9.2023.03.23.13.43.27 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Mar 2023 13:43:27 -0700 (PDT) Message-ID: <41859726-8f6d-c8d9-5a56-b0c98c153391@gmail.com> Date: Thu, 23 Mar 2023 21:43:26 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Content-Language: en-US To: bug-gnu-emacs@gnu.org From: "Herman, Geza" Subject: 29.0.60; strange c++ indentation behavior with tree sitter Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=geza.herman@gmail.com; helo=mail-ed1-x52d.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Copy this half-written program to a c++-ts-mode buffer: ----- 8< ----------------------- void foo() {   for (int i=0 } int main(int argc, char *argv[]) { } ----- 8< ----------------------- Move the point to the end of the line of the for loop, and press ";" (as if you continued to write the loop). Notice that the line will lose its indentation ("for" will be moved to column 1). If you continue writing the for loop, it will be correctly re-indented after the closing parenthesis (for example, continue the line with "; i<10; i++)", and notice that after pressing ")", the line will be re-indented). This doesn't happen if the main function is deleted. I'm not sure whether this is a tree-sitter or emacs problem, but I reported here because I think it's more likely that this is some emacs problem. In GNU Emacs 29.0.60 (build 1, x86_64-pc-linux-gnu, GTK+ Version  3.24.36, cairo version 1.16.0) of 2023-03-23 built on okoska Repository revision: d93a439846f03dfb2be28d6b5c2e963ef6be0c22 Repository branch: emacs-29 Windowing system distributor 'The X.Org Foundation', version 11.0.12101006 System Description: Debian GNU/Linux bookworm/sid Configured using:  'configure --with-native-compilation=aot --without-compress-install  --with-json --with-xinput2 --with-xwidgets --with-tree-sitter  --with-cairo' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM XWIDGETS GTK3 ZLIB Important settings:   value of $LC_ALL: C.UTF-8   value of $LANG: en_US.UTF-8   value of $XMODIFIERS: @im=none   locale-coding-system: utf-8-unix Major mode: C++// Minor modes in effect:   tooltip-mode: t   global-eldoc-mode: t   show-paren-mode: t   electric-indent-mode: t   mouse-wheel-mode: t   tool-bar-mode: t   menu-bar-mode: t   file-name-shadow-mode: t   global-font-lock-mode: t   font-lock-mode: t   blink-cursor-mode: t   line-number-mode: t   indent-tabs-mode: t   transient-mark-mode: t   auto-composition-mode: t   auto-encryption-mode: t   auto-compression-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util text-property-search time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils c-ts-mode c-ts-common treesit comp comp-cstr warnings icons subr-x rx cl-seq cl-macs gv cl-extra help-mode bytecomp byte-compile cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads xwidget-internal dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit xinput2 x multi-tty make-network-process native-compile emacs) Memory information: ((conses 16 109621 7046)  (symbols 48 9139 0)  (strings 32 26509 2321)  (string-bytes 1 916195)  (vectors 16 18595)  (vector-slots 8 371251 16029)  (floats 8 33 41)  (intervals 56 351 0)  (buffers 984 12)) From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 24 14:17:50 2023 Received: (at 62412) by debbugs.gnu.org; 24 Mar 2023 18:17:50 +0000 Received: from localhost ([127.0.0.1]:41334 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pflz4-00011d-04 for submit@debbugs.gnu.org; Fri, 24 Mar 2023 14:17:50 -0400 Received: from mail-pl1-f175.google.com ([209.85.214.175]:46911) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pflz2-00011N-EO for 62412@debbugs.gnu.org; Fri, 24 Mar 2023 14:17:49 -0400 Received: by mail-pl1-f175.google.com with SMTP id kq3so2559716plb.13 for <62412@debbugs.gnu.org>; Fri, 24 Mar 2023 11:17:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679681862; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=FcabfB+2wP/Qq/Jngi3CRs2jl5u4f1Hy0BVZcr93d4U=; b=muom3fN6tklbv8OSGHilIPh7VgVAk8BjmujAQ2OsMy+It5gkM3Zu2bXYeVAWY1b4Cd T4fkjDjEeicxwA9aQ+n+WohEd+d6OzSEABi7otlgc2sUH1KMlKAD2Ie/2T2wysy7yGwi xp57MP5UsXf+e1kLK5RTQzEHA7NvBvDGDVozA+hMtFIT8C0kJny9uD+SdZUxY5KbRBRw 4SR3Cr0LOPQ3Kx0Yn8Y908RliP2ePk/j7uXmsVSH91dyuhj9QDZN+Qgei6GYXvqNwPk7 R+N/xYFN/XN3Ko2r+YA1o9uUYGlpYGrF9ROWMdasNhfsW4G/2+LUnaZGjvmbRqgX7Qqb G1DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679681862; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FcabfB+2wP/Qq/Jngi3CRs2jl5u4f1Hy0BVZcr93d4U=; b=fkmOgLF4mabLs+r34hmiE34OiQxj6xE1FJ2fS1NVwyORFxp2lz8yLAA0UMO4s5BQQl UtGU/NT5eYAkl1lMbVsYbqzSUaNrVPmluZ2VsnicjbiaeI3D+YOdCZwVeUAnwmdNbe6B bCqqb9GGGhGn4rwEV++6AfpxRe3wrP7POvsxjOGzPsWFg4JA0/a3bJ7ctYpPQECYpK2C j38TNDrKY2hPjvmk7uNPHqVwPedLELIChCx4gITaWHWQnFFh38G2d2WyBaBRFdZfIhmH SSBDLYeJrpwkAMa1xGNO/U7MdI3zLO3IKLoHfzQjp2kiyCMv9DeX8nbjcfQ2hfq90nvh uDzA== X-Gm-Message-State: AAQBX9ey4lXhozd0Y5ZrwEicJjiPI9cjlqNYEu/2tAcaNJF/DmGETsL8 Hw0Fy68ssl0v8GkjlbieEMs= X-Google-Smtp-Source: AKy350YFOaUAAtcAnDohkF5xGLqQxVt+VMnHdLtjXRAyIHT87OpSEUuPH5YyWpElun5x74wGrYMtoA== X-Received: by 2002:a17:90a:e7cf:b0:23c:8ee2:bc14 with SMTP id kb15-20020a17090ae7cf00b0023c8ee2bc14mr4477949pjb.24.1679681862285; Fri, 24 Mar 2023 11:17:42 -0700 (PDT) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id g4-20020a17090adb0400b0023f8bdc4a7fsm217495pjv.14.2023.03.24.11.17.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Mar 2023 11:17:41 -0700 (PDT) From: Yuan Fu Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.400.51.1.1\)) Subject: Re: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter Message-Id: <2496F2A0-3EB1-4CD2-B299-E1DC41B7C23B@gmail.com> Date: Fri, 24 Mar 2023 11:17:28 -0700 To: geza.herman@gmail.com X-Mailer: Apple Mail (2.3731.400.51.1.1) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62412 Cc: 62412@debbugs.gnu.org, theodor thornhill X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) "Herman, Geza" writes: > Copy this half-written program to a c++-ts-mode buffer: > > ----- 8< ----------------------- > > void foo() { > for (int i=3D0 > } > > int main(int argc, char *argv[]) { > } > > ----- 8< ----------------------- > > Move the point to the end of the line of the for loop, and press ";" > (as if you continued to write the loop). Notice that the line will > lose its indentation ("for" will be moved to column 1). If you > continue writing the for loop, it will be correctly re-indented after > the closing parenthesis (for example, continue the line with "; i<10; > i++)", and notice that after pressing ")", the line will be > re-indented). > > This doesn't happen if the main function is deleted. I'm not sure > whether this is a tree-sitter or emacs problem, but I reported here > because I think it's more likely that this is some emacs problem. I believe this is due to this rule: ((query "(ERROR (ERROR)) @indent") column-0 0) I=E2=80=99m not sure about the original purpose for this rule, CC=E2=80=99= ing Theo. Yuan From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 24 16:04:39 2023 Received: (at 62412) by debbugs.gnu.org; 24 Mar 2023 20:04:39 +0000 Received: from localhost ([127.0.0.1]:41421 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pfneQ-00042D-KW for submit@debbugs.gnu.org; Fri, 24 Mar 2023 16:04:38 -0400 Received: from out-43.mta1.migadu.com ([95.215.58.43]:13607) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pfneK-000420-8q for 62412@debbugs.gnu.org; Fri, 24 Mar 2023 16:04:36 -0400 Date: Fri, 24 Mar 2023 21:04:24 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1679688268; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=csgAqGWlhp0P6s6n1oepWNQVg1X1T4N9cLNQBjjRruA=; b=p6HEBiqqcOp1Y3UJHMGRbN6s8fohymwm1KYLpR5VMxtFtxE3IPBCRs2twopg848QvbTSDA mQqotsgbLFTOkGKIOzSbfCaQjQ8ZWQoJUOHMlOugaJuKoxqsmg/5zmCfaXevLnxtPG/m50 JyizRw7XmS/uYfbMXFVComGqOvKb7Y3OF44XVJfpog8tHisTJxNOIAQkeDU4t8Nzj7PWwT 461UXBySqCc9aBYRia1SFXBCl4grrYowHwnRSs7yG7/jp3qq6wwFQweYt1Ve/+fvV9DROr WGizRzjaIKl3y76HuXlugZ+GWnO1dlwZZ3L/UiOrRETfyZyvkyhwcQxKjFRbCw== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill To: Yuan Fu , geza.herman@gmail.com Subject: =?US-ASCII?Q?Re=3A_bug=2362412=3A_29=2E0=2E60=3B_strange_c++_i?= =?US-ASCII?Q?ndentation_behavior_with_tree__sitter?= In-Reply-To: <2496F2A0-3EB1-4CD2-B299-E1DC41B7C23B@gmail.com> References: <2496F2A0-3EB1-4CD2-B299-E1DC41B7C23B@gmail.com> Message-ID: <46A6C705-97DA-4D17-999B-0536F01EFCA7@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62412 Cc: 62412@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 24 March 2023 19:17:28 CET, Yuan Fu wrote: > >"Herman, Geza" writes: > >> Copy this half-written program to a c++-ts-mode buffer: >> >> ----- 8< ----------------------- >> >> void foo() { >> for (int i=3D0 >> } >> >> int main(int argc, char *argv[]) { >> } >> >> ----- 8< ----------------------- >> >> Move the point to the end of the line of the for loop, and press ";" >> (as if you continued to write the loop)=2E Notice that the line will >> lose its indentation ("for" will be moved to column 1)=2E If you >> continue writing the for loop, it will be correctly re-indented after >> the closing parenthesis (for example, continue the line with "; i<10; >> i++)", and notice that after pressing ")", the line will be >> re-indented)=2E >> >> This doesn't happen if the main function is deleted=2E I'm not sure >> whether this is a tree-sitter or emacs problem, but I reported here >> because I think it's more likely that this is some emacs problem=2E > >I believe this is due to this rule: > >((query "(ERROR (ERROR)) @indent") column-0 0) > >I=E2=80=99m not sure about the original purpose for this rule, CC=E2=80= =99ing Theo=2E > >Yuan I'll look more deeply into the cause of this, but the rule is covering som= e preproc directives iirc=2E Unfortunately tree-sitter behaves better when auto pairs is used=2E I woul= d advise people to use electric-pairs-mode (if that's the correct name, on = mobile now) to avoid these sorts of issues=2E=20 Theo From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 25 07:48:29 2023 Received: (at 62412) by debbugs.gnu.org; 25 Mar 2023 11:48:30 +0000 Received: from localhost ([127.0.0.1]:41872 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg2Np-0003n2-GX for submit@debbugs.gnu.org; Sat, 25 Mar 2023 07:48:29 -0400 Received: from mail-yw1-f170.google.com ([209.85.128.170]:41644) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg2Nn-0003mW-Si for 62412@debbugs.gnu.org; Sat, 25 Mar 2023 07:48:28 -0400 Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-5445009c26bso81841677b3.8 for <62412@debbugs.gnu.org>; Sat, 25 Mar 2023 04:48:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679744902; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=FFnxUIu/V0icWpOQ75ljMRj8TO/h1v7LpM+cPokr39M=; b=YK92hplwlXLRP1/shBp4TSOxy0xj8raY4exOOjb2btz1iTucpyT1J62UHnOuRxuUpQ XcabBIU9rPyl6IMYyjnWr5nu9ZMTa1JrV6lQ3NgDaEfTeTnrmJkI54+e5K2lLlbEc9E7 41yCMN52obIKTIxoFlhPeBGz1anGSJpO3IRzr3QXNb7KX/c88cSLa4b5/lhgc0MJCeRk BHgqgow0gmR5h4Sroxi+6/paN3dmuv0kqZdgDkhQsNTksJpfZgzN10oFm9d5bT+suf3d iEbpumdDF6m1uLUIPAZzYApr61cpZ5iXHZ5HSMUhrwGa0zAntMlDdJ7uriIAZozIvS6Z Kvmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679744902; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FFnxUIu/V0icWpOQ75ljMRj8TO/h1v7LpM+cPokr39M=; b=eRQ7vK/zSdNow/FuzLpnMp89F4gbLi9YANlNQJyeMorm/UZyJPUZ5b48Vna8BWX8pG oV3H0TDrk0NT75pGN+RFM3sfxsXxTuiXzeKQ30Q8E9cMDutfT8mAfUA83tMLiykUrpXW v3FWZa1fvhAVXS7R3HGHH84pfj25JreJi1EHfdnHA4PW9qXrJunf8khsWEVXra78AUWP JDlZ+VVt755OHJaKC5YeyrgCdcz7N++c1+LadaHIBo5PPv5qWVksElPVkqfxcXdfEuTI RjI0qljGe2qRMq+AMyuBZwS5TqlQv8l09reW0ic8t8mAf5qtMmmexTVwd1o3zBFDGdhH +pEQ== X-Gm-Message-State: AAQBX9dvXFNXsUJgaB9LhTvkUNqorUq7YZKAYUcv0cRPx/w0w4Huax+o jthxKr1V9naySFB4Oek7vn0M6LDpor24gr3HOAGMO+Se X-Google-Smtp-Source: AK7set/5oA1LpOUNYSgaSoe7ohQC/EyBvG5rLWyUdB13lekmNpLIpE6tcV4S0KR796Nh5gZUCxtw7pWl77DES68l6DQ= X-Received: by 2002:a05:6830:1bcf:b0:68b:e0dc:abc7 with SMTP id v15-20020a0568301bcf00b0068be0dcabc7mr1950435ota.4.1679744513907; Sat, 25 Mar 2023 04:41:53 -0700 (PDT) MIME-Version: 1.0 References: <2496F2A0-3EB1-4CD2-B299-E1DC41B7C23B@gmail.com> <46A6C705-97DA-4D17-999B-0536F01EFCA7@thornhill.no> In-Reply-To: From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Sat, 25 Mar 2023 11:43:45 +0000 Message-ID: Subject: Re: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter To: =?UTF-8?Q?Herman=2C_G=C3=A9za?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62412 Cc: Yuan Fu , Theodor Thornhill , 62412@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Sat, Mar 25, 2023 at 10:26=E2=80=AFAM Herman, G=C3=A9za wrote: > > That's the difference. c++-ts-mode appends "{}():;,#" to > electric-indent-chars, while c++-mode doesn't do this. > > Nevertheless, I think that the calculated intendation should be a > correct number. Even if the user turns off electric-indent-mode, but > dedices to call re-indenting manually for a half-written for loop, emacs > should re-intent the line properly. At least, this specific example > works OK with c++-mode. > > (note that I understand that this problem is not trivial, tree > sitter/emacs may get confused if the buffer cannot be properly parsed) There can be no "correct" indentation in a buffer with an invalid state. But there are heuristics. Here, it can be argued that c++-mode's heuristics are better. Let's assume you turn off electric-indent-mode. In c++-mode, pressing RET after: int main() { "correctly" indents the next line. In c++-ts-mode, it doesn't. Both programs are ill-formed but you're right that after correcting that, by say adding 'return 0; RET }', the c++-mode version of the same program is closer to being correctly indented. But this heuristic is not always great, so it's a stick with two ends. Now let's take another invalid program: int foo() class bar { | <- cursor here } In c++-mode typing TAB indents the class line to the second column, which is arguably worse than c++-ts-mode, which doesn't do anything. That's because you may well want to work on that class and then only remember that you need the ';' for the declaration of 'foo'. IMO, it's a question of getting used to it in the end. And using electric-pair-mode helps a lot, as some have pointed out. Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 25 07:53:27 2023 Received: (at 62412) by debbugs.gnu.org; 25 Mar 2023 11:53:27 +0000 Received: from localhost ([127.0.0.1]:41897 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg2Sc-0003vT-RD for submit@debbugs.gnu.org; Sat, 25 Mar 2023 07:53:27 -0400 Received: from out-17.mta0.migadu.com ([91.218.175.17]:62284) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg2SZ-0003v2-Kh for 62412@debbugs.gnu.org; Sat, 25 Mar 2023 07:53:24 -0400 Date: Sat, 25 Mar 2023 11:19:36 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1679739578; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lBR/5b+pG0shhhvStOyR9y6GMZkVv5RPi89P/zxidr4=; b=08l9pLXiTJLWHnqZ89mRpDx4H5XnY1hdt3OYmRwe9/ISCx9a3dA7QSZAYCTwMMgwNvKVpy LaK25pjDBgeRFwtZ7TMyHJpP1QX5f7EQ1PjIJsbANe+I5YqZOxQ6Ei8q2cbx9kbetaQvRD kbHO3tzNFs3bQFZpUs8yQsFiUch0XVRX6nH8J/hZpGj6AWS5whnXYBoA29E9sCvr49ARg5 c8oF1fx3S85tzAZxJP0tWrPobnFsRZ8FKlWTBTyIW/Vo2RP1DvTyMnvshATwUqWJw/Bu5s mrMl17BDosmbbIKOfLD4s8sxPxjfORsAFGK+ktyf1uux8Y7TP/MH+bJvEJFTTg== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill To: =?ISO-8859-1?Q?Jo=E3o_T=E1vora?= Subject: =?US-ASCII?Q?Re=3A_bug=2362412=3A_29=2E0=2E60=3B_strange_c++_?= =?US-ASCII?Q?indentation_behavior_with_tree_sitter?= In-Reply-To: References: <2496F2A0-3EB1-4CD2-B299-E1DC41B7C23B@gmail.com> <46A6C705-97DA-4D17-999B-0536F01EFCA7@thornhill.no> Message-ID: <953E007D-D40A-45CD-B7EE-DF9FE4A869B3@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62412 Cc: Yuan Fu , 62412@debbugs.gnu.org, geza.herman@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 25 March 2023 09:53:31 CET, "Jo=C3=A3o T=C3=A1vora" wrote: >On Fri, Mar 24, 2023 at 10:02=E2=80=AFPM Theodor Thornhill via Bug report= s for >GNU Emacs, the Swiss army knife of text editors > wrote: >e about the original purpose for this rule, CC=E2=80=99ing Theo=2E >> > >> >Yuan >> I'll look more deeply into the cause of this, but the rule is covering = some preproc directives iirc=2E >> >> Unfortunately tree-sitter behaves better when auto pairs is used=2E I w= ould advise people to use electric-pairs-mode (if that's the correct name, = on mobile now) to avoid these sorts of issues=2E > >electric-pair-mode, it's not on by default=2E > >But, for some reason, electric-indent-mode _is_ on by default, >at least in c++-ts-mode=2E > >So this has nothing to do with tree-sitter IMO, it's just >electric-pair-mode doing its thing=2E > >Why is it on by default? A fair number of users don't like >this electricity, or prefer to have it toned down=2E At least >this has been the argument for not turning on electric-pair-mode >by default, which is a much less jarring mode IMO, and one which >would solve these problems=2E > >Jo=C3=A3o Yeah, maybe! But I was under the impression that indentation was electric = by default in most modes, but I may be mistaken=2E The reason I mentioned electric-pair-mode is that the parser fails less of= ten when the closing paren or bracket is inserted, as it is much simpler to= have a functional ast=2E From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 25 08:15:44 2023 Received: (at 62412) by debbugs.gnu.org; 25 Mar 2023 12:15:44 +0000 Received: from localhost ([127.0.0.1]:41965 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg2oC-0004bI-7j for submit@debbugs.gnu.org; Sat, 25 Mar 2023 08:15:44 -0400 Received: from mail-yw1-f177.google.com ([209.85.128.177]:45933) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg2oB-0004b6-14 for 62412@debbugs.gnu.org; Sat, 25 Mar 2023 08:15:43 -0400 Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-5418d54d77bso82493357b3.12 for <62412@debbugs.gnu.org>; Sat, 25 Mar 2023 05:15:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679746528; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bnxwTkZUUCUNhEWUcEbTql2RNVxvvUkXqh+koemogyk=; b=La63dptjhG1gGBQPKkwOt/9punGRHjvukly8q0wPfhjex2Gv9uBV+0YyKIjwVLVM32 u/+YxkPjrI1ocOtawEtgshkHoL7rgtXHvFCUb+iEOYh+Kfl6FHjSxGfspbdSfKNR1nyf p7C2t2AXcB3YrBfZJLDGZrexdlHY7bvetcNpzn1aLYAgq4tWP49AfRVa35R88n9cjbQJ TyAJx0HQO2VC+MyNEF1hPaDygNMgahWHLs6RXLppmHk31eYTcMH8OpjHcFeE+zLre2E6 NKeTjD6wc9pdD4Jzqw3/4VEaGQMAzQY8tHPSk1S4IJDbGWCeeqqZ9JaXxjS4g7IXLAor q7BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679746528; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bnxwTkZUUCUNhEWUcEbTql2RNVxvvUkXqh+koemogyk=; b=d+6+34M89sedhdM+xSjBNI1vcIFhrE0aQT9Zb2bKNI1J53hFYdHzETxir/vmBUazFt eBXUbtQbyIZhwEhg7En8WM4Ems8MUyCblrnKwVWDzxSJui1k8FvjWlPfsWBR9GVNj7V+ IsNEST6ux0yU+znvYtzUsDVSKlYIBmrdB+w2P/HNlbAWrATB0DMqKY2VKuFYCrYRMkJ1 gpt0kima8JBFsXct+VkYXvdRgli4g6LLZ6JwfsbK2mpc9NBxsKrwMNPGhZHYo2+Mq3Rs w0au+qBjTmu98o8mmUpMW7FxfbN/eTSxzLNDa8luAudAmCB/JRT5G3I8kTrqfWpFmWCE y19w== X-Gm-Message-State: AAQBX9c+vp2cMsdhgDbaIY4MhnNtXuBLNV4dhmoJTqj4Fhj43TmgqQOP jW7DcuGR7XI9+eGp7NVKdB7cBZzdOmMXO8mNjSLltdIy X-Google-Smtp-Source: AK7set8xqaggWA15Ay5Ac2f3J+Vsj2250GqkIPwygO6ibN8i3csLmpvcCBRSRshTDwXtgRfjUzmL8Jxt1byIkyBlqzk= X-Received: by 2002:a54:4716:0:b0:384:1e6a:bf10 with SMTP id k22-20020a544716000000b003841e6abf10mr1258528oik.5.1679739984065; Sat, 25 Mar 2023 03:26:24 -0700 (PDT) MIME-Version: 1.0 References: <2496F2A0-3EB1-4CD2-B299-E1DC41B7C23B@gmail.com> <46A6C705-97DA-4D17-999B-0536F01EFCA7@thornhill.no> <953E007D-D40A-45CD-B7EE-DF9FE4A869B3@thornhill.no> In-Reply-To: <953E007D-D40A-45CD-B7EE-DF9FE4A869B3@thornhill.no> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Sat, 25 Mar 2023 10:28:15 +0000 Message-ID: Subject: Re: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter To: Theodor Thornhill Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62412 Cc: Yuan Fu , 62412@debbugs.gnu.org, geza.herman@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Sat, Mar 25, 2023 at 10:19=E2=80=AFAM Theodor Thornhill wrote: > > > > On 25 March 2023 09:53:31 CET, "Jo=C3=A3o T=C3=A1vora" wrote: > >On Fri, Mar 24, 2023 at 10:02=E2=80=AFPM Theodor Thornhill via Bug repor= ts for > >GNU Emacs, the Swiss army knife of text editors > > wrote: > >e about the original purpose for this rule, CC=E2=80=99ing Theo. > >> > > >> >Yuan > >> I'll look more deeply into the cause of this, but the rule is covering= some preproc directives iirc. > >> > >> Unfortunately tree-sitter behaves better when auto pairs is used. I wo= uld advise people to use electric-pairs-mode (if that's the correct name, o= n mobile now) to avoid these sorts of issues. > > > >electric-pair-mode, it's not on by default. > > > >But, for some reason, electric-indent-mode _is_ on by default, > >at least in c++-ts-mode. > > > >So this has nothing to do with tree-sitter IMO, it's just > >electric-pair-mode doing its thing. > > > >Why is it on by default? A fair number of users don't like > >this electricity, or prefer to have it toned down. At least > >this has been the argument for not turning on electric-pair-mode > >by default, which is a much less jarring mode IMO, and one which > >would solve these problems. > > > >Jo=C3=A3o > > Yeah, maybe! But I was under the impression that indentation was electric= by default in most modes, but I may be mistaken. > > The reason I mentioned electric-pair-mode is that the parser fails less o= ften when the closing paren or bracket is inserted, as it is much simpler t= o have a functional ast. Sure. I wrote electric-pair-mode and that's exactly the point. electric-indent-mode is on by default, but many modes just use the default value for electric-indent-chars, which only contains a newline, and so they aren't affected by this problem. In c++-ts-mode, you gave electric-indent-chars a richer value, including characters such as '}', ':' and ';'. This is not unreasonable, but, as you've discovered, only really goes together well with electric-pair-mode. Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 25 09:10:56 2023 Received: (at 62412) by debbugs.gnu.org; 25 Mar 2023 13:10:56 +0000 Received: from localhost ([127.0.0.1]:42129 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg3fc-0006HO-DV for submit@debbugs.gnu.org; Sat, 25 Mar 2023 09:10:56 -0400 Received: from mail-yw1-f169.google.com ([209.85.128.169]:45806) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg3fZ-0006H9-Vt for 62412@debbugs.gnu.org; Sat, 25 Mar 2023 09:10:54 -0400 Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-5418d54d77bso84266727b3.12 for <62412@debbugs.gnu.org>; Sat, 25 Mar 2023 06:10:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679749848; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=GcKjYq+t4cr2Vh1vwUNL5ZE4FJTc/ItCbRuGZa1OrGA=; b=V9ml2F7Zf4Q8Ix8w0JbzQKRtELzYus9B9A+sY5SW6Rje8+w+mnOfoa5qkISKYuqHXt z8rk4TcGS6cVct0QK9u3Y2GCUSAd8zGyF48ABfCkfryqolFxSVDa2NApwpaz/KdAF0PR GYK1orozHAaEmLr61Q+xr8BvygWn3+lvIPaIghv+Kap1KJ2rGKflviLfvQCRC39pAzK8 Obcw6yK5XxrRlXuXVvqKwp9QE3TYII/2Imfyh+0WleY7JsxQN8EMH2Wgl9TBG3AAMA+x /Mofmjp70zZBbgVw1VtP/D5jyUNc0LjSUTMCjjoK8FeGmHm/7drOZYbxXQOk0f8zaZuo +IRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679749848; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GcKjYq+t4cr2Vh1vwUNL5ZE4FJTc/ItCbRuGZa1OrGA=; b=3fIpVzJvZfbZ6ArVFjAPJsIxtEHHXYdMQSDcLR1qxSc/4hVTBJzSSdXTZfulM7GbkQ 7ckafwVc1VBImdK+j4G7XZBJtHZqUFoZzNEJGEP8Cb4OxyKpr2vJxCzKthdPTlPKRuHX NbgqbttX4r5BmCeky4P7LEsWWzzqtxfL/hA+xel2psP0fPEWI8ORCI5qEFEa7y9XcPCm 0YMsNozrj+FW6CgvP7btH3BjY09dEh66wHGJTF5RaQbfRnEghmGwiWmqX9BBvuz1yYst a2arPHIkBxcGD2X7Z6r/QkyLh9dqriHA8zt0mUa5eSyfGFSAl4AWMOBoAEcXBvASJ065 W1fw== X-Gm-Message-State: AAQBX9f/fAD8LO9HQs0uxOpvrlawcuivN1ix5O4MIaWp8hGGYSrvwO2o A6Zx2S3zLFvCF0BVfhLf/+ACCDAGsW3hzU+i3117t7vr X-Google-Smtp-Source: AK7set8Ww/ZAEHur8nGjcQOmIzAT7/R9ojNRPvwfRMwUKwwIJyoFj+6f8748ImQQUUdL7p2gP0f9vBYF1gMKauTf/HQ= X-Received: by 2002:a05:6871:4796:b0:17a:df9b:6b1b with SMTP id qa22-20020a056871479600b0017adf9b6b1bmr2143758oab.5.1679734301090; Sat, 25 Mar 2023 01:51:41 -0700 (PDT) MIME-Version: 1.0 References: <2496F2A0-3EB1-4CD2-B299-E1DC41B7C23B@gmail.com> <46A6C705-97DA-4D17-999B-0536F01EFCA7@thornhill.no> In-Reply-To: <46A6C705-97DA-4D17-999B-0536F01EFCA7@thornhill.no> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Sat, 25 Mar 2023 08:53:31 +0000 Message-ID: Subject: Re: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter To: Theodor Thornhill Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 1.1 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On Fri, Mar 24, 2023 at 10:02 PM Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: e about the original purpose for this rule, CC’ing Theo. > > > >Yuan [...] Content analysis details: (1.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (joaotavora[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 1.1 DATE_IN_PAST_03_06 Date: is 3 to 6 hours before Received: date -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.169 listed in wl.mailspike.net] X-Debbugs-Envelope-To: 62412 Cc: Yuan Fu , 62412@debbugs.gnu.org, geza.herman@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.1 (/) On Fri, Mar 24, 2023 at 10:02=E2=80=AFPM Theodor Thornhill via Bug reports = for GNU Emacs, the Swiss army knife of text editors wrote: e about the original purpose for this rule, CC=E2=80=99ing Theo. > > > >Yuan > I'll look more deeply into the cause of this, but the rule is covering so= me preproc directives iirc. > > Unfortunately tree-sitter behaves better when auto pairs is used. I would= advise people to use electric-pairs-mode (if that's the correct name, on m= obile now) to avoid these sorts of issues. electric-pair-mode, it's not on by default. But, for some reason, electric-indent-mode _is_ on by default, at least in c++-ts-mode. So this has nothing to do with tree-sitter IMO, it's just electric-pair-mode doing its thing. Why is it on by default? A fair number of users don't like this electricity, or prefer to have it toned down. At least this has been the argument for not turning on electric-pair-mode by default, which is a much less jarring mode IMO, and one which would solve these problems. Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 25 09:48:18 2023 Received: (at 62412) by debbugs.gnu.org; 25 Mar 2023 13:48:18 +0000 Received: from localhost ([127.0.0.1]:42206 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg4Fm-0007Ek-5X for submit@debbugs.gnu.org; Sat, 25 Mar 2023 09:48:18 -0400 Received: from mail-ed1-f41.google.com ([209.85.208.41]:39935) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg4Fj-0007E0-7d for 62412@debbugs.gnu.org; Sat, 25 Mar 2023 09:48:15 -0400 Received: by mail-ed1-f41.google.com with SMTP id ek18so18423246edb.6 for <62412@debbugs.gnu.org>; Sat, 25 Mar 2023 06:48:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679752089; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=suyNIP2mWqTopaFt83EWeORVkeD++Q3g+D+333L0u3o=; b=lqRcSMfMP3W/qe/V5XKG2Z7s5DQgeMrDZKmuiIRy5OjPmwZkNIv73Ty+BdWXIgwXKF oIrQf4quYCOPLuXKJ8Cds76PqeX8VrAAPDHoNzhHUMX9TVsUlE8WqiNRfWQIHaWcO06G fEwjOsGGmxCB+2E3s6MEx3FA9O7u66HQvMgpySfeK0g8duG7BU4UC19NRzWAin1wqit4 hNqLWP/Y8skA+OjQaWVbKsnmP6Rw7PTmJUO6OBf3quJODCyf/W4JQ9hQw+sz7Ucugawq xvvt6mEQ8owvVK5K7uFJEV2PYrW68aGrM12EAF4moTSb7G5RH5Jdc2K4LyareMYOBpqm Nkfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679752089; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=suyNIP2mWqTopaFt83EWeORVkeD++Q3g+D+333L0u3o=; b=m2gqOxH1JhrV8BwiEI4EJ4+nV0O3IxXhZzDBTJa0qbMRJLgMDnGsxqNgU+w+/d+qDu PkPGXchsjWsWdtJv17mLDq9dNx6w+f83MbVxKpEeGp1Smy23fJOOfozPevl/F/ctVeMx Rim+isX8v0lqh/bDDVez7G/XyBcMgMepNn8f0QL4U4Yp8BX4KAfXJeRvpoIh1E2dChZZ 8k6KkwQJsPMFNyNotJJxAMJNwOAB/MxCXaT7hCq9cQ/urfUqhysQ/0WhRxXR3gSeIprC aTG20SuSwykRQyltXnedbIHo0i/kBd99kCFJNXriyfDFfw9pIERdk7rG/mx2IUm4Yb6s bvow== X-Gm-Message-State: AAQBX9d5ZaXW7EkSLkQ0GdwZVUjqq4idmWHGugFnAPg+nbD5F+/yzWGb oR1hv/Mc3OOGlVhFoEAAXGc= X-Google-Smtp-Source: AKy350Ybp8TXTcfmEFABGA161CV2+asDrQ7dN/0dUN/gIPtrLPTWkmXsYxaC28T8XyOcBcYitvwhzQ== X-Received: by 2002:a17:906:6946:b0:92f:8324:e3b7 with SMTP id c6-20020a170906694600b0092f8324e3b7mr5974015ejs.37.1679752089244; Sat, 25 Mar 2023 06:48:09 -0700 (PDT) Received: from [192.168.8.4] (netacc-gpn-204-88-167.pool.yettel.hu. [5.204.88.167]) by smtp.gmail.com with ESMTPSA id gv27-20020a1709072bdb00b008b9b4ab6ad1sm11764038ejc.102.2023.03.25.06.48.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Mar 2023 06:48:08 -0700 (PDT) Message-ID: <72d72cd6-4fa8-2df3-f45d-5bf5845e4f38@gmail.com> Date: Sat, 25 Mar 2023 14:48:05 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter Content-Language: sv-FI To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= References: <2496F2A0-3EB1-4CD2-B299-E1DC41B7C23B@gmail.com> <46A6C705-97DA-4D17-999B-0536F01EFCA7@thornhill.no> From: =?UTF-8?Q?Herman=2c_G=c3=a9za?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: 62412 Cc: Yuan Fu , Theodor Thornhill , 62412@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) On 3/25/23 12:43, João Távora wrote: > > There can be no "correct" indentation in a buffer with an invalid state. > > But there are heuristics. Here, it can be argued that c++-mode's > heuristics are better. I agree. In my opinion, c++-mode's heuristics are good. Tree-sitter support is new, it's expected that it won't work perfectly. Also, it doesn't have to handle any invalid program. But, while writing a program, it should handle indentation sensibly. I don't think that it's a good approach that everybody who uses electric indent should get used to the fact that whenever they writing a for loop, the line will jump around. It's a bad experience. Anyways, feel free to close this issue if you think otherwise. I just disabled ';'-caused auto indenting, so I don't see this unpleasant behavior any more. From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 25 12:21:41 2023 Received: (at 62412) by debbugs.gnu.org; 25 Mar 2023 16:21:41 +0000 Received: from localhost ([127.0.0.1]:43320 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg6eD-0003Ip-82 for submit@debbugs.gnu.org; Sat, 25 Mar 2023 12:21:41 -0400 Received: from mail-ed1-f48.google.com ([209.85.208.48]:46717) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg6eC-0003Ib-3d for 62412@debbugs.gnu.org; Sat, 25 Mar 2023 12:21:40 -0400 Received: by mail-ed1-f48.google.com with SMTP id eg48so19385148edb.13 for <62412@debbugs.gnu.org>; Sat, 25 Mar 2023 09:21:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679761294; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5AanYPi7WyAn7+t0ORaK9190jqkmhZaXCVjwMOrz6zA=; b=Yw07UyFWZCNO3J2iL61s366KP606K5FbdUR0p7xY9yJKr8PKrb4E5CrabjJNYx4W9S l/SBmEW6C0itKE+6+BY9A/zKCmIBcN5OZNABXE5tSIzsqucO2ptoTt6z4hQk/L/+xQ4F 8rd+GmyF++ll88nDVDmaT8Lw27dDd/Fc/RlTYqXKOGHXfifDi4kaQa3mSOXfCmZsPRF5 xJpfcro5TEdQ6kLlMbJ1HlYzAZGAxqohphbOF2ERsEKS366fz1GO90IgwNKRsJsgcmH5 AAff3xM3uJhfSTYmGJSq7b/r0w8K1SfuJc1z/gjCHOnuifXjRuMBQ1JEFvgv3EmiEr81 nfWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679761294; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=5AanYPi7WyAn7+t0ORaK9190jqkmhZaXCVjwMOrz6zA=; b=I6AzvNzp9rMtKLNxWQU+W46YAy1TswkPkEAmjzPqFel095HZNa7smRhd+HOBMIlGCQ uooLNZ35HkJCzM+/d98TgXLj3NaPIr/ZYoTuvaonOGzdmUgVY4rG+d8SE3kobWjYRrVB 9NfabwnUMN4O68bf5bA39rWgke1v92/ciFQhHITJptS8FeK8E+936xG0PIAhdlimC5JW K/OpZd1NueTG6clvosW2Ge8/OaPpu7Qg+ArZLEnlkjlonEVaip1QhN2YR2oFNYvxwSsQ 9o4RU0FiAF58tdu1hYU0g8F4cfLT1Sqcj1mwD0LNo3dcdtqTLj/D08zu110OqVBW+s39 6Oug== X-Gm-Message-State: AAQBX9ckOUXD7lKnK1+zppaQw1rEdVKIudbwpnN3qj8k4cj4JKa7rJwo EhM4iIcWKpetfVFW1Rq+v7zR1C4x5ag= X-Google-Smtp-Source: AKy350a6WE7KxeZaEndgJGxYGFpl5xEVQ4c2aPCHa7bBLYMzlzvh8f/UrVN5hx44u4TEQcxwnug91A== X-Received: by 2002:a17:906:8402:b0:87f:5d0a:c610 with SMTP id n2-20020a170906840200b0087f5d0ac610mr7237759ejx.32.1679761294112; Sat, 25 Mar 2023 09:21:34 -0700 (PDT) Received: from krug (87-196-74-168.net.novis.pt. [87.196.74.168]) by smtp.gmail.com with ESMTPSA id q7-20020a170906b28700b00931c887372dsm11774939ejz.107.2023.03.25.09.21.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Mar 2023 09:21:33 -0700 (PDT) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: =?utf-8?Q?Herman=2C_G=C3=A9za?= Subject: Re: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter In-Reply-To: <72d72cd6-4fa8-2df3-f45d-5bf5845e4f38@gmail.com> ("Herman, =?utf-8?Q?G=C3=A9za=22's?= message of "Sat, 25 Mar 2023 14:48:05 +0100") References: <2496F2A0-3EB1-4CD2-B299-E1DC41B7C23B@gmail.com> <46A6C705-97DA-4D17-999B-0536F01EFCA7@thornhill.no> <72d72cd6-4fa8-2df3-f45d-5bf5845e4f38@gmail.com> Date: Sat, 25 Mar 2023 16:23:35 +0000 Message-ID: <87o7ogx0jc.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62412 Cc: Yuan Fu , Theodor Thornhill , 62412@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) "Herman, G=C3=A9za" writes: > On 3/25/23 12:43, Jo=C3=A3o T=C3=A1vora wrote: >> >> There can be no "correct" indentation in a buffer with an invalid state. >> >> But there are heuristics. Here, it can be argued that c++-mode's >> heuristics are better. > I agree. In my opinion, c++-mode's heuristics are good. That's probably only because we're _used_ to c++-mode. If we had been using c++-ts-mode for years, we would be equally suprised. > Tree-sitter support is new, it's expected that it won't work > perfectly. Also, it doesn't have to handle any invalid program. But, > while writing a program, it should handle indentation sensibly. I > don't think that it's a good approach that everybody who uses electric > indent should get used to the fact that whenever they writing a for > loop, the line will jump around. It's a bad experience. But writing a for loop from scratch is only one of the editing activities you do in a C++ file. Other activities involve editing existing code. In those situations, c++-ts-mode's heuristics could "win". Unless you're willing to posit that writing code from scratch is more frequent than editing existing code, there's no right answer here. > Anyways, feel free to close this issue if you think otherwise. I just > disabled ';'-caused auto indenting, so I don't see this unpleasant > behavior any more. Yes, i'm inclined to think that c++-ts-mode shouldn't add any chars to electric-indent-chars. It's just not useful. Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 25 13:41:48 2023 Received: (at 62412) by debbugs.gnu.org; 25 Mar 2023 17:41:48 +0000 Received: from localhost ([127.0.0.1]:43404 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg7tk-0007yR-I7 for submit@debbugs.gnu.org; Sat, 25 Mar 2023 13:41:48 -0400 Received: from out-63.mta1.migadu.com ([95.215.58.63]:58829) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg7th-0007yH-MD for 62412@debbugs.gnu.org; Sat, 25 Mar 2023 13:41:47 -0400 Date: Sat, 25 Mar 2023 18:41:37 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1679766101; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AmAIHrHNjzbhGjnTx+Uqy3mbm4by0Vci8vsLIQJtVOs=; b=M3XYQI71LtTw6i/6r8/CjuimlbVp00uE1/sqLOfR5ZDJCQBh2aGhvsK265dQT2O18cgGWw Xm9NSCcO7adzsapSG75ZxmvgW03xZNDJrxUizBEv1ioATCJW5onOR1h6s8a2XYvP2E7VxF VVh3bkE3CM7gAqygzl+ekNTQsJS9DSSfjE8DRIhsJwbBWz5WaerV+9k79t3uuV9n8AXQYi SoSEfYS6H3wSZfCYbCweFjVf6ud4Gm40glPqYW2RgUSIF2xlf1YBY0llUx/Sonc5gz5INk pBbwH2FqAQvNV57M9NHcAY1iaOQLUxw76tTAylGu8h6OqyBnaXfs5jomFMDIkA== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill To: =?ISO-8859-1?Q?Jo=E3o_T=E1vora?= , =?ISO-8859-1?Q?Herman=2C_G=E9za?= Subject: =?US-ASCII?Q?Re=3A_bug=2362412=3A_29=2E0=2E60=3B_strange_c++_?= =?US-ASCII?Q?indentation_behavior_with_tree_sitter?= In-Reply-To: <87o7ogx0jc.fsf@gmail.com> References: <2496F2A0-3EB1-4CD2-B299-E1DC41B7C23B@gmail.com> <46A6C705-97DA-4D17-999B-0536F01EFCA7@thornhill.no> <72d72cd6-4fa8-2df3-f45d-5bf5845e4f38@gmail.com> <87o7ogx0jc.fsf@gmail.com> Message-ID: <3FB95B26-42DD-4394-B8D7-AF0CBE079781@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62412 Cc: Yuan Fu , 62412@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 25 March 2023 17:23:35 CET, "Jo=C3=A3o T=C3=A1vora" wrote: >"Herman, G=C3=A9za" writes: > >> On 3/25/23 12:43, Jo=C3=A3o T=C3=A1vora wrote: >>> >>> There can be no "correct" indentation in a buffer with an invalid stat= e=2E >>> >>> But there are heuristics=2E Here, it can be argued that c++-mode's >>> heuristics are better=2E >> I agree=2E In my opinion, c++-mode's heuristics are good=2E > >That's probably only because we're _used_ to c++-mode=2E If we had been >using c++-ts-mode for years, we would be equally suprised=2E > >> Tree-sitter support is new, it's expected that it won't work >> perfectly=2E Also, it doesn't have to handle any invalid program=2E But= , >> while writing a program, it should handle indentation sensibly=2E I >> don't think that it's a good approach that everybody who uses electric >> indent should get used to the fact that whenever they writing a for >> loop, the line will jump around=2E It's a bad experience=2E > >But writing a for loop from scratch is only one of the editing >activities you do in a C++ file=2E Other activities involve editing >existing code=2E In those situations, c++-ts-mode's heuristics could >"win"=2E Unless you're willing to posit that writing code from scratch i= s >more frequent than editing existing code, there's no right answer here=2E > >> Anyways, feel free to close this issue if you think otherwise=2E I just >> disabled ';'-caused auto indenting, so I don't see this unpleasant >> behavior any more=2E > >Yes, i'm inclined to think that c++-ts-mode shouldn't add any chars to >electric-indent-chars=2E It's just not useful=2E > >Jo=C3=A3o I won't object to this, as I hold no strong opinions either way=2E Would r= emoving it cause less confusion, yet still reindent correctly in most cases= ? If so, feel free to remove it, unless anyone else objects :) Theo From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 25 13:47:21 2023 Received: (at 62412) by debbugs.gnu.org; 25 Mar 2023 17:47:21 +0000 Received: from localhost ([127.0.0.1]:43429 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg7z6-00088e-Tc for submit@debbugs.gnu.org; Sat, 25 Mar 2023 13:47:21 -0400 Received: from mail-ed1-f48.google.com ([209.85.208.48]:38546) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg7z5-00088R-8r for 62412@debbugs.gnu.org; Sat, 25 Mar 2023 13:47:19 -0400 Received: by mail-ed1-f48.google.com with SMTP id r11so20069048edd.5 for <62412@debbugs.gnu.org>; Sat, 25 Mar 2023 10:47:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679766433; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=irH49+WQQRuUCxatcALEwnkihw8gboHtHGNY3xbd2Rg=; b=PQ7zUcYwE/xOeTot4dOfUNUDgMWTwDrf/ezx6TVMrJFhJGJS6MLYjgeZqIT6nNi7x7 YxZiDqGwms1Qjab4ityEj726uwsaB1SHAD/dRXe1MRzlr/MAtF9WQQ4iJhaRb+hlBK5Q Yfc6BvhCbRgYSFdqz4BjOQ0dpLm/qz2hGPtsJN5H0buERqLncwZ4CCJakzLAKwMG+nd0 CIREJYhaSuyQOzrCbllmw8GSCpV0CffgAcWMggMeinGehf0/+d+rfosr+aPYdk+oyD9e 4Yjt3frSf67QBJTALD/9qhbSSeT6ft0kIgJu94aY2g6S2XVRHdBLc35Xl6fP4OrSE6Iy f40g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679766433; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=irH49+WQQRuUCxatcALEwnkihw8gboHtHGNY3xbd2Rg=; b=21giAjjybvyKaciZfzJ85D5DITKRX6vbQJnnEBdkTQMthmaky83Unyf6KEYQwtqmo2 ApW/BHLfxJE4wg5BTLlxpTTQmck8L42T1803UrtTI/q1GlityarbVET9PI/HZwY1FGdx HNgwjH9FRyuVDyyze6FGKNPlcE7GjTee+N8CWSUow+prassRTJSoh0dNq2jSK/eWDZkS YJWeBLVzeYrgaZtAHTxpUM6wR6idGTUqSzXFkABjLq9UhmAj9rjc49WJp5YtGDSBD432 76M0NZGNRQZcct16v8dzAAlYvx04oeVSSM7Agd8HiK7ByDh4J+ByT4Y/wQLG5Dc/qYPw +y0A== X-Gm-Message-State: AAQBX9dP5+WqxhutVItCbmV8R2MsWztya2TkukvO45PbyOq4FnfEG8iO H4J3mb4AjHD0GdvB1505myg= X-Google-Smtp-Source: AKy350avpxqxzw0pElG6S/YrKOW4CfpwFXAoLtNGMyKCQQS9VBpO4y6c/L1x22swrxuUUSx672NQTA== X-Received: by 2002:a17:906:fc5:b0:928:de2a:8a3f with SMTP id c5-20020a1709060fc500b00928de2a8a3fmr6670216ejk.31.1679766433111; Sat, 25 Mar 2023 10:47:13 -0700 (PDT) Received: from [192.168.8.4] (netacc-gpn-204-88-167.pool.yettel.hu. [5.204.88.167]) by smtp.gmail.com with ESMTPSA id lz24-20020a170906fb1800b009334309eda5sm10196195ejb.196.2023.03.25.10.47.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Mar 2023 10:47:12 -0700 (PDT) Message-ID: Date: Sat, 25 Mar 2023 18:47:11 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter Content-Language: sv-FI To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= References: <2496F2A0-3EB1-4CD2-B299-E1DC41B7C23B@gmail.com> <46A6C705-97DA-4D17-999B-0536F01EFCA7@thornhill.no> <72d72cd6-4fa8-2df3-f45d-5bf5845e4f38@gmail.com> <87o7ogx0jc.fsf@gmail.com> From: =?UTF-8?Q?Herman=2c_G=c3=a9za?= In-Reply-To: <87o7ogx0jc.fsf@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: 62412 Cc: Yuan Fu , Theodor Thornhill , 62412@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) On 3/25/23 17:23, João Távora wrote: > >> I agree. In my opinion, c++-mode's heuristics are good. > That's probably only because we're _used_ to c++-mode. If we had been > using c++-ts-mode for years, we would be equally suprised. Yes, that can be true. > >> Tree-sitter support is new, it's expected that it won't work >> perfectly. Also, it doesn't have to handle any invalid program. But, >> while writing a program, it should handle indentation sensibly. I >> don't think that it's a good approach that everybody who uses electric >> indent should get used to the fact that whenever they writing a for >> loop, the line will jump around. It's a bad experience. > But writing a for loop from scratch is only one of the editing > activities you do in a C++ file. Other activities involve editing > existing code. In those situations, c++-ts-mode's heuristics could > "win". Unless you're willing to posit that writing code from scratch is > more frequent than editing existing code, there's no right answer here. What is the c++-ts heuristics here so it removes the indentation? I don't really understand why it does that. Is there a similarly looking situation where removing the indentation is the sensible behavior? >> Anyways, feel free to close this issue if you think otherwise. I just >> disabled ';'-caused auto indenting, so I don't see this unpleasant >> behavior any more. > Yes, i'm inclined to think that c++-ts-mode shouldn't add any chars to > electric-indent-chars. It's just not useful. > As far as I know, c++-mode has ';'-caused auto indenting, it just works with a different mechanism. So if the aim is that the two c++ modes should work similarly out of the box, then it'd make sense to keep electric-indent-chars as is. From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 25 13:51:41 2023 Received: (at 62412) by debbugs.gnu.org; 25 Mar 2023 17:51:41 +0000 Received: from localhost ([127.0.0.1]:43438 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg83J-0008JW-1X for submit@debbugs.gnu.org; Sat, 25 Mar 2023 13:51:41 -0400 Received: from mail-oi1-f174.google.com ([209.85.167.174]:39850) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg83H-0008JJ-0e for 62412@debbugs.gnu.org; Sat, 25 Mar 2023 13:51:39 -0400 Received: by mail-oi1-f174.google.com with SMTP id bk5so3532283oib.6 for <62412@debbugs.gnu.org>; Sat, 25 Mar 2023 10:51:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679766693; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xZdK+jKcsVHGV7piHqT6or9uOvnv13jzFCOKc1p7Bp4=; b=GmVmtL0TC2eUEQ9QAc3K0m21Td6gHskL+nbetCy0d+U3OX9CMxOr2nVMXNvQgBSqg+ hF/7Koi3A6Fu4xgeS5gjnUER734wW0lUK8VDSWNIN6g5nmEWKDWiAFiE8KhqYoGkZyKD 8taH3HzIWwtm1k+1amqUAnxj2+FO4iBch04Z7augwJURz+E3jfPMMsicoT5B6omJJhTg btg1fQxeItahl+eVMsPa0LV3tse5jPPJJNiNUbltUiyX/ITuNup9LDOgpmzHQXC11t6U k9jqpGtB12GcbiKhzNk34fPPAN0CAHJiW7AQ03yqrlFCBmzI2AMwJT2FMVCzVJJ+LMmn fdyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679766693; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xZdK+jKcsVHGV7piHqT6or9uOvnv13jzFCOKc1p7Bp4=; b=MGvwTI6uoQvA595ZQsnBJDrYNf3vmkkqd1vytbjrjqBIr8fMF/CorPIfFnJNWpGszE M1ArSa5r/RZyTulIgSK8b2kPX7G4MCu2iNv7D+WwTIlHuEbqQbietj1a2K5jENjfKB82 XzxYXpHvjeo5Vc4IAdI1sBfkuK+wCkW4yogEXDy3IWLRB5RMvpBX7JfG50mJ7m9me8dS F33olsanjLh0rgqGa5hnKH+rKDTSiVRV47ZBA7BzxO35m27xHBxeqnwD2xJ9pBIiJs9F YmiyGwNEH70/Hir8I2muKNLQ+lBymAx+eBlspoZrTyf47tt+9EeQqJb+bDUEPMVwflnh EMhg== X-Gm-Message-State: AO0yUKVRFF4Ot5F1uaj55pVJy9YZVqAuq15xzh2AlN1+nHgjK1YZ1qLn HJ6Q3Jg3ZvL5SmAUDG2kAGZ6i1RgBgwtPk5ydq8= X-Google-Smtp-Source: AK7set9oRLOsEKvIYtwUFESrsyujXzrdbg3EJsDEOTuhSQUvq4nhRDcxFLNtU2bHobYhXq0PwdcxG8jto1/7UzaNE70= X-Received: by 2002:aca:6508:0:b0:384:420d:6671 with SMTP id m8-20020aca6508000000b00384420d6671mr2156381oim.5.1679766693075; Sat, 25 Mar 2023 10:51:33 -0700 (PDT) MIME-Version: 1.0 References: <2496F2A0-3EB1-4CD2-B299-E1DC41B7C23B@gmail.com> <46A6C705-97DA-4D17-999B-0536F01EFCA7@thornhill.no> <72d72cd6-4fa8-2df3-f45d-5bf5845e4f38@gmail.com> <87o7ogx0jc.fsf@gmail.com> In-Reply-To: From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Sat, 25 Mar 2023 17:53:23 +0000 Message-ID: Subject: Re: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter To: =?UTF-8?Q?Herman=2C_G=C3=A9za?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62412 Cc: Yuan Fu , Theodor Thornhill , 62412@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Sat, Mar 25, 2023 at 5:47=E2=80=AFPM Herman, G=C3=A9za wrote: > So if the aim is that the two c++ modes > should work similarly out of the box, then it'd make sense to keep > electric-indent-chars as is. Only _if_ it is generally understood that c++-ts-mode's heuristics are worse. And only _then_ if they can somehow fixed to become better. Until these conditions are satisfied, I think electric-indent-chars has to be left alone. Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 25 14:38:04 2023 Received: (at 62412) by debbugs.gnu.org; 25 Mar 2023 18:38:04 +0000 Received: from localhost ([127.0.0.1]:43484 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg8mB-00015B-Rz for submit@debbugs.gnu.org; Sat, 25 Mar 2023 14:38:04 -0400 Received: from mail-lj1-f171.google.com ([209.85.208.171]:42751) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pg8mA-00014d-0T for 62412@debbugs.gnu.org; Sat, 25 Mar 2023 14:38:02 -0400 Received: by mail-lj1-f171.google.com with SMTP id x20so4952646ljq.9 for <62412@debbugs.gnu.org>; Sat, 25 Mar 2023 11:38:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679769476; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Hfyrfe2nrTYd9tJ/Gz1MV+VN2gXxTg10MyUWBW2Rcw0=; b=qslVMevh82nlmshnYyrL6I2iEmyyshhED2/3vs3IQExKVLw4IZ8lAt+V2CSJhKjhJV jf/lbZ6Smz0Uczzn6KCzamc81pMFYuvxCEgjVUuHWFsv0hyI2uFRe+QGLEFIJDOgO7ha O8mWMX/nSAbJGI77hXlY9w0soQ6QxaIEFByf/ej4NgyliplZRM5we7oK6J4lKNMt+iMY Vcb5cwwIsCjpvLCdoM/PzMuetH5sOVq2XJreo3FB0J6eK+xAX5qe3pd5dCzDhmfEQqc5 B8ZV5k6YLPrPcBMMeWTqAxLvxbfFmxvLZ+8bmhDrmkzLPJRXjK+/qJdKOEOkINMdwjzz V67Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679769476; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Hfyrfe2nrTYd9tJ/Gz1MV+VN2gXxTg10MyUWBW2Rcw0=; b=1QDORpn54dGS2lSSRTdsgQMkBht2JEFw5EhYQxfP/lxYXNQF4jC0hSFwr8M/3jdjIM zI9PdRLONy6i919Mb+P3nnfz9AWG6L5XyU6FspUKA7luV6ttluOK0DNgF7pqdvB+/Sye URfbknYyexD6ifMSox7CKgmjKYj88xxV1b178Sf8p0fhn1u+1ElgWY//INPx2+smzjKk sJzLQ7gh/k+QSYcBf+j1TIQ7PJmsOlxZBJ8g6k2y/5PEmRRx7qZZUJ9BMkK3gLZmqRjI 1TznLHdtidL+qTIVM59XCX+kV8r/DRCYY2OOsMH95CWFQGdkHwOuHbnXPNQovzbd+ceI GRyg== X-Gm-Message-State: AAQBX9dXstAKPD8o+fUBMBKWSZBjoxt/VYXD3yDZrOhSmQmjoTnRLtQE +oNxctFoIVANauzWaROqr9c3zDQlu4w= X-Google-Smtp-Source: AKy350YU3SRl1H0U7mkTKpp8/NDSvbQkKNU8lEDEkbFQ54t6WrdnxaEIadGtLDXzV0R8X0plULPF8A== X-Received: by 2002:a17:906:284c:b0:931:99b5:5a23 with SMTP id s12-20020a170906284c00b0093199b55a23mr5567276ejc.44.1679739966438; Sat, 25 Mar 2023 03:26:06 -0700 (PDT) Received: from [192.168.8.4] (netacc-gpn-204-88-167.pool.yettel.hu. [5.204.88.167]) by smtp.gmail.com with ESMTPSA id gz4-20020a170907a04400b0090e0a4e1bacsm11528537ejc.159.2023.03.25.03.26.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Mar 2023 03:26:06 -0700 (PDT) Message-ID: Date: Sat, 25 Mar 2023 11:26:04 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter Content-Language: sv-FI To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= , Theodor Thornhill References: <2496F2A0-3EB1-4CD2-B299-E1DC41B7C23B@gmail.com> <46A6C705-97DA-4D17-999B-0536F01EFCA7@thornhill.no> From: =?UTF-8?Q?Herman=2c_G=c3=a9za?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: 62412 Cc: Yuan Fu , 62412@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) That's the difference. c++-ts-mode appends "{}():;,#" to electric-indent-chars, while c++-mode doesn't do this. Nevertheless, I think that the calculated intendation should be a correct number. Even if the user turns off electric-indent-mode, but dedices to call re-indenting manually for a half-written for loop, emacs should re-intent the line properly. At least, this specific example works OK with c++-mode. (note that I understand that this problem is not trivial, tree sitter/emacs may get confused if the buffer cannot be properly parsed) On 3/25/23 09:53, João Távora wrote: > On Fri, Mar 24, 2023 at 10:02 PM Theodor Thornhill via Bug reports for > GNU Emacs, the Swiss army knife of text editors > wrote: > e about the original purpose for this rule, CC’ing Theo. >>> Yuan >> I'll look more deeply into the cause of this, but the rule is covering some preproc directives iirc. >> >> Unfortunately tree-sitter behaves better when auto pairs is used. I would advise people to use electric-pairs-mode (if that's the correct name, on mobile now) to avoid these sorts of issues. > electric-pair-mode, it's not on by default. > > But, for some reason, electric-indent-mode _is_ on by default, > at least in c++-ts-mode. > > So this has nothing to do with tree-sitter IMO, it's just > electric-pair-mode doing its thing. > > Why is it on by default? A fair number of users don't like > this electricity, or prefer to have it toned down. At least > this has been the argument for not turning on electric-pair-mode > by default, which is a much less jarring mode IMO, and one which > would solve these problems. > > João From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 26 09:25:30 2023 Received: (at 62412) by debbugs.gnu.org; 26 Mar 2023 13:25:31 +0000 Received: from localhost ([127.0.0.1]:44266 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pgQNG-0000eC-Dt for submit@debbugs.gnu.org; Sun, 26 Mar 2023 09:25:30 -0400 Received: from sonic301-21.consmr.mail.ir2.yahoo.com ([77.238.176.98]:33550) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pgQND-0000dr-Gx for 62412@debbugs.gnu.org; Sun, 26 Mar 2023 09:25:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1679837120; bh=3HxmsSTZavL05/J+mMo/CAjtZBmrx03HC4lUcZ4SKXo=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=SBvjrFnMC8WXbNtKGRFki3fK4lqUryHHALPsV9oPsfY7kuCM6MFSvbv1b57HsZcJFbP7eVLrszI4UrgI/DdzmrZRXKhaRuk0R8c/mPzoMEKcU2J0vmEKiOev1wwhdT92nHORAXdmeupwS4fi8EqrtLBBYaAomCQ24WX/Vb7yLPPcF/VA1tjtrt1GHKQO0vX+bpvAsH0TwIQRsYe2GrSeOS2g1+jmpYVv4yMzN6zxj2MS8oTY1FcLwMIsIDBzZ1WYcRoIJ4WvPHW4gjUxYoQUEmN3D8jFSGxEIfj0+mrQ1jX5X5CIq5xLBNfHsqA3ucPaXpeZhBfpfQf/zA68M4nBHg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1679837120; bh=r79q4OohKRTYyPfNAOrCkKtvzAIO19gpM8fC7s440t2=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=bznkN06nC7Sf+s8K3+7Mp/D0kkdt0MwwzcdXFi4ZD6p2Ve8S603xnvJi/L2f2MCnooXJ/L44P8ehue5FuA03PMdBxKN9mmpNFqReKJ7fY4rBv9OrTLp/4cQg1AqrR/0mYJMsju6Pdl5cEQZs9PfVVN9TIJlqUFxs3RFhoMcn3876UgA7JMPPVTla1AdHg0I67Tf26Wrjh7d4vqZZiFD086juu9IDfTtahGviEbGUlhxBrD3jZzjiAf23bCV2jtxbDJOAJG6HcyKs7HpayOkSikjJdX07LK2NdphBnaWszhGud8BZEWG+lBdlb7cV8GINDYBArOCAAvCepWaeD+00dw== X-YMail-OSG: X6CEv_YVM1lLwm3bk71GGB4zn_Y4DNHBr0IhAM8PD0nx5NFdWGWpo9FEfza0bab 7h4vzZuOOOj0_c6.YWk3lau3tu86h0H1iqp5F1oaiGAodE0umVid_TCGVOb5OEx3MhE252F1CZb9 pSfdjK17zuHPavryQwQIr6YCFaKq2xHM.jeOQMK6wNm1aVeTcbuN.Ru04x_gzrQmrnpLqunwlG3s xlrFWFM62Lx_LJ.55x8.JResfix3tP9TWaWq983gEb81G0YLRi4cZQqDVIPGwxJLjnmsY5aOuFVn HvemIdky6rcmR5xXzXOoon2B7P4PnMCgrJmcy6jjqmU5HY2viu9e0Wg2yNurtoU8JrayWNQVnxki 2VaAy1J6YydS6_m6yE9j4QMDO1u9N77ayEHI25.DTmSPjG.ST5iP5UAipEIf_r_vZizndf4HiR9X SaexV6zkzRsZZSqed1hevWwGWLZq.8ZgGlApzACR5SI2DrvkTJqQRRP.tx0OgVfYe7Wr76boSmWZ wd8xvT_LiU_qbgDGAG.HECJ97pQLScNis6ojV78Hs9yT6W6sjgOizZ.NqUpI8owOxfJ8igbf6sel ByRNaLI5PtFBhB6VDJ1pPZVs5Jy12aN0LfjNZPA8UZe.Eg0VS8WeXTc17fgZrhfvsKRqLiH_kjr0 fELIFsftUm9UWGZvIOUJLdgjC9KatfU_dF1HEdrjKnYy3xBUiMzfgkab3c2eMF1vh6FlJjloIAAY RCFJe5wJQnI7G6SSiwJCyXD8j0bJqkg6UgQtg1sMjGOu_CDW3CBGISLjJovlJOrKQNU9sW_wWqXG ni2GpPs4mvnCON3SIdtHoo82Zi7yVAhfH0GjlIw7Iobpw.tznTc2qQuu0soxBt8BAeimadlq02Jt GqP5KwVWQ9nBO2ZZxmiyUkI8aiw0tKJ5EcAOdM47031XRkrRQuhhVoEXlT9iwZwbF86DTLawpYmb FSjFVQdADLMX_tKpepkRoM0cy3tICQZGmakKegCoBJTp8xdp4Gbpf2rw8kNjeP1Tj1JpnxfnesuA aFL277vpHrb5W0WFuvSau.RoZ.HaPCA74_y4zSCK__guBUY9q4F0LP4b8bx2zFNbyqh93LdeJAEy .ZVgu6rHoNX0BynAVG0M7y5pZAP_eGbW0w90FMQqo22by3XPrYTj0T7uT7F09Mh_AlLaUqQ2o5TN OwR5eQl8yIrFNjpoOlVDq8NKAZIRWGbf96m3qwilQ7pFDBdG5ekv8NSR8O3_meJDy1OCG18KatB_ vrl3E5XZ.faM9CTwvaiAKPiLGKrPw3kDwZIhdHjfzufavldT_N9N1erGTEfoX1A37lxNv.7zDH75 Gz1GvuMxDesTAMNuDOQmpxWx9AQUYylWoLR45hEY1IhucdVtt244gxlc5G5XssNgwIrjYbULzTRb 3shRf80AnyaMBtdKOuQMqcbLBwmowE7PAdc0U68GR94TYCPhrjibKpGOF38DcpcZD1gz.8J8wlab v0Clumnl3A50_OOSPPtsvc3JEsWTPi0ZawWLlDs6wDuQcuxZz8_fWzqVCRLLEau4.l9I5fBQMwHm hM9XxsJMAwIE9q63csJ80GMzPbE3uESacqni2Kr6PTNhF4TaLZEgKQwhXRK5CodKau.xI5qprVcO hvMOI4.HmTll_izvPMeGFvHo6n1vVujBAwxMWSvZZ8R2LXZZev0fYR40.Xk1qzuGFq40Bb841Qqs SFfYUR5SKAvbTMZ3dgrUMTaLSTz4cfEf93g9cPRn_hJznMPasGvKQdl_Ch83szOkSgJgE09nZsnW X5k0ydsnTVAWMOo4ewJgZk0u8OzG3hPyLmYokpHDPzu5GZvW_0_XLyy9KNIL.x8E4zozZ.WTmFX4 4mk29s2zE5rquLP9vcs7rxcZieCztNEtP1rlKftVaSt.QyZ8upE6hj585PMZ6EAgrR8unji_0Ctj M.DoBACAJ3uNxV7qe.4r3Zhgl0T5ZLpiBaYFjaUpAPe3IpHhes5kqCZgeUbdnosfFmq21lspk6SE aTx2Voydng0hbOBTPkUjr8mcmviEdBVKM7pMa8FKpe2w3qftS8Es.PaQHgwArJFp70MRCKCrxWRm zIbF.cYJLMfLTGU3UrjyZibyFMqsxRjlN2PiWjneBlLXQWefch8KlCvYrz4LxPbAqhruNbd5Ewbd DofAAFYmufVpA4U9xFKJizgsVS5cojuxukmQ1QhK.r2pTjVKtLyNkU_lyvLiSNRSFW5iVa.D7okD eHWVuSMVxBJyb_kyro11pm3x3RYEdtDBn3vqVoQ-- X-Sonic-MF: X-Sonic-ID: 7d33e869-1bfc-4163-b5dc-798d3a95d802 Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.ir2.yahoo.com with HTTP; Sun, 26 Mar 2023 13:25:20 +0000 Received: by hermes--production-ir2-5b7d458747-rxkcm (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 7d3370177d3fe044b4068cabab889c6a; Sun, 26 Mar 2023 13:25:16 +0000 (UTC) From: =?utf-8?Q?Daniel_Mart=C3=ADn?= To: Theodor Thornhill Subject: Re: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter References: <2496F2A0-3EB1-4CD2-B299-E1DC41B7C23B@gmail.com> <46A6C705-97DA-4D17-999B-0536F01EFCA7@thornhill.no> Date: Sun, 26 Mar 2023 15:25:15 +0200 In-Reply-To: <46A6C705-97DA-4D17-999B-0536F01EFCA7@thornhill.no> (Theodor Thornhill's message of "Fri, 24 Mar 2023 21:04:24 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (darwin) MIME-Version: 1.0 Content-Type: text/plain X-Mailer: WebService/1.1.21284 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 2004 X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 62412 Cc: Yuan Fu , 62412@debbugs.gnu.org, geza.herman@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Theodor Thornhill writes: > I'll look more deeply into the cause of this, but the rule is covering some preproc directives iirc. > > Unfortunately tree-sitter behaves better when auto pairs is used. I > would advise people to use electric-pairs-mode (if that's the correct > name, on mobile now) to avoid these sorts of issues. > Yes, I think that having an error node in the indentation rules is not a good idea. It can cause unexpected issues like the one described in this thread. I'd explore the idea of removing error nodes from the rules before resorting to tweak the electric or pairing features of Emacs. Let's look into the problem that the introduction of the error node tried to solve, the indentation of preprocessor directives. Starting with this code: int main() { | } if I type '#', automatic indentation does not happen because, at that stage, the AST doesn't recognize the full preprocessor directive (the node in the AST is an error node). If I continue writing the preprocessor directive (say, "#ifdef DEBUG"), the preprocessor node is created correctly, but it would require a manual TAB to go to column 0 because we haven't inserted any electric character while we completed the directive. The same manual TAB is required by c++-mode, so I wouldn't see this as a regression. However, there might be still minor divergences between c++-mode and c++-ts-mode. For example: int main() { #if } This in-progress code would indent correctly in c++-mode, but on c-ts-mode the node is an error node, so we won't reliably know that it should indent to column 0. If we want to fix these minor divergences, I see two possible approaches: - Investigate if the C/C++ grammars can be improved to cover these cases better. - Without changing the grammars, could we insert our own preprocessor nodes in the AST tree by checking if the first non-whitespace character of the line is the beginning of #assert, #define, #include, #if, #ifndef, #elif, etc.? From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 26 09:54:19 2023 Received: (at 62412) by debbugs.gnu.org; 26 Mar 2023 13:54:19 +0000 Received: from localhost ([127.0.0.1]:44312 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pgQp8-0003rR-Qu for submit@debbugs.gnu.org; Sun, 26 Mar 2023 09:54:19 -0400 Received: from mail-ed1-f41.google.com ([209.85.208.41]:36385) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pgQp7-0003rF-5i for 62412@debbugs.gnu.org; Sun, 26 Mar 2023 09:54:17 -0400 Received: by mail-ed1-f41.google.com with SMTP id w9so25611546edc.3 for <62412@debbugs.gnu.org>; Sun, 26 Mar 2023 06:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679838851; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=EWyRS3+j1owghA6kpyPweOAk8wBXhAhBv34eeqOirIo=; b=Zl1K7b/qD65KtHHxinx/lFl+Q4z5yrtqTqQCovDTo9x8J6b4anFF+m58DIFIFEauAP dfMCGLglf3Tj9a+uyIpWR14zes1cb19OVsENja2T0+a0kn8Hq3w44UFwOLCb6qCwL/4b rtNVP5IA+Cu12Pi25qBvwua+MPJnit/Cem4lJGii2f7gRtgBKZDP2mnEl6FWGCne4Q0f YniUng/L/NCwB3IAC/O9oNArfenvKWzyX6d0KtexhIb2nilQYRgPatxtcnW/Qf6E0IjG VmZMr1LOtcdvsyJFNEfk3YuHaDPufy3MZAN6jP3r1pM689qSih5i3AXh9sqozMfoUnau OY0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679838851; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EWyRS3+j1owghA6kpyPweOAk8wBXhAhBv34eeqOirIo=; b=waanU3sAyeKyAl/bOsALOI51X8JOzYbn1aFR/XTbmFCNbROVmq+9vZBnctcW8Aybqz uYh951E1EaTZjhBmJe19t9rcGEdctmJv28lNlh32XYYR9MA02XpFaqkCp6rPj3Jw5t8T tCEfdJVmEldSv/Or/7j651M/7VfuT3mxkhwTRRLOtXy6HXZwIimiI5Ux+4xwJdjbgOWX LU65jr9VVxZvK+tK89FVn9DvE1x65TcIIGgfpoJPgBJAuJWog0OpfvmdDA1Ej5l5wLCF 46F7IdATW1LqUmBjsKbBhPi4WjJA4N5tUzZJagCM3wVqFwXg/mEih4GLyBBEi9OpUa0I AwRg== X-Gm-Message-State: AAQBX9f70yfky1CDd7wtVYcH+prS6bfQRYs2naPmntUWweCU6523+BR7 seUym4/xIzl/ayJ7DMScU38= X-Google-Smtp-Source: AKy350ayj1HZkRFZJIu0nR6Vbfo7qDfGk2NBwaU/IHkHRflY4wcWyB9wUoUEEb1X/rY+SFX/awHssw== X-Received: by 2002:a17:906:7189:b0:930:6591:15ee with SMTP id h9-20020a170906718900b00930659115eemr10166752ejk.10.1679838851182; Sun, 26 Mar 2023 06:54:11 -0700 (PDT) Received: from [192.168.8.4] (netacc-gpn-204-88-167.pool.yettel.hu. [5.204.88.167]) by smtp.gmail.com with ESMTPSA id n25-20020a1709061d1900b008e9c79ff14csm13099857ejh.96.2023.03.26.06.54.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 26 Mar 2023 06:54:10 -0700 (PDT) Message-ID: <73f1483b-a450-7e8a-d565-665fae62a0a1@gmail.com> Date: Sun, 26 Mar 2023 15:54:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter Content-Language: sv-FI To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= References: <2496F2A0-3EB1-4CD2-B299-E1DC41B7C23B@gmail.com> <46A6C705-97DA-4D17-999B-0536F01EFCA7@thornhill.no> From: =?UTF-8?Q?Herman=2c_G=c3=a9za?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: 62412 Cc: Yuan Fu , Theodor Thornhill , 62412@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) On 3/25/23 12:43, João Távora wrote: > Let's assume you turn off electric-indent-mode. In c++-mode, pressing RET > after: > > int main() { > > "correctly" indents the next line. In c++-ts-mode, it doesn't. > > Both programs are ill-formed but you're right that after correcting > that, by say adding 'return 0; RET }', the c++-mode version of the > same program is closer to being correctly indented. I'd say that the current c++-ts-mode behavior is very bad for this example. If you type this into an empty buffer: int main() { and press RET, the new line won't get indented. But the case is worse, because TAB doesn't work either (doesn't do anything). Supposedly because tree sitter has the wrong idea of the indentation: if add indentation by using spaces, pressing TAB deletes the spaces. (Note: it doesn't matter whether electric-indent-mode is turned on or off, same thing happens). From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 11 20:03:16 2023 Received: (at 62412-done) by debbugs.gnu.org; 12 Sep 2023 00:03:16 +0000 Received: from localhost ([127.0.0.1]:55301 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qfqs8-0006Nx-3S for submit@debbugs.gnu.org; Mon, 11 Sep 2023 20:03:16 -0400 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]:44463) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qfqs4-0006Ni-QM for 62412-done@debbugs.gnu.org; Mon, 11 Sep 2023 20:03:14 -0400 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2bf78950354so41559401fa.1 for <62412-done@debbugs.gnu.org>; Mon, 11 Sep 2023 17:03:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694476982; x=1695081782; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:from:to:cc:subject:date :message-id:reply-to; bh=23ZM+V/ShkqVe01cRLPcJwnUnZCRobPLraK4Z03ZQzY=; b=l3IWf0xzDradZgz0F/52GGwPp6iah1HFHrkKFd8JfxQW91FEAMyAAQANPMDGWDcZ6T QoQcGLCwCEZ54zathRcrd9MgsulcDdjsqLLgSWb2vEgODeF+kwZG7Yea9Gr/7dxcKvi3 0aBtNPbOsWOjwYMGdIpjMic7u0Gr+cjUfO37aeoUm/84BlppEQf5aEgyw9pP7kN1QUOG KFGoyC1getS+Kl08KOjPKsEnaayu6qF6Y4SrTWwsETwN/Oo9TJDT7PeenTHzcI669udX 3wa4kDHSbZ/YHpUQY5np24m/S96Qf8GFhoTSuGfTSHrIuQopQoLRgD1DsfT+JgpMhgzN U+iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694476982; x=1695081782; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=23ZM+V/ShkqVe01cRLPcJwnUnZCRobPLraK4Z03ZQzY=; b=wyUCtG7Is0e1VNa1y5Fm80PhofG4Le/O4cMfDWN5EjudHlqVscwUMGhD46KADuJUF0 dylFjvuittkG4DogimLSW5a6IqCsRAYfkzPXrZU/h6LsFFgXE6H2vPQqiIRW+z46C+oT 9rF1rCDTLcTy31XEIMh1vEvBvGL+jWfGK5qbUMvHmLNla7+Oq/CThvHIJOwovxRSRBi0 n+2JmI/ukeWtuZ6HRzyWD7kF0I2uhinZwQoYIMGn6TuH1dcNUUEj11RT8hbmc2E8UdkB /0O/wWmMCNA7WTuC0BzXf68pqr1+p6hcYF3ZjIW7NBcrjKQpclNnfnOPhaxCv1LAxIPm RM6w== X-Gm-Message-State: AOJu0YwsuRfNwPqGhi3scfrbzG0ysPI6B8ZWTPeSxTj7GG2BgvpPqnu3 QgmaOMqoVthFn9jT+0NsCdbrzdc4AVNUI/XCztU= X-Google-Smtp-Source: AGHT+IGDeA745UtEj2Sv7kfR1raEhg7fmQlf3+QO8nxRzdlRZSQWkyLFFtCUMDBJ1iPPBOqycBXYBcafGS9rW51OUkA= X-Received: by 2002:a2e:9d90:0:b0:2bc:dada:dbe0 with SMTP id c16-20020a2e9d90000000b002bcdadadbe0mr9637895ljj.10.1694476982355; Mon, 11 Sep 2023 17:03:02 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 11 Sep 2023 17:03:01 -0700 From: Stefan Kangas In-Reply-To: <3FB95B26-42DD-4394-B8D7-AF0CBE079781@thornhill.no> (Theodor Thornhill's message of "Sat, 25 Mar 2023 18:41:37 +0100") References: <2496F2A0-3EB1-4CD2-B299-E1DC41B7C23B@gmail.com> <46A6C705-97DA-4D17-999B-0536F01EFCA7@thornhill.no> <72d72cd6-4fa8-2df3-f45d-5bf5845e4f38@gmail.com> <87o7ogx0jc.fsf@gmail.com> <3FB95B26-42DD-4394-B8D7-AF0CBE079781@thornhill.no> MIME-Version: 1.0 Date: Mon, 11 Sep 2023 17:03:01 -0700 Message-ID: Subject: Re: bug#62412: 29.0.60; strange c++ indentation behavior with tree sitter To: Theodor Thornhill Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 62412-done Cc: 62412-done@debbugs.gnu.org, Yuan Fu , =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= , =?UTF-8?B?SGVybWFuIEfDqXph?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Theodor Thornhill writes: > On 25 March 2023 17:23:35 CET, "Jo=C3=A3o T=C3=A1vora" wrote: >>"Herman, G=C3=A9za" writes: >> >>> Anyways, feel free to close this issue if you think otherwise. I >>> just disabled ';'-caused auto indenting, so I don't see this >>> unpleasant behavior any more. >> >>Yes, i'm inclined to think that c++-ts-mode shouldn't add any chars to >>electric-indent-chars. It's just not useful. > > I won't object to this, as I hold no strong opinions either way. It seems like this is not something we want to do, so I'm closing this bug. From unknown Mon Aug 18 18:01:02 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 10 Oct 2023 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator