From unknown Wed Jun 25 10:48:40 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#61142 <61142@debbugs.gnu.org> To: bug#61142 <61142@debbugs.gnu.org> Subject: Status: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions Reply-To: bug#61142 <61142@debbugs.gnu.org> Date: Wed, 25 Jun 2025 17:48:40 +0000 retitle 61142 29.0.60; java-ts-mode - Wrong indentation for the body of mul= tiple lines conditions reassign 61142 emacs submitter 61142 =E5=A4=AA=E9=98=B3 severity 61142 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 29 03:32:24 2023 Received: (at submit) by debbugs.gnu.org; 29 Jan 2023 08:32:24 +0000 Received: from localhost ([127.0.0.1]:42248 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pM36r-0001rO-8O for submit@debbugs.gnu.org; Sun, 29 Jan 2023 03:32:23 -0500 Received: from lists.gnu.org ([209.51.188.17]:39802) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pLysH-0006Lj-QG for submit@debbugs.gnu.org; Sat, 28 Jan 2023 23:01:05 -0500 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 1pLysH-0003T5-IU for bug-gnu-emacs@gnu.org; Sat, 28 Jan 2023 23:01:01 -0500 Received: from mail-sgaapc01olkn2038.outbound.protection.outlook.com ([40.92.53.38] helo=APC01-SG2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pLysE-0001fG-6b for bug-gnu-emacs@gnu.org; Sat, 28 Jan 2023 23:01:01 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tts6qEGXZsd53DN//36AghLg4tPKZHMogtkPYkForQdVWQ9xiYMi5lgLwwRHaHtb4DhfjkhUbNCSYUu2VYAUiM20hOiBb/ZETm0rZ1QAaPk9pj/9/2W6TWUsB29crPpjhNVr1zKO0t0dtnNIShDoKuoyipqJ+YDAPa9DApbnZkO61gaW2bQeLzGPO/Uhuo4IqpDbx3HvmpAJLGNJAmTiCuev6Jet/dgUdUz77CRFulHk5O8qh1k0uo2QgwdLZcn7w1h2w6Ow5aSotCUzPgRQSk8PRrfEQkeE4Sb3PRGP3o0nLzmY0smPp9rQB9aAYqh+XSB+1zP97G8PTvlPpwhnTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=u6HXrD1HLZAYWUqXlOU7DntqmXm8F6WNMYWWBwF6HzI=; b=MKkWmMidgx7tHAjeP4GtU+n18C0wrxuz6otXvMXWqbOWnsHIJ93qEKOWBCP+D6SPUbMCweA9r3XD4CviSgnGCoWgelwHI5Bz4apYpv1lZB7S1aNUqtBVNGWMaAPHJOW+hAolECRNfGKVrmSEPmz9E26txMKjIQ9esBo2954ETcnizsMQbff7Jd79LU3wNdj/Rndpht+ri9QtDOtnDSETKYRuwW7qU5w/LGEUCGPbML+xEKXJAS5uQmhtS5ClQT6NnShFA3hN5dTOS6NIex6eZJPuQ3pyH/lHO0IHId7tMeSuDPqyZfvP33KWATjCBMc2wGEK3iJBIcrLzOWPgj/iSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u6HXrD1HLZAYWUqXlOU7DntqmXm8F6WNMYWWBwF6HzI=; b=qYV/tWkiG8bDSFGrjbZ3weVs+c9hSOtJxuWpUoXldqbGVtTrwGOL7qaiOvVzoqSyf+ODZoFu3NQHJJxYlP8L3nWgDc4PwWZaS888ILL8XRDWCgvPvNepWRXBPdADIXoVzkAY/kZMUjk9u0D21M4rUnVhNs0/PbuSyGdgfNKDj2h/Sxnk9s6m4ELYUKGvfdrXSVzxUQEoQDxP6lG0wBwCsVmz00VQhMsd/7NDR0Drf6psqwoIWdgGcYHW4JpjxOFyPTt6dDf5eLj1+TvoU7m5pf3XCDhTjeQSGCRyxXerAqbNAv9by7ZiDPSqzY1HU+aQG54RypqzGcuweSKLDZdSMw== Received: from OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:13e::13) by TYWP286MB3591.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:396::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.33; Sun, 29 Jan 2023 04:00:52 +0000 Received: from OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM ([fe80::c3e:9933:93cd:8cfa]) by OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM ([fe80::c3e:9933:93cd:8cfa%5]) with mapi id 15.20.6043.031; Sun, 29 Jan 2023 04:00:52 +0000 Content-Type: text/plain; charset=utf-8 Message-ID: From: =?UTF-8?Q?=E5=A4=AA=E9=98=B3?= To: bug-gnu-emacs@gnu.org Subject: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions Date: Sun, 29 Jan 2023 04:00:46 +0000 X-Mailer: Vivaldi Mail User-Agent: Vivaldi Mail/1.3.2867.58 Content-Transfer-Encoding: quoted-printable X-TMN: [yLYSgOojMg0Z+XdiATy2Me7xw5APO69l] X-ClientProxiedBy: SI2P153CA0030.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::15) To OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:13e::13) X-Microsoft-Original-Message-ID: <1674964289135.1825926093.4037868981@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OSZP286MB1417:EE_|TYWP286MB3591:EE_ X-MS-Office365-Filtering-Correlation-Id: 25b4f620-a18b-4789-1bcd-08db01ad69f9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 35pK3IEE0AC6VkR9tC81oGI3cdTx/SSoZfrBpGn+SLR2m/YEUwlO0VJb+g8LvygB7AERCI+ciLN/sSCsLbfUNjkkOJufczcbOo0P66ztlGmEyV68LTpTQXdG2wlqbs6Qgve/sJOgZbxVZrSq66OaefLQLg0gC2rO94+aXo9nkfLXFzoxcsZ/+QOqWYxPTjztdk0ygdXXHicTNhzu2g1u1WzTUDWrPk6ij71TPaK7Q31HUgJrYSNqunWDIrh3lD9Qsii3z7q6K2FJRYe1jbHzeaf9dovQnvZWu3/vSRgMJtAIwO2G7W6Dr3OnAauTVxVkEc+Zn3FiR2fxQaONjMoUDtGDyZYqMER3aUNesg0GgNn+s3JBh26IO3cL8a5OyOgTp8isjigkqM0WGgxKYwarnWMbKrEl4Ae8x/+dIT6Q3YCcYSvDzsORf4tVSHHRAqdWJR8VwQz+ziujXQVMVnwtxwb6I/0qEtiVU/qd4IGtasL0dMmTxTn6alrBVj4R6TVMzIC5pTy5e0Vxuk0UWQ326z3rNmmj6Zv8B1S6FPMGFRJdQoTjNnYsfytpaVn9/t54OCfv8/lHN6GlM1hZSsVNRbtDpuY03UFUexZf7IYFScc= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?QzZmdXg5SElvUHI3Q1hSN0V0TFdLN2dXZ3YyWWZSS1hwZUJ0ZEtKcmU5TjNm?= =?utf-8?B?NGdCNkIyK2RrbEM4Qn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db01ad69f9 X-MS-Exchange-CrossTenant-AuthSource: OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2023 04:00:52.7717 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWP286MB3591 Received-SPF: pass client-ip=40.92.53.38; envelope-from=zjyzhaojiyang@hotmail.com; helo=APC01-SG2-obe.outbound.protection.outlook.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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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-Mailman-Approved-At: Sun, 29 Jan 2023 03:32:20 -0500 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 (--) Hi I mean for code like this: ``` public class T { public void F(String s) { if ("abc".equals(s) // if condition occupies two lines. || "bcd".equals(s)) { return; // <=3D=3D=3D=3D this line has= one more level of indentation } } } ``` It seems that the body is indented according to the last line of the condit= ion. If the `if` condition is rewritten to one line, `return;` is indented corre= ctly. This also happens to multiple-line `while` (I haven't only tested `if` and = `while`). Thanks for your hard work. :) In GNU Emacs 29.0.60 (build 14, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 2023-01-29 built on tux-manjaro Repository revision: 2bd0b9475384adfb4dd2cc794bbe1d8621546717 Repository branch: makepkg Windowing system distributor 'The X.Org Foundation', version 11.0.12101006 System Description: Manjaro Linux Configured using: 'configure --prefix=3D/usr --sysconfdir=3D/etc --libexecdir=3D/usr/lib --localstatedir=3D/var --mandir=3D/usr/share/man --with-gameuser=3D:games --with-modules --without-libotf --without-m17n-flt --without-gconf --with-native-compilation=3Dno --with-xinput2 --with-x-toolkit=3Dlucid --with-xft --with-xaw3d --without-cairo --with-sound=3Dno --with-tree-sitter --without-gpm --without-compress-install '--program-transform-name=3Ds/\([ec]tags\)/\1.emacs/' 'CFLAGS=3D-march=3Dx86-64 -mtune=3Dgeneric -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3D2 -Wformat -Werror=3Dformat-security -fstack-clash-protection -fcf-protection' LDFLAGS=3D-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now' Configured features: ACL DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XAW3D XDBE XFT XIM XINPUT2 XPM LUCID ZLIB Important settings: value of $LC_MONETARY: zh_CN.UTF-8 value of $LC_NUMERIC: zh_CN.UTF-8 value of $LC_TIME: zh_CN.UTF-8 value of $LANG: zh_CN.UTF-8 value of $XMODIFIERS: @im=3Dfcitx locale-coding-system: utf-8 Major mode: Java Minor modes in effect: yas-global-mode: t yas-minor-mode: t winner-mode: t recentf-mode: t helm--remap-mouse-mode: t async-bytecomp-package-mode: t which-function-mode: t hl-todo-mode: t dumb-jump-mode: t yafolding-mode: t auto-dim-other-buffers-mode: t global-display-line-numbers-mode: t display-line-numbers-mode: t global-so-long-mode: t global-hl-line-mode: t super-save-mode: t ctags-global-auto-update-mode: t ctags-auto-update-mode: t highlight-symbol-mode: t hungry-delete-mode: t corfu-history-mode: t corfu-popupinfo-mode: t global-corfu-mode: t corfu-mode: t evil-escape-mode: t global-evil-surround-mode: t evil-surround-mode: t shell-dirtrack-mode: t evil-local-mode: t windmove-mode: t eww-plus-mode: t all-the-icons-ivy-rich-mode: t ivy-rich-project-root-cache-mode: t ivy-rich-mode: t ivy-mode: t global-highlight-parentheses-mode: t highlight-parentheses-mode: t electric-pair-mode: t which-key-mode: t psessionm-mode: t psessionm-savehist-mode: t ace-pinyin-global-mode: t ace-pinyin-mode: t global-anzu-mode: t anzu-mode: t amx-mode: t auto-compile-on-load-mode: t auto-compile-on-save-mode: t override-global-mode: t save-place-mode: t display-time-mode: t global-auto-revert-mode: t gcmh-mode: t tooltip-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t column-number-mode: t line-number-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: /home/lucency/.emacs.d/data/unsync/elpa29/transient-20230124.2013/transient= hides /usr/share/emacs/29.0.60/lisp/transient /home/lucency/.emacs.d/data/unsync/elpa29/use-package-20221209.2013/use-pac= kage-bind-key hides /usr/share/emacs/29.0.60/lisp/use-package/use-package-b= ind-key /home/lucency/.emacs.d/data/unsync/elpa29/use-package-20221209.2013/use-pac= kage-diminish hides /usr/share/emacs/29.0.60/lisp/use-package/use-package-d= iminish /home/lucency/.emacs.d/data/unsync/elpa29/use-package-20221209.2013/use-pac= kage-lint hides /usr/share/emacs/29.0.60/lisp/use-package/use-package-lint /home/lucency/.emacs.d/data/unsync/elpa29/use-package-20221209.2013/use-pac= kage hides /usr/share/emacs/29.0.60/lisp/use-package/use-package /home/lucency/.emacs.d/data/unsync/elpa29/use-package-20221209.2013/use-pac= kage-ensure hides /usr/share/emacs/29.0.60/lisp/use-package/use-package-ens= ure /home/lucency/.emacs.d/data/unsync/elpa29/use-package-20221209.2013/use-pac= kage-core hides /usr/share/emacs/29.0.60/lisp/use-package/use-package-core /home/lucency/.emacs.d/data/unsync/elpa29/use-package-20221209.2013/use-pac= kage-delight hides /usr/share/emacs/29.0.60/lisp/use-package/use-package-de= light /home/lucency/.emacs.d/data/unsync/elpa29/use-package-20221209.2013/use-pac= kage-jump hides /usr/share/emacs/29.0.60/lisp/use-package/use-package-jump /home/lucency/.emacs.d/data/unsync/elpa29/bind-key-20221209.2013/bind-key h= ides /usr/share/emacs/29.0.60/lisp/use-package/bind-key Features: (shadow mail-extr emacsbug message yank-media rfc822 mml mml-sec epa epg rfc6068 epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils sendmail rfc2047 rfc2045 ietf-drums mule-util dabbrev helm-command helm-mode modern-cpp-font-lock cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs yasnippet-snippets yasnippet winner ffap recentf tree-widget tramp-archive tramp-gvfs dbus helm-x-files helm-for-files helm-bookmark helm-adaptive helm-external helm-net helm-misc helm-elisp helm-files image-dired image-dired-tags image-dired-external image-dired-util helm-buffers helm-occur helm-tags helm-locate helm-grep helm-regexp helm-eval helm-info helm-utils helm-types helm-help helm helm-global-bindings helm-easymenu helm-core async-bytecomp helm-source helm-multi-match helm-lib which-func imenu hl-todo dumb-jump yafolding auto-dim-other-buffers display-line-numbers so-long hl-line super-save ivy-stock stock-analyze stock-leek stock stock-baostock stock-tushare stock-db stock-db-tushare stock-db-baostock stock-util stock-struct csv gitec gnuplot info-look aggressive-indent java-ts-mode c-ts-common ob-rust cmake-mode rst flymake-cursor ctags-update etags fileloop highlight-symbol hungry-delete topsy treesit pb corfu-history corfu-popupinfo cape corfu cal-china-x cal-china lunar solar cal-dst holidays holiday-loaddefs language-chunk lc-memo lc-corpus lc-storage lc-db emacsql-sqlite3 emacsql emacsql-compiler lc-util lc-struct lc-const ivy-anotes anotes anotes-struct counsel-deft f f-shortdoc dash-docs gnutls doc-view jka-compr image-mode exif vterm vc-git diff-mode vc-dispatcher bookmark tramp tramp-loaddefs trampver tramp-integration tramp-compat parse-time iso8601 ls-lisp term disp-table ehelp vterm-module term/xterm xterm evil-god-state god-mode evil-escape evil-surround evil-anzu evil evil-keybindings evil-maps evil-commands reveal evil-jumps evil-command-window evil-search evil-ex shell evil-types evil-macros evil-repeat evil-states evil-core evil-common windmove calc calc-loaddefs calc-macs rect evil-digraphs evil-vars diminish eww-plus eww url-queue shr-tag-pre-highlight language-detection shrface shr pixel-fill kinsoku url-file svg xml dom puny mm-url gnus nnheader gnus-util range mm-util mail-prsvr request mailheader mail-utils bm ivy-xref ivy-hydra hydra lv all-the-icons-ivy-rich all-the-icons all-the-icons-faces data-material data-weathericons data-octicons data-fileicons data-faicons data-alltheicons ivy-rich ivy-plus pulse flymake-proc flymake warnings heap counsel xref project dired-open dired-hacks-utils dired-x dired dired-loaddefs compile text-property-search swiper ivy ivy-faces ivy-overlay colir color weblorg templatel em-glob esh-util cus-edit wid-edit files-x ox-odt rng-loc rng-uri rng-parse rng-match rng-dt rng-util rng-pttrn nxml-parse nxml-ns nxml-enc xmltok nxml-util ox-latex ox-icalendar org-agenda ox-html table ox-ascii ox-publish ox org-appear org-element org-persist xdg org-id org-refile avl-tree generator diary-lib diary-loaddefs org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-src ob-comint org-pcomplete pcomplete comint ansi-osc ansi-color org-list org-footnote org-faces org-entities time-date noutline outline icons ob-emacs-lisp ob-core ob-eval org-cycle org-table ol org-fold org-fold-core org-keys oc org-loaddefs cal-menu calendar cal-loaddefs org-version org-compat org-macs highlight-parentheses log4j-mode elec-pair which-key psessionm gitignore-mode vundo pcase pyim-cstring-utils pyim-cregexp-utils pyim pyim-cloudim pyim-probe pyim-preview pyim-page popup posframe-plus posframe pyim-indicator pyim-dregcache pyim-dhashcache sort pyim-dict async pyim-autoselector pyim-process pyim-punctuation pyim-outcome pyim-candidates pyim-cstring pyim-cregexp xr rx pyim-codes pyim-imobjs pyim-pinyin pyim-entered pyim-dcache pyim-pymap pyim-scheme pyim-common ace-pinyin avy ring pinyinlib anzu thingatpt amx s transient format-spec compat ht dash use-package-diminish auto-compile ispell edmacro kmacro use-package-bind-key bind-key easy-mmode conf-mode saveplace time server pinentry autorevert filenotify tab-line doom-vibrant-theme doom-themes-ext-org doom-themes-ext-visual-bell face-remap doom-themes doom-themes-base gcmh cl-extra use-package-core delsel cus-load finder-inf amx-autoloads all-the-icons-ivy-rich-autoloads corfu-doc-autoloads dired-open-autoloads helm-autoloads helm-core-autoloads auto-compile-autoloads evil-surround-autoloads use-package-autoloads rainbow-mode-autoloads alert-autoloads cal-china-x-autoloads posframe-autoloads hungry-delete-autoloads counsel-autoloads sdcv-autoloads smart-compile-autoloads eww-lnum-autoloads elfeed-autoloads jsonian-autoloads corfu-autoloads expand-region-autoloads hide-lines-autoloads php-mode-autoloads magit-autoloads magit-section-autoloads ivy-rich-autoloads crontab-mode-autoloads yaml-mode-autoloads topsy-autoloads company-box-autoloads frame-local-autoloads dumb-jump-autoloads ivy-hydra-autoloads sql-indent-autoloads highlight-symbol-autoloads git-modes-autoloads cape-autoloads evil-tutor-autoloads pinentry-autoloads request-autoloads heap-autoloads showtip-autoloads go-mode-autoloads highlight-parentheses-autoloads powerline-autoloads ascii-table-autoloads vundo-autoloads shr-tag-pre-highlight-autoloads log4j-mode-autoloads youdao-dictionary-autoloads derived pp names edebug debug backtrace help-mode find-func names-autoloads advice gcmh-autoloads hl-todo-autoloads hydra-autoloads lv-autoloads ob-rust-autoloads rust-mode-autoloads git-commit-autoloads with-editor-autoloads chinese-word-at-point-autoloads iedit-autoloads diminish-autoloads language-detection-autoloads vterm-autoloads doom-themes-autoloads evil-anzu-autoloads anzu-autoloads popup-autoloads packed-autoloads evil-escape-autoloads evil-autoloads emacsql-sqlite3-autoloads emacsql-autoloads ace-pinyin-autoloads pinyinlib-autoloads avy-autoloads auto-dim-other-buffers-autoloads pos-tip-autoloads async-autoloads ht-autoloads yasnippet-snippets-autoloads yasnippet-autoloads templatel-autoloads gntp-autoloads eshell-toggle-autoloads xr-autoloads org-appear-autoloads gnuplot-autoloads cargo-autoloads markdown-mode-autoloads htmlize-autoloads sqlup-mode-autoloads modern-cpp-font-lock-autoloads unicad-autoloads super-save-autoloads queue-autoloads bind-key-autoloads aggressive-indent-autoloads which-key-autoloads company-statistics-autoloads company-autoloads log4e-autoloads transient-autoloads compat-autoloads csv-mode-autoloads helpful-autoloads elisp-refs-autoloads f-autoloads s-autoloads rfc-mode-autoloads web-mode-autoloads swiper-autoloads ivy-autoloads dired-hacks-utils-autoloads info dash-autoloads dockerfile-mode-autoloads all-the-icons-autoloads kv-autoloads goto-chg-autoloads bm-autoloads package-installer-package package browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs password-cache json subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib china-util 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 dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting x-toolkit xinput2 x multi-tty make-network-process emacs) Memory information: ((conses 16 868713 194867) (symbols 48 55153 0) (strings 32 258665 59271) (string-bytes 1 7565062) (vectors 16 286268) (vector-slots 8 2047867 360407) (floats 8 92581 819) (intervals 56 5305 1112) (buffers 984 19)) --=20 =E5=8F=91=E9=80=81=E8=87=AA Vivaldi =E9=82=AE=E4=BB=B6=E3=80=82=E8=AE=BF=E9= =97=AE vivaldi.com =E5=85=8D=E8=B4=B9=E4=B8=8B=E8=BD=BD From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 01 04:13:25 2023 Received: (at 61142) by debbugs.gnu.org; 1 Feb 2023 09:13:26 +0000 Received: from localhost ([127.0.0.1]:56449 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pN9BD-0005ZG-PS for submit@debbugs.gnu.org; Wed, 01 Feb 2023 04:13:25 -0500 Received: from mail-tyzapc01olkn2064.outbound.protection.outlook.com ([40.92.107.64]:49414 helo=APC01-TYZ-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pN8mC-0002P3-Ba for 61142@debbugs.gnu.org; Wed, 01 Feb 2023 03:47:47 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z1gvbAOjTYVC1+Yp3nM74rvVlNT0BLNqmD0oz0FUcNzD5By1g9gGrtpFAAW/3pNaCw/revXypEJ2n+1xpUMzyKSmB+X/Z/4AIl134YLnCkwA8nOZKGEuSW/sXMP1bYngLR1PAW39/rKshepVFpzNRnNeQuq+qNGipFkf7xvk+mI/LTcAuUR54daJREFTi2v1ypyPi8aYGHyJgSAcoWheysUnTz0gUyoeMJsRqub2+mU5jLZSG1djL5AlJC00Mt/1eVNjW+sefzvBONPcz+bVFlZ0pX8nx/uZNXE6AdDQxzba7B4RkJO6uGS7KEm67mscXuEF+Dw2l7+Zl+/VllOPBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gob5u/eoifqg2C7n0CmVM6cN6XkgFZuUFik7d4uy58w=; b=Uxi8ChVIGW8BhGJ0KHP3+fUOuCUGoMWsL9//X8mN4ixARWVLo5zpumFdF0Uf9rbG98XRIWB/i0dSxF70QUqujXd/aL6vpZJnDk9kff9ymEIC1MGIoyOmKSkaP3mjF1Ds8K7f6lkUH1Jo0V07kJTbmnUYoc9Id94vR//9cx/AZE8mRT5ahe/oCqlmUQ7qUxGJADd5HdBoMKeS7VPh00wwWYrOw1zYeocTy2YKzza0xRHKZS88N/7PsL5yOc+XM4YZESapKl8J+Ud7v+0ETLqQhueMTcxWTWiPCQs27tE4jZD4tbqWt3DtnXoz72yKk5+enCf3pybmsUeSkO+Dc/LqDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gob5u/eoifqg2C7n0CmVM6cN6XkgFZuUFik7d4uy58w=; b=qjEoTzCzvgPpeZvsbXkR2VeszSKh4jvSJso4nKC2ZMVCg5eK8wZqKME1A563CbThFav57E5uR9lbRM6l9b70jPGQHcn+rpcYcKXaLfQ868jEB7BCs3ckt6i8ZhnY/UCXiJVBKqLcJDcocwDAGCmR8deWdA2AD0Gx0fJByQ8f9NPQ6Bt3BM+NTo8GNsAtlaGkVbBVG/TuyrL8eB7cHUtJEFJlDO496OPNnNWdh8TIV9XCcph+InB+Wt8UFp0fON7VXMw79BtU53nMXrnre/NwjSlHquIYHE7TtGp6oq1/JRkTZBC9qayzOR0k9kPkn+UXnsAQeolaBsO+L4KRzX2QQg== Received: from OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:13e::13) by TYTP286MB3461.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:39f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.22; Wed, 1 Feb 2023 08:46:33 +0000 Received: from OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM ([fe80::c3e:9933:93cd:8cfa]) by OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM ([fe80::c3e:9933:93cd:8cfa%4]) with mapi id 15.20.6043.036; Wed, 1 Feb 2023 08:46:33 +0000 Content-Type: text/plain; charset=utf-8 Message-ID: From: =?UTF-8?Q?=E5=A4=AA=E9=98=B3?= To: 61142@debbugs.gnu.org, GNU bug Tracking System Subject: Re: bug#61142: Acknowledgement (29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions) Date: Wed, 01 Feb 2023 08:46:28 +0000 In-Reply-To: References: X-Mailer: Vivaldi Mail User-Agent: Vivaldi Mail/1.3.2867.58 Content-Transfer-Encoding: quoted-printable X-TMN: [qP9VonjIKEQXcogGNQgjvxbaVMFbpAH6] X-ClientProxiedBy: SG2PR02CA0063.apcprd02.prod.outlook.com (2603:1096:4:54::27) To OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:13e::13) X-Microsoft-Original-Message-ID: <1675240771678.2373746191.3557144216@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OSZP286MB1417:EE_|TYTP286MB3461:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ad7d255-a8f5-4ae3-2d3f-08db0430d212 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0Y7DEKXycWe2Bo7KHxa3g1VrPNG7R79Ryrgq3nqRKI0n2b/wGQ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Xk1TllQQ1A5dVhPT1VJcFlkM3gzcjR6cmgvMVM0dUdPeCtKSDI5V25J?= =?utf-8?B?MlBJcy83YUNydS9ibUFRZnZtc2FHaEJYSEFYOXBmMUxKcGNuZStjWjBLZE1E?= =?utf-8?B?TGx0enNxcDBJODQwTlExam9qNHBpdGhmSWZtWnhSOHB4RElkZHBhUzEwK2Rt?= =?utf-8?B?T0dkc203UmtXcHdXSDhHMEgvdDRjSkhyTzJBa1hKdnE5NlRBdGVoTDFqenNH?= =?utf-8?B?a1RUTWFyeG0xWU1mMks5Y1hSSzlDMzdaMXFoL085MnM1V0k2SE90M0NjbkV4?= =?utf-8?B?ek5CdVExYXdMQmtpRWtTMG1YNzFjVFBhSUhBZHZ3WkFOcUNheUNFK1JkZHVz?= =?utf-8?B?UUI4ZmQyK0pzWGdKNHVZTUdUem1WVGVPdHlYbjBjM3RLUG1TY0xwaVBadllj?= =?utf-8?B?VUpRZXMzNXA1ais5b2dyY1hvTWFleGlvdVBYcTR4YklXSXNIVGJmK1U0VWZm?= =?utf-8?B?OUR2N1ZMcUZDbjg0U1Z5WmdmY0pCZHRuMHMrT1dIYkFncm5ZUVNEUlYzU3dL?= =?utf-8?Q?CRTAUeGnc9Wr65VETw=3D?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-05f45.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 6ad7d255-a8f5-4ae3-2d3f-08db0430d212 X-MS-Exchange-CrossTenant-AuthSource: OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 08:46:33.8475 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYTP286MB3461 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 61142 X-Mailman-Approved-At: Wed, 01 Feb 2023 04:13:09 -0500 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 (-) After reading treesit's manual, I found that we can use `n-p-gp` as the mat= cher and `grand-parent` as the anchor to match the body of `if` (and `while= `, which has a similar issue).=20 I mean a rule looks like the following: ``` ((n-p-gp nil "block" "if_statement") grand-parent java-ts-mode-indent-offse= t) ``` GNU bug Tracking System =E5=9C=A8 2023=E5=B9=B401=E6=9C=8829=E6=97=A5 =E6= =98=9F=E6=9C=9F=E6=97=A5 16=E6=97=B633=E5=88=8603=E7=A7=92 (+08:00) =E5=86= =99=E9=81=93=EF=BC=9A > Thank you for filing a new bug report with debbugs.gnu.org. >=20 > This is an automatically generated reply to let you know your message > has been received. >=20 > Your message is being forwarded to the package maintainers and other > interested parties for their attention; they will reply in due course. >=20 > Your message has been sent to the package maintainer(s): > bug-gnu-emacs@gnu.org >=20 > If you wish to submit further information on this problem, please > send it to 61142@debbugs.gnu.org. >=20 > Please do not send mail to help-debbugs@gnu.org unless you wish > to report a problem with the Bug-tracking system. >=20 --=20 =E5=8F=91=E9=80=81=E8=87=AA Vivaldi =E9=82=AE=E4=BB=B6=E3=80=82=E8=AE=BF=E9= =97=AE vivaldi.com =E5=85=8D=E8=B4=B9=E4=B8=8B=E8=BD=BD From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 04 05:45:37 2023 Received: (at 61142) by debbugs.gnu.org; 4 Feb 2023 10:45:37 +0000 Received: from localhost ([127.0.0.1]:40757 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOG36-0001SV-QU for submit@debbugs.gnu.org; Sat, 04 Feb 2023 05:45:37 -0500 Received: from out-36.mta0.migadu.com ([91.218.175.36]:50415) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOG34-0001SN-SI for 61142@debbugs.gnu.org; Sat, 04 Feb 2023 05:45:35 -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=1675507533; 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=acKdWCjHgIMAshk7hOAD5c0QDLXzKqpj4b/SGSmTyDw=; b=YvORqm+u3Rjc0OEE86Q6JWOpA6xapkzHwu6WewL12W1eP3phn+7FBxDn9GsANdNnpmEwZc cbUUOa+PzX1rrfuzq2TUDgOfbHCfkJ/1zYPlPBxgkNMkxiQ+Gg6RuLIvFAtCIA0aYyTFbl rBiqVCubLvAlcwkNYPa6fiJyDz5TTj751U6CMKUVIDop25WoNOpHCcAO6CLHGNpGC4MDbF 1nkFOH0ZfDx7I1AMpgVRDUi8F+ETZ1DLnkDBX4Fexl+Bgj5LtJraw0PwIwYrucXZwh5c5D 2Ul61L/w5ncUGDBzydEB99JZq/RetF5OeBD3ncyYeXrVOVOhTZPNRAq0jd4JpQ== From: Theodor Thornhill To: =?utf-8?B?5aSq6Ziz?= Subject: Re: bug#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions In-Reply-To: (=?utf-8?B?IuWkqumYsyIncw==?= message of "Wed, 01 Feb 2023 08:46:28 +0000") References: Date: Sat, 04 Feb 2023 11:45:31 +0100 Message-ID: <87wn4x7lpw.fsf_-_@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: 61142 Cc: 61142@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 (-) =E5=A4=AA=E9=98=B3 writes: > After reading treesit's manual, I found that we can use `n-p-gp` as the m= atcher > and `grand-parent` as the anchor to match the body of `if` (and `while`, = which > has a similar issue). > > I mean a rule looks like the following: > > ``` > ((n-p-gp nil "block" "if_statement") grand-parent java-ts-mode-indent-off= set) > ``` > > Thanks! We have a mechanism in place for this, see 'c-ts-common-statement-offset' in 'c-ts-common.el'. I didn't get to it yet, but I'll try to look at it this evening, unless you want to? See c-ts-mode for examples of how to use it, if you're interested! Theo From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 05 02:53:42 2023 Received: (at 61142) by debbugs.gnu.org; 5 Feb 2023 07:53:42 +0000 Received: from localhost ([127.0.0.1]:44011 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOZqH-0000Ed-N0 for submit@debbugs.gnu.org; Sun, 05 Feb 2023 02:53:42 -0500 Received: from out-82.mta1.migadu.com ([95.215.58.82]:51204) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOZqF-0000ET-Br for 61142@debbugs.gnu.org; Sun, 05 Feb 2023 02:53:40 -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=1675583615; 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=kr8nA74M4qEIq7l9zjFd/HN+vAetPVIUPcqxiGhWquI=; b=pQV6CwvVpXckLhV5mBoi05xu9Op28A5r4LaqiiOcFVErz19NDSL2DT3PvzxfEnG5ai1LDt sZsbNgT7P1wH06YexyIZndt1HDO1kiVzEw7rms4QDhgiWHQ/yb0QJBV+u+f6c/u9OCOXip YxlPJc9CpL2PM7qH9o6Co0a9c4xRaR+FFZnL5oZYH+DjNE3gJRSlCk4Tblp6/pg56Q6Gyi 3K8VInVll9jGNu0oylwWMJ+/VthF4n4ySQ9bUoO7+Ensas2I1mscJnlCXBtl+vhuErcnHy +AwSa417zVBbocgqtN+x6QasGVGE/u60Gt/ACftlc1ABIAoNPNIe3Hwgt2m9YQ== From: Theodor Thornhill To: =?utf-8?B?5aSq6Ziz?= Subject: Re: bug#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions In-Reply-To: <87wn4x7lpw.fsf_-_@thornhill.no> (Theodor Thornhill's message of "Sat, 04 Feb 2023 11:45:31 +0100") References: <87wn4x7lpw.fsf_-_@thornhill.no> Date: Sun, 05 Feb 2023 08:53:33 +0100 Message-ID: <87r0v47dky.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61142 Cc: 61142@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 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Theodor Thornhill writes: > =E5=A4=AA=E9=98=B3 writes: > >> After reading treesit's manual, I found that we can use `n-p-gp` as the = matcher >> and `grand-parent` as the anchor to match the body of `if` (and `while`,= which >> has a similar issue). >> >> I mean a rule looks like the following: >> >> ``` >> ((n-p-gp nil "block" "if_statement") grand-parent java-ts-mode-indent-of= fset) >> ``` >> >> > > > Thanks! We have a mechanism in place for this, see > 'c-ts-common-statement-offset' in 'c-ts-common.el'. I didn't get to it > yet, but I'll try to look at it this evening, unless you want to? See > c-ts-mode for examples of how to use it, if you're interested! > > Theo Hi again! Can you test this patch for me? @Eli: Is this ok for emacs-29? I'd love to add some test for this, but now they are on the master branch. What is the common procedure to move stuff from master branch to the release branch? I _can_ just add some test to the master branch, but it would be nice to have them on emacs-29 too :-) Theo --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Use-c-ts-common-statement-offset-in-java-ts-mode.patch >From 18beb67646446363cec98e4074822b9fcf270d12 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Sun, 5 Feb 2023 08:49:08 +0100 Subject: [PATCH] Use c-ts-common-statement-offset in java-ts-mode * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Add new matchers to enable c-ts-common machinery. (java-ts-mode): Add regexps. * lisp/progmodes/c-ts-common.el (c-ts-common-statement-offset): Fix typo. --- lisp/progmodes/c-ts-common.el | 2 +- lisp/progmodes/java-ts-mode.el | 34 +++++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/lisp/progmodes/c-ts-common.el b/lisp/progmodes/c-ts-common.el index 8729cae4ba..188734badb 100644 --- a/lisp/progmodes/c-ts-common.el +++ b/lisp/progmodes/c-ts-common.el @@ -285,7 +285,7 @@ c-ts-common-statement-offset "This anchor is used for children of a statement inside a block. This function basically counts the number of block nodes (i.e., -brackets) (defined by `c-ts-mode--indent-block-type-regexp') +brackets) (defined by `c-ts-common-indent-block-type-regexp') between NODE and the root node (not counting NODE itself), and multiply that by `c-ts-common-indent-offset'. diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index b9f7894095..1b6f2ba8b3 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -70,22 +70,24 @@ java-ts-mode--syntax-table (defvar java-ts-mode--indent-rules `((java ((parent-is "program") point-min 0) - ((node-is "}") (and parent parent-bol) 0) + ((match "}" "element_value_array_initializer") + parent-bol 0) + ((node-is "}") point-min c-ts-common-statement-offset) ((node-is ")") parent-bol 0) ((node-is "]") parent-bol 0) ((and (parent-is "comment") c-ts-common-looking-at-star) c-ts-common-comment-start-after-first-star -1) ((parent-is "comment") prev-adaptive-prefix 0) ((parent-is "text_block") no-indent) - ((parent-is "class_body") parent-bol java-ts-mode-indent-offset) + ((parent-is "class_body") point-min c-ts-common-statement-offset) ((parent-is "array_initializer") parent-bol java-ts-mode-indent-offset) - ((parent-is "annotation_type_body") parent-bol java-ts-mode-indent-offset) - ((parent-is "interface_body") parent-bol java-ts-mode-indent-offset) - ((parent-is "constructor_body") parent-bol java-ts-mode-indent-offset) + ((parent-is "annotation_type_body") point-min c-ts-common-statement-offset) + ((parent-is "interface_body") point-min c-ts-common-statement-offset) + ((parent-is "constructor_body") point-min c-ts-common-statement-offset) ((parent-is "enum_body_declarations") parent-bol 0) - ((parent-is "enum_body") parent-bol java-ts-mode-indent-offset) - ((parent-is "switch_block") parent-bol java-ts-mode-indent-offset) - ((parent-is "record_declaration_body") parent-bol java-ts-mode-indent-offset) + ((parent-is "enum_body") point-min c-ts-common-statement-offset) + ((parent-is "switch_block") point-min c-ts-common-statement-offset) + ((parent-is "record_declaration_body") point-min c-ts-common-statement-offset) ((query "(method_declaration (block _ @indent))") parent-bol java-ts-mode-indent-offset) ((query "(method_declaration (block (_) @indent))") parent-bol java-ts-mode-indent-offset) ((parent-is "local_variable_declaration") parent-bol java-ts-mode-indent-offset) @@ -118,7 +120,7 @@ java-ts-mode--indent-rules ((parent-is "case_statement") parent-bol java-ts-mode-indent-offset) ((parent-is "labeled_statement") parent-bol java-ts-mode-indent-offset) ((parent-is "do_statement") parent-bol java-ts-mode-indent-offset) - ((parent-is "block") (and parent parent-bol) java-ts-mode-indent-offset))) + ((parent-is "block") point-min c-ts-common-statement-offset))) "Tree-sitter indent rules.") (defvar java-ts-mode--keywords @@ -300,6 +302,20 @@ java-ts-mode (c-ts-common-comment-setup) ;; Indent. + (setq-local c-ts-common-indent-block-type-regexp + (rx (or "class_body" + "\\`array_initializer" + "annotation_type_body" + "interface_body" + "interface_constructor_body" + "enum_body" + "switch_block" + "record_declaration_body" + "block"))) + (setq-local c-ts-common-indent-bracketless-type-regexp + (rx (or "if_statement" "do_statement" + "for_statement" "while_statement"))) + (setq-local c-ts-common-indent-offset 'java-ts-mode-indent-offset) (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) ;; Electric -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 05 02:54:56 2023 Received: (at 61142) by debbugs.gnu.org; 5 Feb 2023 07:54:56 +0000 Received: from localhost ([127.0.0.1]:44016 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOZrU-0000GZ-99 for submit@debbugs.gnu.org; Sun, 05 Feb 2023 02:54:56 -0500 Received: from out-245.mta1.migadu.com ([95.215.58.245]:52331) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOZrR-0000GQ-UG for 61142@debbugs.gnu.org; Sun, 05 Feb 2023 02:54:55 -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=1675583692; 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=8axufmZYZH0vLUdvL6TgKoXJTd/mu0+7O0oSXr2nvoM=; b=TGjGUJBbcq/yIyOLw5Rb0rOKS3g/MmkPGVViJHnjSY2E1dqMdtx5RLaA/+sNcwrygJFylq rEILPvoY8yTLrtyWl3O7VfFcbck3R17oBy2qzhWjQfWIugjoUUT4iV5TrwxuEmI4IO3h/f rcj3s05XzKn4/xivyZowh92eVPNkZo66PbPrth0Idy+5ZFs5JT8w42JVbBPReiljpnSlyi jFMozmIlXKSFQNJsqf0mB+a54JytyUzwIa7xTl7i06uOJPytlVHF4oRwKA3TLUhIEbzbgm oRvlhaHNYRRmkRv83/yA1uqlCPchbZmtwOTWllqqfhgctIs6WVuaVRN/GJ1jaQ== From: Theodor Thornhill To: =?utf-8?B?5aSq6Ziz?= Subject: Re: bug#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions In-Reply-To: <87r0v47dky.fsf@thornhill.no> (Theodor Thornhill's message of "Sun, 05 Feb 2023 08:53:33 +0100") References: <87wn4x7lpw.fsf_-_@thornhill.no> <87r0v47dky.fsf@thornhill.no> Date: Sun, 05 Feb 2023 08:54:51 +0100 Message-ID: <87o7q87dis.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61142 Cc: 61142@debbugs.gnu.org, eliz@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 (-) (Actually adding Eli to Cc...) > @Eli: Is this ok for emacs-29? I'd love to add some test for this, but > now they are on the master branch. What is the common procedure to move > stuff from master branch to the release branch? I _can_ just add some > test to the master branch, but it would be nice to have them on emacs-29 > too :-) > Theo From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 05 04:20:30 2023 Received: (at 61142) by debbugs.gnu.org; 5 Feb 2023 09:20:30 +0000 Received: from localhost ([127.0.0.1]:44066 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pObCI-0002Vr-G5 for submit@debbugs.gnu.org; Sun, 05 Feb 2023 04:20:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35182) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pObCG-0002Vc-Eq for 61142@debbugs.gnu.org; Sun, 05 Feb 2023 04:20:28 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pObCA-0005mj-57; Sun, 05 Feb 2023 04:20:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=G0lrsVel90QXaOfEXuz79RGEe06OW7Vx0pLmbK8VWYI=; b=koaRzzCj79aOpD3ndZRf +IfVWkEBY8LyKCXeJ3yB29QMhbV1XAHRiH38nxUQ10pT50KVgAC9tSnfOI0Bumw1HqHVCwMQny8Q7 NULKVIrtj8GdrMNAXDefJoquMT9UWx1Ssi7HRTK0P3mBUBJIs3w41XumTxLp+dtnJFVDUwxrqkvFv BYV+B2FvUKe5ZfoAK0WqLaZtxsyhEmMGCDevyCr3JeR9bWHz1ErSs4kbFTXVHURHNgwzsvCgdYm2i r5uimp1FwXGrQRO+ua3udOild1NG9pu/gCZSN7cS/06/6ArZVnSUFBm/7OJK+i1+A2qAlNRPNMZs9 Tsryba64Mrl0fg==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pObC5-00061K-Ax; Sun, 05 Feb 2023 04:20:20 -0500 Date: Sun, 05 Feb 2023 11:20:27 +0200 Message-Id: <83lelcsc2s.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <87r0v47dky.fsf@thornhill.no> (bug-gnu-emacs@gnu.org) Subject: Re: bug#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions References: <87wn4x7lpw.fsf_-_@thornhill.no> <87r0v47dky.fsf@thornhill.no> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61142 Cc: 61142@debbugs.gnu.org, zjyzhaojiyang@hotmail.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: -3.3 (---) > Cc: 61142@debbugs.gnu.org > Date: Sun, 05 Feb 2023 08:53:33 +0100 > From: Theodor Thornhill via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > Theodor Thornhill writes: > > > 太阳 writes: > > > >> After reading treesit's manual, I found that we can use `n-p-gp` as the matcher > >> and `grand-parent` as the anchor to match the body of `if` (and `while`, which > >> has a similar issue). > >> > >> I mean a rule looks like the following: > >> > >> ``` > >> ((n-p-gp nil "block" "if_statement") grand-parent java-ts-mode-indent-offset) > >> ``` > >> > >> > > > > > > Thanks! We have a mechanism in place for this, see > > 'c-ts-common-statement-offset' in 'c-ts-common.el'. I didn't get to it > > yet, but I'll try to look at it this evening, unless you want to? See > > c-ts-mode for examples of how to use it, if you're interested! > > > > Theo > > Hi again! > > Can you test this patch for me? > > @Eli: Is this ok for emacs-29? I'd love to add some test for this, but > now they are on the master branch. What is the common procedure to move > stuff from master branch to the release branch? I _can_ just add some > test to the master branch, but it would be nice to have them on emacs-29 > too :-) The procedure is "git cherry-pick", but I don't think I understand what exactly is the problem here and what is the solution suggested to solve it. Also, why does it need to be on emacs-29. Can you help me understand that? Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 05 04:28:38 2023 Received: (at 61142) by debbugs.gnu.org; 5 Feb 2023 09:28:38 +0000 Received: from localhost ([127.0.0.1]:44084 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pObKA-0002jf-7g for submit@debbugs.gnu.org; Sun, 05 Feb 2023 04:28:38 -0500 Received: from out-185.mta1.migadu.com ([95.215.58.185]:24486) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pObK5-0002jU-Nm for 61142@debbugs.gnu.org; Sun, 05 Feb 2023 04:28:37 -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=1675589311; 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=8lJBjN7kzUEsuP9fVUvo+KJZNFoX9hU7/D7PPrRRj8c=; b=M8hfkFEeD+xGcQgzo+9wJPyrYeBIt9PGl/vPd/KSaBBTjzU8KNgkuvaZDbpHgfqfBaA+nk gJ+NKKz+16XyLfkPyyYWTacPKNluAKD6qjgQPEBY5jFN50SKHoXiESsluJGymWjZ10ygdy iwWGZBPzIx11CdmdLR+UTqDN0U0EggCE2raVjB0ogUlaUo7dwlPctmIKR2ZtT8IKWZBBdx /YFpl/phKYM8iaDKiwkTg5a3ENcJcc/l3RfITIdsJeyDfHfvdd+r1mLLFnhNBeCZbLLmSL JXmqyK2wa00y0dXOO3BvC0c3o4bFhvYXK7iT8NjTStdUzMVgDw2z47sWvE9W+w== From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions In-Reply-To: <83lelcsc2s.fsf@gnu.org> References: <87wn4x7lpw.fsf_-_@thornhill.no> <87r0v47dky.fsf@thornhill.no> <83lelcsc2s.fsf@gnu.org> Date: Sun, 05 Feb 2023 10:28:29 +0100 Message-ID: <87lelc796q.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61142 Cc: 61142@debbugs.gnu.org, zjyzhaojiyang@hotmail.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 (-) Eli Zaretskii writes: > > The procedure is "git cherry-pick", but I don't think I understand > what exactly is the problem here and what is the solution suggested to > solve it. Also, why does it need to be on emacs-29. Can you help me > understand that? > No need to have the test files on emacs-29. I could just as well add a test when emacs-29 is synced to master later. The test-files themselves don't exist on emacs-29. Theo From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 05 05:15:48 2023 Received: (at 61142) by debbugs.gnu.org; 5 Feb 2023 10:15:48 +0000 Received: from localhost ([127.0.0.1]:44124 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOc3o-00041n-4q for submit@debbugs.gnu.org; Sun, 05 Feb 2023 05:15:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36980) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOc3l-00041V-GN for 61142@debbugs.gnu.org; Sun, 05 Feb 2023 05:15:47 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOc3e-00072P-As; Sun, 05 Feb 2023 05:15:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=x0v512K9L1fV37sR08T85BqhVZN3nF6F1njX5CL1gEk=; b=mWP9NU/zv8dZ 4xPmZ0OQkjf2/xHg9WT8qP2WAUhGqQSo859yuU2lXUh9/ulNYnMlIPKp7/Do6rB0fhU0Id4fmPKsg TjomOpHMwuYkDoGMH4C6QZVWQnRUa0blICouRHtMsm0hiAqck9uGTNsSLQIkpDeEnf1biHBx4g9XB y4CsOnH1wD7ycSSRN9gTZQ/3b0Ex5NT16l8Mj5QxC6fmGF6Q2c5BMNCEfTjxT2tIFZEDlEFOpDI9w 0BfXZsbpXw1B0LLCJnBaME7+gLnoMw88/GG2tfMV0qQvrDe7O0/6O4CEcaMaTdlZFtBonNWVMVrFJ IOGN3gacQ3oudxCq4lRg/A==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOc3d-00059Q-Dt; Sun, 05 Feb 2023 05:15:38 -0500 Date: Sun, 05 Feb 2023 12:15:47 +0200 Message-Id: <83h6w0s9ik.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <87lelc796q.fsf@thornhill.no> (message from Theodor Thornhill on Sun, 05 Feb 2023 10:28:29 +0100) Subject: Re: bug#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions References: <87wn4x7lpw.fsf_-_@thornhill.no> <87r0v47dky.fsf@thornhill.no> <83lelcsc2s.fsf@gnu.org> <87lelc796q.fsf@thornhill.no> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61142 Cc: 61142@debbugs.gnu.org, zjyzhaojiyang@hotmail.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: -3.3 (---) > From: Theodor Thornhill > Cc: zjyzhaojiyang@hotmail.com, 61142@debbugs.gnu.org > Date: Sun, 05 Feb 2023 10:28:29 +0100 > > Eli Zaretskii writes: > > > > > The procedure is "git cherry-pick", but I don't think I understand > > what exactly is the problem here and what is the solution suggested to > > solve it. Also, why does it need to be on emacs-29. Can you help me > > understand that? > > > > No need to have the test files on emacs-29. I could just as well add a > test when emacs-29 is synced to master later. The test-files themselves > don't exist on emacs-29. OK, but still: what exactly is the problem that your patch is trying to fix? I didn't understand that from the original report. And one comment to the patch: > @@ -300,6 +302,20 @@ java-ts-mode > (c-ts-common-comment-setup) > > ;; Indent. > + (setq-local c-ts-common-indent-block-type-regexp > + (rx (or "class_body" > + "\\`array_initializer" > + "annotation_type_body" > + "interface_body" > + "interface_constructor_body" > + "enum_body" > + "switch_block" > + "record_declaration_body" > + "block"))) > + (setq-local c-ts-common-indent-bracketless-type-regexp > + (rx (or "if_statement" "do_statement" > + "for_statement" "while_statement"))) > + (setq-local c-ts-common-indent-offset 'java-ts-mode-indent-offset) > (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) > > ;; Electric Why are we adding a c-ts-common-SOMETHING variable to java-ts-mode.el? Shouldn't it be named java-ts-SOMETHING instead? Or am I missing something? From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 05 05:26:10 2023 Received: (at 61142) by debbugs.gnu.org; 5 Feb 2023 10:26:10 +0000 Received: from localhost ([127.0.0.1]:44139 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOcDp-0004Jh-QB for submit@debbugs.gnu.org; Sun, 05 Feb 2023 05:26:10 -0500 Received: from out-218.mta0.migadu.com ([91.218.175.218]:31723) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOcDk-0004JU-M5 for 61142@debbugs.gnu.org; Sun, 05 Feb 2023 05:26:08 -0500 Date: Sun, 05 Feb 2023 11:25:52 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1675592762; 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=9IpKRbt6N4qPGKc63mwXvL6kC//L0HslbYVSdlbvCeo=; b=fHgu3KbVniFKal5LXIiG7P5NderCrerszV1TdRlcJWkHuqzCAgSrAO4eXnwkOc0HsP8YYN nGtde24pXKa939XmYaBr1ajO9hN9YgYP9L0o2Ly5gg5hCMUmbBLsUPqslxiO7ruSG8L6G1 bF7swgExyFDzSIfAURKGcmVPoF2Tmqog7mgsqFyVI5yUXwEFDyArz5oPRcRdokO9dXLsXW bSYy6+3PZRitGIIFQzddEdxiL99oBLvcVwsGj0Z2XzEv7lIHoK1X56EzbQdRAqfo/pUVII FSHrmF9uKzS1Woo770db+m9eXdOgpfaLPbg8chb+x53RsRk6Ck8+msuRVnbW1Q== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill To: Eli Zaretskii Subject: =?US-ASCII?Q?Re=3A_bug=2361142=3A_29=2E0=2E60=3B_?= =?US-ASCII?Q?java-ts-mode_-_Wrong_inde?= =?US-ASCII?Q?ntation_for_the_body_of_multiple_lines_conditions?= In-Reply-To: <83h6w0s9ik.fsf@gnu.org> References: <87wn4x7lpw.fsf_-_@thornhill.no> <87r0v47dky.fsf@thornhill.no> <83lelcsc2s.fsf@gnu.org> <87lelc796q.fsf@thornhill.no> <83h6w0s9ik.fsf@gnu.org> Message-ID: 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: 61142 Cc: 61142@debbugs.gnu.org, zjyzhaojiyang@hotmail.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 5 February 2023 11:15:47 CET, Eli Zaretskii wrote: >> From: Theodor Thornhill >> Cc: zjyzhaojiyang@hotmail=2Ecom, 61142@debbugs=2Egnu=2Eorg >> Date: Sun, 05 Feb 2023 10:28:29 +0100 >>=20 >> Eli Zaretskii writes: >>=20 >> > >> > The procedure is "git cherry-pick", but I don't think I understand >> > what exactly is the problem here and what is the solution suggested t= o >> > solve it=2E Also, why does it need to be on emacs-29=2E Can you hel= p me >> > understand that? >> > >>=20 >> No need to have the test files on emacs-29=2E I could just as well add= a >> test when emacs-29 is synced to master later=2E The test-files themsel= ves >> don't exist on emacs-29=2E > >OK, but still: what exactly is the problem that your patch is trying >to fix? I didn't understand that from the original report=2E > Oh right!=20 There are some indentation issues where if you have=20 void foo( String foo) { // =2E=2E=2E } Then the normal code will indent like void foo( String foo) { //=2E=2E=2E } Because of the parent-bol anchor=2E When these paired brackets are nested = (and some other cases) we have to find the grand-parent, but that caused so= me other issues with ie c-ts-mode where compound_statements can be nested _= and_ siblings=2E Yuan made an effort to make this work in c-ts-mode due to = the many bug reports=2E He then generalized it into c-ts-common, for use in= other modes, like java=2E This patch adds support for that in java=2E >And one comment to the patch: > >> @@ -300,6 +302,20 @@ java-ts-mode >> (c-ts-common-comment-setup) >> =20 >> ;; Indent=2E >> + (setq-local c-ts-common-indent-block-type-regexp >> + (rx (or "class_body" >> + "\\`array_initializer" >> + "annotation_type_body" >> + "interface_body" >> + "interface_constructor_body" >> + "enum_body" >> + "switch_block" >> + "record_declaration_body" >> + "block"))) >> + (setq-local c-ts-common-indent-bracketless-type-regexp >> + (rx (or "if_statement" "do_statement" >> + "for_statement" "while_statement"))) >> + (setq-local c-ts-common-indent-offset 'java-ts-mode-indent-offset) >> (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) >> =20 >> ;; Electric > >Why are we adding a c-ts-common-SOMETHING variable to java-ts-mode=2Eel? >Shouldn't it be named java-ts-SOMETHING instead? Or am I missing >something? This is because there is some setup involved in the new bracket-counting c= ode in c-ts-common=2E Theo From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 05 05:59:44 2023 Received: (at 61142) by debbugs.gnu.org; 5 Feb 2023 10:59:44 +0000 Received: from localhost ([127.0.0.1]:44151 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOckK-0005BH-5V for submit@debbugs.gnu.org; Sun, 05 Feb 2023 05:59:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33206) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOckG-0005B2-7L for 61142@debbugs.gnu.org; Sun, 05 Feb 2023 05:59:42 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOckA-0005IZ-BX; Sun, 05 Feb 2023 05:59:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=yTREXRK+SdHynRUwSr3Z5uM+uUICesnJxY4y9I1S32Q=; b=aUoXEA/G1sC2 Y7LIO9y8m8ll6jf1D6iX3sRcdFT88UlE/m/wBS0oxsqc+1aCtRAm51d6/1d7U4fwLXTwzp8dGe66M QyTWhYZJj3CL++yyPj9BsblowiLQYUEzHWKfgS2z/oPgS5cZfAfw5pa0HPgBmmh7OaAodNM+pkGoz MzdGS1cM/6SwxVfOpL2c272q0+msSb6c4pvmS0B6xF8MGnToVzmFczeRhFjvcMrzz0ycJU3mfT0f2 JPg6noTMLemsilxVwLtNLsBklK8jWQMYo2olyFjB5ILZ+fb+6PX/vwixoeHcywnmPxgpWme2aa9qc NfMAPhk3FxJpeoSqSm8teg==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOck9-0006pt-Ly; Sun, 05 Feb 2023 05:59:33 -0500 Date: Sun, 05 Feb 2023 12:59:43 +0200 Message-Id: <83bkm8s7hc.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: (message from Theodor Thornhill on Sun, 05 Feb 2023 11:25:52 +0100) Subject: Re: bug#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions References: <87wn4x7lpw.fsf_-_@thornhill.no> <87r0v47dky.fsf@thornhill.no> <83lelcsc2s.fsf@gnu.org> <87lelc796q.fsf@thornhill.no> <83h6w0s9ik.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61142 Cc: 61142@debbugs.gnu.org, zjyzhaojiyang@hotmail.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: -3.3 (---) > Date: Sun, 05 Feb 2023 11:25:52 +0100 > From: Theodor Thornhill > CC: zjyzhaojiyang@hotmail.com, 61142@debbugs.gnu.org > > There are some indentation issues where if you have > > void foo( > String foo) { > // ... > } > > Then the normal code will indent like > > void foo( > String foo) { > //... > } > > Because of the parent-bol anchor. When these paired brackets are nested (and some other cases) we have to find the grand-parent, but that caused some other issues with ie c-ts-mode where compound_statements can be nested _and_ siblings. Yuan made an effort to make this work in c-ts-mode due to the many bug reports. He then generalized it into c-ts-common, for use in other modes, like java. > > This patch adds support for that in java. > > > >And one comment to the patch: > > > >> @@ -300,6 +302,20 @@ java-ts-mode > >> (c-ts-common-comment-setup) > >> > >> ;; Indent. > >> + (setq-local c-ts-common-indent-block-type-regexp > >> + (rx (or "class_body" > >> + "\\`array_initializer" > >> + "annotation_type_body" > >> + "interface_body" > >> + "interface_constructor_body" > >> + "enum_body" > >> + "switch_block" > >> + "record_declaration_body" > >> + "block"))) > >> + (setq-local c-ts-common-indent-bracketless-type-regexp > >> + (rx (or "if_statement" "do_statement" > >> + "for_statement" "while_statement"))) > >> + (setq-local c-ts-common-indent-offset 'java-ts-mode-indent-offset) > >> (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) > >> > >> ;; Electric > > > >Why are we adding a c-ts-common-SOMETHING variable to java-ts-mode.el? > >Shouldn't it be named java-ts-SOMETHING instead? Or am I missing > >something? > > This is because there is some setup involved in the new bracket-counting code in c-ts-common. OK, please install on emacs-29, and thanks. From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 05 14:19:26 2023 Received: (at 61142) by debbugs.gnu.org; 5 Feb 2023 19:19:26 +0000 Received: from localhost ([127.0.0.1]:46492 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOkXt-0005eM-Tg for submit@debbugs.gnu.org; Sun, 05 Feb 2023 14:19:26 -0500 Received: from out-189.mta1.migadu.com ([95.215.58.189]:24096) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOkXq-0005eB-Qk for 61142@debbugs.gnu.org; Sun, 05 Feb 2023 14:19:24 -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=1675624761; 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=uuJHA59zz4cVvqRmdVoBpG1NZvZVcrber3tih+XE4Hg=; b=zddKCw00Erzlogg0beVLQbIbg9gTLLHiQJWrfsm6SGytBTkEWI02PRJ9tPVNm53hZFJeb2 BHLrFqHr/h1vFEDJ8VG8dypfI/PGfrOg4FP+uLdY6SnYwJm4Ir40ICSv/gTTzbtYFDhnID BX8ZocMR6RYvEWE/apLAazy5+ZuI7l7U6x2pRoaMEtiWUjsb6G62u6dE+Rn6QNs7UsoSIc edUWGuoXVeZ6DVrzHzGCdQzljjDNQUICf/oXIPyqYoZV9MJQDiFduOoF+Qr61XS6ZNZoOR b+RUagExErek/hhmk6PJLU+iA8cTija8YnRvNyJQZt1o54bO7692OKRe80fTfw== From: Theodor Thornhill To: =?utf-8?B?6LW1IOe6qumYsw==?= Subject: Re: =?utf-8?B?5Zue5aSNOg==?= bug#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions In-Reply-To: References: <87wn4x7lpw.fsf_-_@thornhill.no> <87r0v47dky.fsf@thornhill.no> Date: Sun, 05 Feb 2023 20:19:19 +0100 Message-ID: <87h6vz7weg.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61142 Cc: "61142@debbugs.gnu.org" <61142@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 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =E8=B5=B5 =E7=BA=AA=E9=98=B3 writes: > Thanks for the patch. > Thanks for testing! > I've not tested this patch adequately, but I found an issue: > java-ts-mode indents the body of `else if` with one more level of indenta= tion. > > ``` > public class T { > int f() { > int a =3D 0; > int b =3D 1; > if (a =3D=3D 0 > && b =3D=3D 1) { > // indentation ok > return 0; > } else if (a =3D=3D 1 ) { > // indentation more > return 1; > } > } > } > ``` > If the second branch of the if-statement is just an `else` (not `else if`= ), the body of it will be indented correctly. > > > I've also tested c-ts-mode (use 'linux as c-ts-mode-indent-style) and it = also has this kind of problem. > ``` > int main() { > int a =3D 0; > if (a =3D=3D 0) { > // indentation ok > } else if (a =3D=3D 2) { > // indentation more > } > } > ``` > Right, I remember this. This finally made me create a fix - can you test the provided patch and check if this works for you? It works nicely for me, at least. Theo --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Use-c-ts-common-statement-offset-in-java-ts-mode.patch >From 95c381d40cf6907e333acb107160d901740da79d Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Sun, 5 Feb 2023 08:49:08 +0100 Subject: [PATCH] Use c-ts-common-statement-offset in java-ts-mode * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Add new matchers to enable c-ts-common machinery. (java-ts-mode): Add regexps. * lisp/progmodes/c-ts-common.el (c-ts-common-statement-offset): Fix typo in documentation and use the new if statement helpers. (c-ts-common-if-statement-regexp): New defvar. (c-ts-common-nestable-if-statement-p): New defvar. (c-ts-common--fix-nestable-if-statement): New helper. --- lisp/progmodes/c-ts-common.el | 26 +++++++++++++++++++++++- lisp/progmodes/java-ts-mode.el | 36 +++++++++++++++++++++++++--------- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/lisp/progmodes/c-ts-common.el b/lisp/progmodes/c-ts-common.el index 8729cae4ba..2edb979be5 100644 --- a/lisp/progmodes/c-ts-common.el +++ b/lisp/progmodes/c-ts-common.el @@ -281,11 +281,32 @@ c-ts-common-indent-bracketless-type-regexp This can be nil, meaning such special handling is not needed.") +(defvar c-ts-common-if-statement-regexp "if_statement" + "Regexp used to select an if statement in a C like language. + +This can be set to a different regexp if needed.") + +(defvar c-ts-common-nestable-if-statement-p t + "Does the current parser nest if-else statements? + +T if the current tree-sitter grammar nests the else if +statements, NIL otherwise.") + +(defun c-ts-common--fix-nestable-if-statement (level node) + (or (and node + (treesit-node-parent node) + c-ts-common-nestable-if-statement-p + (equal (treesit-node-type node) c-ts-common-if-statement-regexp) + (equal (treesit-node-type (treesit-node-parent node)) + c-ts-common-if-statement-regexp) + (cl-decf level)) + level)) + (defun c-ts-common-statement-offset (node parent bol &rest _) "This anchor is used for children of a statement inside a block. This function basically counts the number of block nodes (i.e., -brackets) (defined by `c-ts-mode--indent-block-type-regexp') +brackets) (defined by `c-ts-common-indent-block-type-regexp') between NODE and the root node (not counting NODE itself), and multiply that by `c-ts-common-indent-offset'. @@ -312,6 +333,9 @@ c-ts-common-statement-offset (while (if (eq node t) (setq node parent) node) + ;; Subtract one indent level if the language nests + ;; if-statements and node is if_statement. + (setq level (c-ts-common--fix-nestable-if-statement level node)) (when (string-match-p c-ts-common-indent-block-type-regexp (treesit-node-type node)) (cl-incf level) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index b9f7894095..b3ecbd5987 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -70,22 +70,24 @@ java-ts-mode--syntax-table (defvar java-ts-mode--indent-rules `((java ((parent-is "program") point-min 0) - ((node-is "}") (and parent parent-bol) 0) + ((match "}" "element_value_array_initializer") + parent-bol 0) + ((node-is "}") point-min c-ts-common-statement-offset) ((node-is ")") parent-bol 0) ((node-is "]") parent-bol 0) ((and (parent-is "comment") c-ts-common-looking-at-star) c-ts-common-comment-start-after-first-star -1) ((parent-is "comment") prev-adaptive-prefix 0) ((parent-is "text_block") no-indent) - ((parent-is "class_body") parent-bol java-ts-mode-indent-offset) + ((parent-is "class_body") point-min c-ts-common-statement-offset) ((parent-is "array_initializer") parent-bol java-ts-mode-indent-offset) - ((parent-is "annotation_type_body") parent-bol java-ts-mode-indent-offset) - ((parent-is "interface_body") parent-bol java-ts-mode-indent-offset) - ((parent-is "constructor_body") parent-bol java-ts-mode-indent-offset) + ((parent-is "annotation_type_body") point-min c-ts-common-statement-offset) + ((parent-is "interface_body") point-min c-ts-common-statement-offset) + ((parent-is "constructor_body") point-min c-ts-common-statement-offset) ((parent-is "enum_body_declarations") parent-bol 0) - ((parent-is "enum_body") parent-bol java-ts-mode-indent-offset) - ((parent-is "switch_block") parent-bol java-ts-mode-indent-offset) - ((parent-is "record_declaration_body") parent-bol java-ts-mode-indent-offset) + ((parent-is "enum_body") point-min c-ts-common-statement-offset) + ((parent-is "switch_block") point-min c-ts-common-statement-offset) + ((parent-is "record_declaration_body") point-min c-ts-common-statement-offset) ((query "(method_declaration (block _ @indent))") parent-bol java-ts-mode-indent-offset) ((query "(method_declaration (block (_) @indent))") parent-bol java-ts-mode-indent-offset) ((parent-is "local_variable_declaration") parent-bol java-ts-mode-indent-offset) @@ -118,7 +120,7 @@ java-ts-mode--indent-rules ((parent-is "case_statement") parent-bol java-ts-mode-indent-offset) ((parent-is "labeled_statement") parent-bol java-ts-mode-indent-offset) ((parent-is "do_statement") parent-bol java-ts-mode-indent-offset) - ((parent-is "block") (and parent parent-bol) java-ts-mode-indent-offset))) + ((parent-is "block") point-min c-ts-common-statement-offset))) "Tree-sitter indent rules.") (defvar java-ts-mode--keywords @@ -300,6 +302,22 @@ java-ts-mode (c-ts-common-comment-setup) ;; Indent. + (setq-local c-ts-common-indent-block-type-regexp + (regexp-opt '("class_body" + "array_initializer" + "annotation_type_body" + "interface_body" + "interface_constructor_body" + "enum_body" + "switch_block" + "record_declaration_body" + "block"))) + (setq-local c-ts-common-indent-bracketless-type-regexp + (regexp-opt '("if_statement" + "do_statement" + "for_statement" + "while_statement"))) + (setq-local c-ts-common-indent-offset 'java-ts-mode-indent-offset) (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) ;; Electric -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 05 14:30:41 2023 Received: (at 61142) by debbugs.gnu.org; 5 Feb 2023 19:30:41 +0000 Received: from localhost ([127.0.0.1]:46498 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOkin-0005x7-Fg for submit@debbugs.gnu.org; Sun, 05 Feb 2023 14:30:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55720) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOkim-0005wu-Gj for 61142@debbugs.gnu.org; Sun, 05 Feb 2023 14:30:40 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOkia-0000QF-N1; Sun, 05 Feb 2023 14:30:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=PQkhFD2rcrR7yTccfTk00YmsH6ipdO2JZWYCv+XurM4=; b=ExwFv+EdBYFuFPxz9A2e NIK8Scmwf3Ga0mISnPmnq/RMaopu7HoSkh4dPaxvamCFwOeixHLcGsG4eMqBp7YOYbZdB8umgJu8a PqZPEUk5I6WHUQdzJZVRsDrN3prUjhXQxGT558GSD+SyaCjoXZyO3vTpReveChCCDTLkRo2HLDkqI mVnLP2z9Mkc5H0YdaZhz3D0Po2FM8maGv/7L0JuPcYCMmrOkM3RxhqBYjjlZV3mZ+LrV+oW9LaiCO 5Fvzq8B2av11umdVNC/JRE3qLeuq6QM4l9CW3S79GQKz5pVKSCC2mm/j1rGZE8ZgZn68lvGKNrnzO ASMMHLkhSNtXBA==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOkiS-0004JS-PH; Sun, 05 Feb 2023 14:30:25 -0500 Date: Sun, 05 Feb 2023 21:30:29 +0200 Message-Id: <83ilgfrju2.fsf@gnu.org> From: Eli Zaretskii To: Theodor Thornhill In-Reply-To: <87h6vz7weg.fsf@thornhill.no> (bug-gnu-emacs@gnu.org) Subject: Re: bug#61142: =?utf-8?B?5Zue5aSNOg==?= bug#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions References: <87wn4x7lpw.fsf_-_@thornhill.no> <87r0v47dky.fsf@thornhill.no> <87h6vz7weg.fsf@thornhill.no> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61142 Cc: 61142@debbugs.gnu.org, zjyzhaojiyang@hotmail.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: -3.3 (---) > Cc: "61142@debbugs.gnu.org" <61142@debbugs.gnu.org> > Date: Sun, 05 Feb 2023 20:19:19 +0100 > From: Theodor Thornhill via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > +(defvar c-ts-common-nestable-if-statement-p t > + "Does the current parser nest if-else statements? > + > +T if the current tree-sitter grammar nests the else if > +statements, NIL otherwise.") A nit: we use t and nil, lowercase, to refer to these two symbols. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 05 14:32:59 2023 Received: (at 61142) by debbugs.gnu.org; 5 Feb 2023 19:32:59 +0000 Received: from localhost ([127.0.0.1]:46508 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOkl1-00060w-J0 for submit@debbugs.gnu.org; Sun, 05 Feb 2023 14:32:59 -0500 Received: from out-208.mta0.migadu.com ([91.218.175.208]:34133) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOkky-00060n-Ot for 61142@debbugs.gnu.org; Sun, 05 Feb 2023 14:32:57 -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=1675625573; 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=9shqs9VtIqhIfWZU7CMMUStik6UsAcRigXb0HKFc9KE=; b=F17eDU9lAvxEXahe/IKabg9kF8BklmbN0/+/zA60RUAr3bxtYqQCijnQLoo/CcglfWuDBw FN72n069yvtDVoGuiF3MnXPKArv1tbNH7ekyQ1WhBl4zIVpKzZQ3a7uqtl16xcN10Hcgcj x7qUOYyoQTqbBQV0VTyoj/kccByzAhu2o37JXjRtq1nee3VT0+SdxTCzTZiuQniET2fJCV Jt03sJ5QMyeCuJC1dgnw6JOXWErkMrJvUKRnOyXNZlp7HPWUVf17vwViZvf2YlbiS7Z/st ZkYEY7X8p8asoWb74Ci6LpbkT0EIgdYXhcomFkwMA7N4XsfIztA/nXUzdZnQzg== From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#61142: =?utf-8?B?5Zue5aSNOg==?= bug#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions In-Reply-To: <83ilgfrju2.fsf@gnu.org> References: <87wn4x7lpw.fsf_-_@thornhill.no> <87r0v47dky.fsf@thornhill.no> <87h6vz7weg.fsf@thornhill.no> <83ilgfrju2.fsf@gnu.org> Date: Sun, 05 Feb 2023 20:32:51 +0100 Message-ID: <87edr37vrw.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61142 Cc: 61142@debbugs.gnu.org, zjyzhaojiyang@hotmail.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 (-) Eli Zaretskii writes: >> Cc: "61142@debbugs.gnu.org" <61142@debbugs.gnu.org> >> Date: Sun, 05 Feb 2023 20:19:19 +0100 >> From: Theodor Thornhill via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> +(defvar c-ts-common-nestable-if-statement-p t >> + "Does the current parser nest if-else statements? >> + >> +T if the current tree-sitter grammar nests the else if >> +statements, NIL otherwise.") > > A nit: we use t and nil, lowercase, to refer to these two symbols. > > Thanks. Thanks! Theo From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 05 15:12:28 2023 Received: (at 61142) by debbugs.gnu.org; 5 Feb 2023 20:12:28 +0000 Received: from localhost ([127.0.0.1]:46527 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOlND-0006zF-HM for submit@debbugs.gnu.org; Sun, 05 Feb 2023 15:12:28 -0500 Received: from out-184.mta1.migadu.com ([95.215.58.184]:18758) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOlNB-0006z5-Co for 61142@debbugs.gnu.org; Sun, 05 Feb 2023 15:12:26 -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=1675627944; 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=Gz8TArh8ko02IgYMxXgtnkffFyYT/3wBpG/9wXbEJ7c=; b=CnR9jkwZoAPQGkzYVAq5p1BUjSznUAWOqxHlqrn9muYwCekvGBr8czvJ2lC6sJxue3BwtU wOwpO8VBRamXMaG+WPBKEmsxAX0J6SIxrIXFt49qZYx1vbtN4bB6R+FzmYGXWMYXPUQ1Ue NLCHE0cmXagwfYKFfjmYgTOJXz2fhKz+Smg29ngQ3+mPLp4xEcCUNAa3U7TCvo523q5s0N WUwImuJnV1dD7ZR3XH9DUc2CkPfWqTskkGaVdmEYxxjlXQJ//r8Gy8901Qw6kFxyZ01PbM oSK38KEPNWkYrtYdNp8Da8r2ozDbXAyqPhzDTh95TGRXBfmONO2FvU9plmaDHw== From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#61142: =?utf-8?B?5Zue5aSNOg==?= bug#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions In-Reply-To: <87edr37vrw.fsf@thornhill.no> References: <87wn4x7lpw.fsf_-_@thornhill.no> <87r0v47dky.fsf@thornhill.no> <87h6vz7weg.fsf@thornhill.no> <83ilgfrju2.fsf@gnu.org> <87edr37vrw.fsf@thornhill.no> Date: Sun, 05 Feb 2023 21:12:23 +0100 Message-ID: <87bkm77ty0.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61142 Cc: 61142@debbugs.gnu.org, zjyzhaojiyang@hotmail.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 (-) --=-=-= Content-Type: text/plain Theodor Thornhill writes: > Eli Zaretskii writes: > >>> Cc: "61142@debbugs.gnu.org" <61142@debbugs.gnu.org> >>> Date: Sun, 05 Feb 2023 20:19:19 +0100 >>> From: Theodor Thornhill via "Bug reports for GNU Emacs, >>> the Swiss army knife of text editors" >>> >>> +(defvar c-ts-common-nestable-if-statement-p t >>> + "Does the current parser nest if-else statements? >>> + >>> +T if the current tree-sitter grammar nests the else if >>> +statements, NIL otherwise.") >> >> A nit: we use t and nil, lowercase, to refer to these two symbols. >> >> Thanks. > > Thanks! > > Theo I added some small tweaks, and will add the following as a test later: ``` public class Java { public Java( String foo) { this.foo = foo; } void foo( String foo) { for (var f : rs) return new String[]{ "foo", "bar" }; if (a == 0 && b == 1 && foo) { return 0; } else if (a == 1) { return 1; } else if (true) return 5; else { if (a == 0 && b == 1 && foo) while (true) for ( ;;) if (true) return 5; else if (false) { return 6; } else if (true && false) return 6; } } } ``` Even though its some pretty wild code, its indented correctly after this patch. I'll create something similar for C as well. Theo --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Use-c-ts-common-statement-offset-in-java-ts-mode-bug.patch >From e2e931843936134f157ee6259167b6aae429da3a Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Sun, 5 Feb 2023 08:49:08 +0100 Subject: [PATCH] Use c-ts-common-statement-offset in java-ts-mode (bug#61142) * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Add new matchers to enable c-ts-common machinery. (java-ts-mode): Add regexps. * lisp/progmodes/c-ts-common.el (c-ts-common-statement-offset): Fix typo in documentation and use the new if statement helpers. (c-ts-common-if-statement-regexp): New defvar. (c-ts-common-nestable-if-statement-p): New defvar. (c-ts-common--fix-nestable-if-statement): New helper. --- lisp/progmodes/c-ts-common.el | 33 ++++++++++++++++++++++++++++++- lisp/progmodes/java-ts-mode.el | 36 +++++++++++++++++++++++++--------- 2 files changed, 59 insertions(+), 10 deletions(-) diff --git a/lisp/progmodes/c-ts-common.el b/lisp/progmodes/c-ts-common.el index 8729cae4ba..affb38139a 100644 --- a/lisp/progmodes/c-ts-common.el +++ b/lisp/progmodes/c-ts-common.el @@ -281,11 +281,22 @@ c-ts-common-indent-bracketless-type-regexp This can be nil, meaning such special handling is not needed.") +(defvar c-ts-common-if-statement-regexp "if_statement" + "Regexp used to select an if statement in a C like language. + +This can be set to a different regexp if needed.") + +(defvar c-ts-common-nestable-if-statement-p t + "Does the current parser nest if-else statements? + +t if the current tree-sitter grammar nests the else if +statements, nil otherwise.") + (defun c-ts-common-statement-offset (node parent bol &rest _) "This anchor is used for children of a statement inside a block. This function basically counts the number of block nodes (i.e., -brackets) (defined by `c-ts-mode--indent-block-type-regexp') +brackets) (defined by `c-ts-common-indent-block-type-regexp') between NODE and the root node (not counting NODE itself), and multiply that by `c-ts-common-indent-offset'. @@ -312,6 +323,9 @@ c-ts-common-statement-offset (while (if (eq node t) (setq node parent) node) + ;; Subtract one indent level if the language nests + ;; if-statements and node is if_statement. + (setq level (c-ts-common--fix-nestable-if-statement level node)) (when (string-match-p c-ts-common-indent-block-type-regexp (treesit-node-type node)) (cl-incf level) @@ -354,6 +368,23 @@ c-ts-mode--fix-bracketless-indent (1+ level) level))) +(defun c-ts-common--fix-nestable-if-statement (level node) + "Takes LEVEL and NODE and return adjusted LEVEL. +Look at the type of NODE, when it is an if-statement node, as +defined by `c-ts-common-if-statement-regexp' and its parent is +also an if-statement node, subtract one level. Otherwise return +the value unchanged. Whether or not if-statements are nestable +is controlled by `c-ts-common-nestable-if-statement-p'." + ;; This fixes indentation for cases shown in bug#61142. + (or (and node + (treesit-node-parent node) + c-ts-common-nestable-if-statement-p + (equal (treesit-node-type node) c-ts-common-if-statement-regexp) + (equal (treesit-node-type (treesit-node-parent node)) + c-ts-common-if-statement-regexp) + (cl-decf level)) + level)) + (provide 'c-ts-common) ;;; c-ts-common.el ends here diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index b9f7894095..1d7bdb0722 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -70,22 +70,25 @@ java-ts-mode--syntax-table (defvar java-ts-mode--indent-rules `((java ((parent-is "program") point-min 0) - ((node-is "}") (and parent parent-bol) 0) + ((match "}" "element_value_array_initializer") + parent-bol 0) + ((node-is "}") point-min c-ts-common-statement-offset) ((node-is ")") parent-bol 0) + ((node-is "else") parent-bol 0) ((node-is "]") parent-bol 0) ((and (parent-is "comment") c-ts-common-looking-at-star) c-ts-common-comment-start-after-first-star -1) ((parent-is "comment") prev-adaptive-prefix 0) ((parent-is "text_block") no-indent) - ((parent-is "class_body") parent-bol java-ts-mode-indent-offset) + ((parent-is "class_body") point-min c-ts-common-statement-offset) ((parent-is "array_initializer") parent-bol java-ts-mode-indent-offset) - ((parent-is "annotation_type_body") parent-bol java-ts-mode-indent-offset) - ((parent-is "interface_body") parent-bol java-ts-mode-indent-offset) - ((parent-is "constructor_body") parent-bol java-ts-mode-indent-offset) + ((parent-is "annotation_type_body") point-min c-ts-common-statement-offset) + ((parent-is "interface_body") point-min c-ts-common-statement-offset) + ((parent-is "constructor_body") point-min c-ts-common-statement-offset) ((parent-is "enum_body_declarations") parent-bol 0) - ((parent-is "enum_body") parent-bol java-ts-mode-indent-offset) - ((parent-is "switch_block") parent-bol java-ts-mode-indent-offset) - ((parent-is "record_declaration_body") parent-bol java-ts-mode-indent-offset) + ((parent-is "enum_body") point-min c-ts-common-statement-offset) + ((parent-is "switch_block") point-min c-ts-common-statement-offset) + ((parent-is "record_declaration_body") point-min c-ts-common-statement-offset) ((query "(method_declaration (block _ @indent))") parent-bol java-ts-mode-indent-offset) ((query "(method_declaration (block (_) @indent))") parent-bol java-ts-mode-indent-offset) ((parent-is "local_variable_declaration") parent-bol java-ts-mode-indent-offset) @@ -118,7 +121,7 @@ java-ts-mode--indent-rules ((parent-is "case_statement") parent-bol java-ts-mode-indent-offset) ((parent-is "labeled_statement") parent-bol java-ts-mode-indent-offset) ((parent-is "do_statement") parent-bol java-ts-mode-indent-offset) - ((parent-is "block") (and parent parent-bol) java-ts-mode-indent-offset))) + ((parent-is "block") point-min c-ts-common-statement-offset))) "Tree-sitter indent rules.") (defvar java-ts-mode--keywords @@ -300,6 +303,21 @@ java-ts-mode (c-ts-common-comment-setup) ;; Indent. + (setq-local c-ts-common-indent-block-type-regexp + (regexp-opt '("class_body" + "array_initializer" + "constructor_body" + "annotation_type_body" + "interface_body" + "enum_body" + "switch_block" + "record_declaration_body" + "block"))) + (setq-local c-ts-common-indent-bracketless-type-regexp + (regexp-opt '("if_statement" + "for_statement" + "while_statement"))) + (setq-local c-ts-common-indent-offset 'java-ts-mode-indent-offset) (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) ;; Electric -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 05 16:20:27 2023 Received: (at 61142) by debbugs.gnu.org; 5 Feb 2023 21:20:27 +0000 Received: from localhost ([127.0.0.1]:46596 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOmR0-0000HX-OP for submit@debbugs.gnu.org; Sun, 05 Feb 2023 16:20:27 -0500 Received: from out-84.mta1.migadu.com ([95.215.58.84]:31319) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOmQy-0000HN-27 for 61142@debbugs.gnu.org; Sun, 05 Feb 2023 16:20:25 -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=1675632022; 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=lTTwbGew+/oahWfuVWigc1yCFfZ73giBrkNto2WFYVw=; b=SXOJIdkTWwNeyIW17+xVsFkUZCVLZbIaRT13uem+pyfcNG2EXtMA9/U2n0APBv1p1sEYpC /SG7HxBDoGK+CYnJhEbkQAWP/XrfHtJW+raqUHvy6hMKKGARxZOS4s6ar1d5S3IMj/5R+j /l2v7F40vUNTiwsmrNDwbVChD+Ww7DDslh2hsLbdmkswg3zOWesvX5fBh/sqADNR6DgFqn HnGGiy9yvhSFfxrKSx1pmYlTzCGHi914713o1pGO90rH2nx2mRCRmy0DAJqTVn0xudSWHX HLX5qHR+kgW03zcg90agyOH2gAPxHSC+VblluXVViLM0/EgelaZg4j3XjoGLMw== From: Theodor Thornhill To: Eli Zaretskii Subject: Re: bug#61142: =?utf-8?B?5Zue5aSNOg==?= bug#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions In-Reply-To: <87bkm77ty0.fsf@thornhill.no> References: <87wn4x7lpw.fsf_-_@thornhill.no> <87r0v47dky.fsf@thornhill.no> <87h6vz7weg.fsf@thornhill.no> <83ilgfrju2.fsf@gnu.org> <87edr37vrw.fsf@thornhill.no> <87bkm77ty0.fsf@thornhill.no> Date: Sun, 05 Feb 2023 22:20:19 +0100 Message-ID: <878rhb7qss.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61142 Cc: 61142@debbugs.gnu.org, zjyzhaojiyang@hotmail.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 (-) --=-=-= Content-Type: text/plain Theodor Thornhill writes: > Theodor Thornhill writes: > >> Eli Zaretskii writes: >> >>>> Cc: "61142@debbugs.gnu.org" <61142@debbugs.gnu.org> >>>> Date: Sun, 05 Feb 2023 20:19:19 +0100 >>>> From: Theodor Thornhill via "Bug reports for GNU Emacs, >>>> the Swiss army knife of text editors" >>>> >>>> +(defvar c-ts-common-nestable-if-statement-p t >>>> + "Does the current parser nest if-else statements? >>>> + >>>> +T if the current tree-sitter grammar nests the else if >>>> +statements, NIL otherwise.") >>> >>> A nit: we use t and nil, lowercase, to refer to these two symbols. >>> >>> Thanks. >> >> Thanks! >> >> Theo > > I added some small tweaks, and will add the following as a test later: > I made even further tweaks, and while testing the c variant I noticed that the C tests weren't actually working. There were missing rules for many of the cases in the tests, so I added some more rules to the c-ts-mode indentation and added a big-ish test with some wonky but seemingly working indentation. Because the tests are now working I think this is good to go, so unless somebody objects I'll install this sometime tomorrow :-) Theo --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Use-c-ts-common-statement-offset-in-java-ts-mode-bug.patch >From 23d859a6bedab436b87db2458f15a69403bbef99 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Sun, 5 Feb 2023 08:49:08 +0100 Subject: [PATCH] Use c-ts-common-statement-offset in java-ts-mode (bug#61142) * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Add new matchers to enable c-ts-common machinery. (java-ts-mode): Add regexps. * lisp/progmodes/c-ts-common.el (c-ts-common-statement-offset): Fix typo in documentation and use the new if statement helpers. (c-ts-common-if-statement-regexp): New defvar. (c-ts-common-nestable-if-statement-p): New defvar. (c-ts-common--fix-nestable-if-statement): New helper. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: Add test for complicated bracket matching indentation. * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Add indent rules for bracketless statements. --- lisp/progmodes/c-ts-common.el | 34 +++++++++++++- lisp/progmodes/c-ts-mode.el | 7 +++ lisp/progmodes/java-ts-mode.el | 36 +++++++++++---- .../progmodes/c-ts-mode-resources/indent.erts | 45 +++++++++++++++++++ 4 files changed, 112 insertions(+), 10 deletions(-) diff --git a/lisp/progmodes/c-ts-common.el b/lisp/progmodes/c-ts-common.el index 8729cae4ba..6767f10a9e 100644 --- a/lisp/progmodes/c-ts-common.el +++ b/lisp/progmodes/c-ts-common.el @@ -281,11 +281,22 @@ c-ts-common-indent-bracketless-type-regexp This can be nil, meaning such special handling is not needed.") +(defvar c-ts-common-if-statement-regexp "if_statement" + "Regexp used to select an if statement in a C like language. + +This can be set to a different regexp if needed.") + +(defvar c-ts-common-nestable-if-statement-p t + "Does the current parser nest if-else statements? + +t if the current tree-sitter grammar nests the else if +statements, nil otherwise.") + (defun c-ts-common-statement-offset (node parent bol &rest _) "This anchor is used for children of a statement inside a block. This function basically counts the number of block nodes (i.e., -brackets) (defined by `c-ts-mode--indent-block-type-regexp') +brackets) (defined by `c-ts-common-indent-block-type-regexp') between NODE and the root node (not counting NODE itself), and multiply that by `c-ts-common-indent-offset'. @@ -312,6 +323,9 @@ c-ts-common-statement-offset (while (if (eq node t) (setq node parent) node) + ;; Subtract one indent level if the language nests + ;; if-statements and node is if_statement. + (setq level (c-ts-common--fix-nestable-if-statement level node)) (when (string-match-p c-ts-common-indent-block-type-regexp (treesit-node-type node)) (cl-incf level) @@ -354,6 +368,24 @@ c-ts-mode--fix-bracketless-indent (1+ level) level))) +(defun c-ts-common--fix-nestable-if-statement (level node) + "Takes LEVEL and NODE and return adjusted LEVEL. +Look at the type of NODE, when it is an if-statement node, as +defined by `c-ts-common-if-statement-regexp' and its parent is +also an if-statement node, subtract one level. Otherwise return +the value unchanged. Whether or not if-statements are nestable +is controlled by `c-ts-common-nestable-if-statement-p'." + ;; This fixes indentation for cases shown in bug#61142. + (or (and node + (equal (treesit-node-type (treesit-node-prev-sibling node)) "else") + (treesit-node-parent node) + c-ts-common-nestable-if-statement-p + (equal (treesit-node-type node) c-ts-common-if-statement-regexp) + (equal (treesit-node-type (treesit-node-parent node)) + c-ts-common-if-statement-regexp) + (cl-decf level)) + level)) + (provide 'c-ts-common) ;;; c-ts-common.el ends here diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 5093c3980b..e3d8c9ddad 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -238,6 +238,13 @@ c-ts-mode--indent-styles ((parent-is "labeled_statement") point-min c-ts-common-statement-offset) + ;; Bracketless statement matchers. + ((match nil "while_statement" "condition") parent-bol c-ts-mode-indent-offset) + ((match nil "if_statement" "consequence") parent-bol c-ts-mode-indent-offset) + ((match nil "if_statement" "alternative") parent-bol c-ts-mode-indent-offset) + ((match nil "do_statement" "body") parent-bol c-ts-mode-indent-offset) + ((match nil "for_statement" "body") parent-bol c-ts-mode-indent-offset) + ((match "preproc_ifdef" "compound_statement") point-min 0) ((match "#endif" "preproc_ifdef") point-min 0) ((match "preproc_if" "compound_statement") point-min 0) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index b9f7894095..1d7bdb0722 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -70,22 +70,25 @@ java-ts-mode--syntax-table (defvar java-ts-mode--indent-rules `((java ((parent-is "program") point-min 0) - ((node-is "}") (and parent parent-bol) 0) + ((match "}" "element_value_array_initializer") + parent-bol 0) + ((node-is "}") point-min c-ts-common-statement-offset) ((node-is ")") parent-bol 0) + ((node-is "else") parent-bol 0) ((node-is "]") parent-bol 0) ((and (parent-is "comment") c-ts-common-looking-at-star) c-ts-common-comment-start-after-first-star -1) ((parent-is "comment") prev-adaptive-prefix 0) ((parent-is "text_block") no-indent) - ((parent-is "class_body") parent-bol java-ts-mode-indent-offset) + ((parent-is "class_body") point-min c-ts-common-statement-offset) ((parent-is "array_initializer") parent-bol java-ts-mode-indent-offset) - ((parent-is "annotation_type_body") parent-bol java-ts-mode-indent-offset) - ((parent-is "interface_body") parent-bol java-ts-mode-indent-offset) - ((parent-is "constructor_body") parent-bol java-ts-mode-indent-offset) + ((parent-is "annotation_type_body") point-min c-ts-common-statement-offset) + ((parent-is "interface_body") point-min c-ts-common-statement-offset) + ((parent-is "constructor_body") point-min c-ts-common-statement-offset) ((parent-is "enum_body_declarations") parent-bol 0) - ((parent-is "enum_body") parent-bol java-ts-mode-indent-offset) - ((parent-is "switch_block") parent-bol java-ts-mode-indent-offset) - ((parent-is "record_declaration_body") parent-bol java-ts-mode-indent-offset) + ((parent-is "enum_body") point-min c-ts-common-statement-offset) + ((parent-is "switch_block") point-min c-ts-common-statement-offset) + ((parent-is "record_declaration_body") point-min c-ts-common-statement-offset) ((query "(method_declaration (block _ @indent))") parent-bol java-ts-mode-indent-offset) ((query "(method_declaration (block (_) @indent))") parent-bol java-ts-mode-indent-offset) ((parent-is "local_variable_declaration") parent-bol java-ts-mode-indent-offset) @@ -118,7 +121,7 @@ java-ts-mode--indent-rules ((parent-is "case_statement") parent-bol java-ts-mode-indent-offset) ((parent-is "labeled_statement") parent-bol java-ts-mode-indent-offset) ((parent-is "do_statement") parent-bol java-ts-mode-indent-offset) - ((parent-is "block") (and parent parent-bol) java-ts-mode-indent-offset))) + ((parent-is "block") point-min c-ts-common-statement-offset))) "Tree-sitter indent rules.") (defvar java-ts-mode--keywords @@ -300,6 +303,21 @@ java-ts-mode (c-ts-common-comment-setup) ;; Indent. + (setq-local c-ts-common-indent-block-type-regexp + (regexp-opt '("class_body" + "array_initializer" + "constructor_body" + "annotation_type_body" + "interface_body" + "enum_body" + "switch_block" + "record_declaration_body" + "block"))) + (setq-local c-ts-common-indent-bracketless-type-regexp + (regexp-opt '("if_statement" + "for_statement" + "while_statement"))) + (setq-local c-ts-common-indent-offset 'java-ts-mode-indent-offset) (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) ;; Electric diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent.erts b/test/lisp/progmodes/c-ts-mode-resources/indent.erts index 7dcc3b0fb3..6f64e1e795 100644 --- a/test/lisp/progmodes/c-ts-mode-resources/indent.erts +++ b/test/lisp/progmodes/c-ts-mode-resources/indent.erts @@ -244,3 +244,48 @@ int main() { } } =-=-= + +Name: Complicated mixed bracket matching indentation (bug#61142) + +=-= +void foo( + int foo) { + for (;;) + return 5; + + if (a == 0 + && b == 1 + && foo) + { + return 0; + } + else if (a == 1) + { + return 1; + } + else if (true) + return 5; + else + { + if (a == 0 + && b == 1 + && foo) + for ( + int i = 0; + i < 5; + i++) + if (true) + do + i = 5; + while (true); + else if (false) + { + return 6; + } + else + if (true + && false) + return 6; + } +} +=-=-= -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 06 00:51:41 2023 Received: (at 61142) by debbugs.gnu.org; 6 Feb 2023 05:51:41 +0000 Received: from localhost ([127.0.0.1]:47191 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOuPk-0003eB-Qt for submit@debbugs.gnu.org; Mon, 06 Feb 2023 00:51:41 -0500 Received: from mail-psaapc01olkn2047.outbound.protection.outlook.com ([40.92.52.47]:6625 helo=APC01-PSA-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOem1-00059r-QA for 61142@debbugs.gnu.org; Sun, 05 Feb 2023 08:09:38 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WFQPE2TAAH45qafj5OEyrQu7F3Q1c7WDN7r/rWaGbHf5eOJyicQXASiWCnHHhrPRXdocNP4KffzffA50Y8qURaby0MbcKvek/f3+g3661o/hpphd/ntoy70ZhHW/gm/H0r0MYTliovl403wMg3BU0F+zvD+0PPYQAB5hs3bl94gUuJJxyIpjWfDHw4UUu0iHfaKOIxpPHCM/s6VPinr3kwkhqBvM5EXMEEwsfJsjcNg7iwIPnrc7DRVuL0swswkk1Lxu73PtWNNNTO1BTTuWznLTnrA+INllKsKHFZ7SZjugQzmmmDDuv11N+M74TKFnA0k9r098fHpgHF2WKovyeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pHma/0g1IoeTNYRgNdLcxomq8UqgvdsDceEPej361Ic=; b=AmlY4Xee/HX0tFeXNIqvP++sH5tM9n4s4iz9moTp/wbbtrniPK+g3mAi0E2F0lSpyZiTrgMPO3pPkzJLMa7kFnL1/9eFxDdY45f85SMXa13Y4RHBNcoNoxgae/bQ5Fm1EIkUaECYbHN/LM2cmZrJCKNVUo7QIkzl8ECYwDdiBgJauZNQYHRmbeaUppXQnafr/lMW0IuVqfIEXvJVCNpo7cJDSGiRcMiQrFDJQJvO2Xm8uBTGAfnWtkPkSqjqJCmuO9khQ5MFqLL0CA7dDCFgU82uInKCpDGSqBz4hXhTv530rjqfSTllVOt9+vCDxwdEOwrcPBCtyw1nz38Zj6wTJg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pHma/0g1IoeTNYRgNdLcxomq8UqgvdsDceEPej361Ic=; b=Qd02gCs2vOhXM2WCB7VqWUu+WpuiVVTjpxPUwh+2mUHoD/Do2F7/I+yf8y/qdtQxXIC9zIwgcllAwqkRH9w+aH0vF22camk9k4Wvoi0cfw9czq6r9s3Ew4ED5rJJbp6uAyx/UhrAmOEl7AY5A8xAqNOP6uyoQFRqs85p/oCkaiBdj5bgoAMNqLLmj1d+4h+Y58dySxVIdnzdlX2g3S3yOq17MnLZ5aHbPXB1Zg8P/vrk1LnCUdj1ozuYX6s1a4hjUsOS+hQh/QXYo9o5FZzhtZ6xllGXFtM9bBfWbo6XBGjAktNSYtCeX1qH1SREBu0VWmJdIMbunhNuNvJpMVu94Q== Received: from OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:13e::13) by TYWP286MB3349.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:2da::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Sun, 5 Feb 2023 13:09:19 +0000 Received: from OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM ([fe80::c3e:9933:93cd:8cfa]) by OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM ([fe80::c3e:9933:93cd:8cfa%5]) with mapi id 15.20.6064.034; Sun, 5 Feb 2023 13:09:19 +0000 From: =?gb2312?B?1dQgvM3R9A==?= To: Theodor Thornhill Subject: =?gb2312?B?u9i4tDogYnVnIzYxMTQyOiAyOS4wLjYwOyBqYXZhLXRzLW1vZGUgLSBXcm9u?= =?gb2312?B?ZyBpbmRlbnRhdGlvbiBmb3IgdGhlIGJvZHkgb2YgbXVsdGlwbGUgbGluZXMg?= =?gb2312?Q?conditions?= Thread-Topic: bug#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions Thread-Index: AQHZOIXR1teovax0pkiAxqIpffDvG66//N8TgABX6BU= Date: Sun, 5 Feb 2023 13:09:19 +0000 Message-ID: References: <87wn4x7lpw.fsf_-_@thornhill.no> <87r0v47dky.fsf@thornhill.no> In-Reply-To: <87r0v47dky.fsf@thornhill.no> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [vUJLFp/2vtvdNX38+SrjqqwKq5dVQ3UH] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: OSZP286MB1417:EE_|TYWP286MB3349:EE_ x-ms-office365-filtering-correlation-id: 29cfc424-7b5a-4938-9836-08db077a3112 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: uqqVlLm03we96i70QOR/oPNtzTjuUGyqPhAFP/fwrgl8Swoi6IN1GLEyAa3AYYnN/1FSq8kHvl5AxecVUVDncHq+hx0XKwGzsBTq1Nms0pksGeItVUavP6voleqrPUVZCQciW+1YlfEobijclbrep4f1IMfORXB8d9JtLWJpu91hpGG1UMk3cRDa5WzyOaTiK8ipPLd0Cd+FkCWpAJ1Aq7dd5VJykD4xJfbYHal8FaMVrex+TkKLvghdSJomRuXYkLhfdeiw3jigkC5GWGltyPKqoJ1yJzNAipBn//oWCAQsaywpni8lHfcDlKCWKvyuSGv4j+rTWa7R8ydMoHsEc08UqOIRC/1QXmS3OWy9dpHf/PxDkHB/58Yg2O8eG43rKO1aF28lUdhR4xvjjTvAu6qoKsaowwHM7pM+ZiJiaLeXRUws+JewdSvKVbW0LMGnt6c7sV5c+QtibcW9xEXiUOuF3HVG9ANHFjeBjS1Ql5Q9CfwXGJoNTJn9aQ1SBfhbBvHqt93KvvBe2Aa0Jo0kNs9Tk+o45AEFfbf5fox941gzhE9fxpmAgV2v149MVCLAK3+MP1cwNLWnQER59ecYscTDZpKiqvGm/Z0xEhMlbOw= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?gb2312?B?RE1RUHNocGVFemhlY0Z1K21LQSt2bzBrVUZUek9iUXFpUEhrTGdNT2pVSkhE?= =?gb2312?B?Ky9ma3RLNGZHeTE0WU41alo2QlZSWi9HRDlkOE9WdGJoN25uaDJzSnR4MGt5?= =?gb2312?B?bDczK1RFT2x0RXpLT3VUenZ0Y3VYUUY0Q3hvdUVPSU9LUXlzLz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mFuNE9XMDdUS2Z5Y1JFbVJpUldWKzRp?= =?gb2312?B?WENLQU9IOWROY0svSVBjNURrMlNodlZHSVRSRlNMT2gzTGRoR0tzR2tyTHIx?= =?gb2312?B?UW9ZNlZFYVdwOHQ5NERnS1BibVBMbE84TnZieVJPa3pSOUptZk52RVl5Mng3?= =?gb2312?B?VjhxR092L3BkdHozblFFcGpTdEJhQ21mRHAzUER0NFVBOU5WSVl2ZE5obkpk?= =?gb2312?B?OE5RdGZUanRwT1NaSmFIYmZYakFDUmlrZ2VWTlJPbU1Hdlg2ODRGMGc4ZzVp?= =?gb2312?B?cDYwNWU2WkhYV0dzTWRRQi9pU1FtVTVZZzk3MVlBU24xWjFRQ3liR2tFdi9Y?= =?gb2312?B?T1JKNllUdG5mVXlZQ1VUQkdpUkhldW02ajdqL0sxL1h4NHJmU2lMWCt4K1pp?= =?gb2312?B?N2FOeW9zK2svbUxVTTBPK0NoWk11M1VwV3o2d3EwTVJ5QVJlWGcvTFNTRE5E?= =?gb2312?B?QmYydHZoaGFSTHFsK0ZiQlQ3MUZhaUZwS0dNaXBUOFVKd3hRMVBlNzJoeG9x?= =?gb2312?B?Q0dJN3lkeFVMYkNxY3lMc0J4amp1N1FzWXhrTElhZ0R0T2JrQjRJRXVKbVVH?= =?gb2312?B?SGxJNjZFdFBzN1Qxc1Y2Vlo0Y3dSZFNGL2xiUjc2RW13QURQQ2pCQzlyTjJa?= =?gb2312?B?U1lMc1o5OW1IVkpHenNoYWZiSi9wa2QvSkJabUk4QVdZNitDY2htMHRnPT0=?= Content-Type: multipart/alternative; boundary="_000_OSZP286MB141720BF3D08F8E5195C4FAFA8D59OSZP286MB1417JPNP_" MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-05f45.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 29cfc424-7b5a-4938-9836-08db077a3112 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Feb 2023 13:09:19.3452 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWP286MB3349 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 61142 X-Mailman-Approved-At: Mon, 06 Feb 2023 00:51:39 -0500 Cc: "61142@debbugs.gnu.org" <61142@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 (-) --_000_OSZP286MB141720BF3D08F8E5195C4FAFA8D59OSZP286MB1417JPNP_ Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: base64 VGhhbmtzIGZvciB0aGUgcGF0Y2guDQoNCkkndmUgbm90IHRlc3RlZCB0aGlzIHBhdGNoIGFkZXF1 YXRlbHksIGJ1dCBJIGZvdW5kIGFuIGlzc3VlOg0KamF2YS10cy1tb2RlIGluZGVudHMgdGhlIGJv ZHkgb2YgYGVsc2UgaWZgIHdpdGggb25lIG1vcmUgbGV2ZWwgb2YgaW5kZW50YXRpb24uDQoNCmBg YA0KcHVibGljIGNsYXNzIFQgew0KICAgIGludCBmKCkgew0KICAgICAgICBpbnQgYSA9IDA7DQog ICAgICAgIGludCBiID0gMTsNCiAgICAgICAgaWYgKGEgPT0gMA0KICAgICAgICAgICAgJiYgYiA9 PSAxKSB7DQogICAgICAgICAgICAvLyBpbmRlbnRhdGlvbiBvaw0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Rlc3Qg dGhpcyBwYXRjaCBmb3IgbWU/DQoNCkBFbGk6IElzIHRoaXMgb2sgZm9yIGVtYWNzLTI5PyAgSSdk IGxvdmUgdG8gYWRkIHNvbWUgdGVzdCBmb3IgdGhpcywgYnV0DQpub3cgdGhleSBhcmUgb24gdGhl IG1hc3RlciBicmFuY2guICBXaGF0IGlzIHRoZSBjb21tb24gcHJvY2VkdXJlIHRvIG1vdmUNCnN0 dWZmIGZyb20gbWFzdGVyIGJyYW5jaCB0byB0aGUgcmVsZWFzZSBicmFuY2g/ICBJIF9jYW5fIGp1 c3QgYWRkIHNvbWUNCnRlc3QgdG8gdGhlIG1hc3RlciBicmFuY2gsIGJ1dCBpdCB3b3VsZCBiZSBu aWNlIHRvIGhhdmUgdGhlbSBvbiBlbWFjcy0yOQ0KdG9vIDotKQ0KDQpUaGVvDQoNCg== --_000_OSZP286MB141720BF3D08F8E5195C4FAFA8D59OSZP286MB1417JPNP_ Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable
Thanks = for the patch.

I've not tested this patch adequately, but I found an issue: 
java-ts-mode= indents the body of `e= lse if` with one more level of indentation. 

```
public class T {
    int f(= ) {
     =   int a =3D 0;
     =   int b =3D 1;
     =   if (a =3D=3D 0
     =       && b =3D=3D 1) {
     =       // indentation ok
     =       return 0;
     =   } else if (a =3D=3D 1 ) {
     =           // indentation more
     =           return 1;
     =       }
    }
}
```
If the second branch= of the if-statement is just an `else` (not `else if`), the body of it will= be indented correctly.


I've also tested c-t= s-mode (use 'linux as c-ts-mode-indent-style) and it also has this kin= d of problem. 
```
int main() {
    = int a =3D 0;
    = if (a =3D=3D 0) {
    =     // indentation ok
    = } else if (a =3D=3D 2) {
    =         // indentation more
    =     }
}
```


=B7=A2=BC=FE=C8=CB: Theodor= Thornhill <theo@thornhill.no>
=B7=A2=CB=CD=CA=B1=BC=E4: 2023=C4=EA2=D4=C25=C8=D5 15:53
=CA=D5=BC=FE=C8=CB: =CC=AB=D1=F4 <zjyzhaojiyang@hotmail.com> =B3=AD=CB=CD: 61142@debbugs.gnu.org <61142@debbugs.gnu.org> =D6=F7=CC=E2: Re: bug#61142: 29.0.60; java-ts-mode - Wrong indentati= on for the body of multiple lines conditions
 
Theodor Thornhill <theo@thornhill.no> writes= :

> =CC=AB=D1=F4 <zjyzhaojiyang@hotmail.com> writes:
>
>> After reading treesit's manual, I found that we can use `n-p-gp` a= s the matcher
>> and `grand-parent` as the anchor to match the body of `if` (and `w= hile`, which
>> has a similar issue).
>>
>> I mean a rule looks like the following:
>>
>> ```
>> ((n-p-gp nil "block" "if_statement") grand-par= ent java-ts-mode-indent-offset)
>> ```
>>
>>
>
>
> Thanks!  We have a mechanism in place for this, see
> 'c-ts-common-statement-offset' in 'c-ts-common.el'.  I didn't get= to it
> yet, but I'll try to look at it this evening, unless you want to? = ; See
> c-ts-mode for examples of how to use it, if you're interested!
>
> Theo

Hi again!

Can you test this patch for me?

@Eli: Is this ok for emacs-29?  I'd love to add some test for this, bu= t
now they are on the master branch.  What is the common procedure to mo= ve
stuff from master branch to the release branch?  I _can_ just add some=
test to the master branch, but it would be nice to have them on emacs-29 too :-)

Theo

--_000_OSZP286MB141720BF3D08F8E5195C4FAFA8D59OSZP286MB1417JPNP_-- From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 06 00:51:47 2023 Received: (at 61142) by debbugs.gnu.org; 6 Feb 2023 05:51:47 +0000 Received: from localhost ([127.0.0.1]:47197 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOuPq-0003eW-E5 for submit@debbugs.gnu.org; Mon, 06 Feb 2023 00:51:46 -0500 Received: from mail-sgaapc01olkn2032.outbound.protection.outlook.com ([40.92.53.32]:20041 helo=APC01-SG2-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOrKp-0004Wo-Jf for 61142@debbugs.gnu.org; Sun, 05 Feb 2023 21:34:25 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LBuJIgdlUNvFb/aQIQ/nfTl/7vkSbVMmEiBdonVM7nfRznq/l7yaGWVJQkN4MYACRGxz9oGiP4YqWlU838JnRTXEKMYJRD1daUZ0EpAuuoEp9g8jXN/FioCNA3r/Q2n1PS9bqIDF8fZD2kglP7bxHM8OAnYOEGoUEHvRoo1jpFPI3tJwf580cwb+go1UaSsZtsueT2P1dHwxBmObuwTjkXQJTrYrrV571UeQGMsZSIeNw65sEnad8gWLoOu9ZBClR+jD4gpVeHQwad10RYQa76+f7oGCmIKVAVHDDJUilCMFmuMpqnudPt+eo7n6WN3h95cI8CkiWOn0mL4+uHF7Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lYop6ciy/MR6vVemAs4Dxs5DiPuZHWOdyJqdgyCwl/s=; b=mdRKG6q6wT1RtN0q0HyVxNaH2dB6L5zxzuPMZAjZtkuhDDMHITnMOk4WNTG2pmhs0y9CqhLYLwmTUzf3PmdBAq1v2JQVMLc5cAC+idU5nyAhuWgQr8lyoXyd7XD6s5nPQDNudAO5tmC2AztFjCx+prTqxNiyIvpyMOV9T2iEsYznQaU1IuaxnjhxyHrmISS94CLUC7kaU7TtoXgP7nLkGFDQUd2SSU9LIBPEKGrLTSTnn7ayODPjU9MRcFjjJ2UGO/X7oxAJWbDYSN4vqHlfR5VQ0XG189iJBn2gDdv4d0XzqG+GRP9uHKmwdjfSiug9QYgTVV6kVF1gg7mn530OLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lYop6ciy/MR6vVemAs4Dxs5DiPuZHWOdyJqdgyCwl/s=; b=KPUUIhuNRg5t1YYtnBwgHbn0EJayAH7h2qz+P5tcn7cUeyyc7OnBr74fKec1Sha1mWNv1r4pyirCfuiNKNDD4cflbDvp3r/tDRlrLAPnhq8EfYhYDHCbaX/FbcwosgYtN+pMV7Axe4xXfksxQCU7naUN2aSX1vuEWucySx/20cz+unIZVjoLXvNCU210IefijHx6OqU2SvQjYmgywT/gkuxYEz2jt6EjKjeEXrH/Bnu65sc696ybfSIIXXOiGGiVdYPb9YzNn9aocr0jSLxWcPpfTFRMssC4GDlimVq5/K2mx4bngW8IfrVFXdPkFGRxjeYxT8ZDDZY5IOMRX13XKA== Received: from OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:13e::13) by TYWP286MB3675.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3f3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 02:34:12 +0000 Received: from OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM ([fe80::c3e:9933:93cd:8cfa]) by OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM ([fe80::c3e:9933:93cd:8cfa%5]) with mapi id 15.20.6064.034; Mon, 6 Feb 2023 02:34:12 +0000 From: =?gb2312?B?1dQgvM3R9A==?= To: Theodor Thornhill Subject: =?gb2312?B?u9i4tDogYnVnIzYxMTQyOiC72Li0OiBidWcjNjExNDI6IDI5LjAuNjA7IGph?= =?gb2312?B?dmEtdHMtbW9kZSAtIFdyb25nIGluZGVudGF0aW9uIGZvciB0aGUgYm9keSBv?= =?gb2312?Q?f_multiple_lines_conditions?= Thread-Topic: =?gb2312?B?YnVnIzYxMTQyOiC72Li0OiBidWcjNjExNDI6IDI5LjAuNjA7IGphdmEtdHMt?= =?gb2312?B?bW9kZSAtIFdyb25nIGluZGVudGF0aW9uIGZvciB0aGUgYm9keSBvZiBtdWx0?= =?gb2312?Q?iple_lines_conditions?= Thread-Index: AQHZOIXR1teovax0pkiAxqIpffDvG66//N8TgABX6BWAAGeqgIAAAysCgAAAnYCAAAsMgIAAEvuAgABXncI= Date: Mon, 6 Feb 2023 02:34:12 +0000 Message-ID: References: <87wn4x7lpw.fsf_-_@thornhill.no> <87r0v47dky.fsf@thornhill.no> <87h6vz7weg.fsf@thornhill.no> <83ilgfrju2.fsf@gnu.org> <87edr37vrw.fsf@thornhill.no> <87bkm77ty0.fsf@thornhill.no> <878rhb7qss.fsf@thornhill.no> In-Reply-To: <878rhb7qss.fsf@thornhill.no> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [KBMEVwQQ+BFi1XrvW6Hkm4x+SdxPlw0b] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: OSZP286MB1417:EE_|TYWP286MB3675:EE_ x-ms-office365-filtering-correlation-id: 24c53a2c-6981-4818-3cc2-08db07eaa1de x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: +vae0zmEEDPEilJlEPQcGRVSHNMvQ9bUnb7tjMK+qi6jgVziYey6wWe5z63/C37RzOq5shj8OG2w4LEHq+bh2iH5xW0r4UGGEZorGPX8UCpOW9bWojjd4BV41Xp8JhTXQkCIbbl252qCOx8u61k67a4cOC4sqIGsdro5crRcLZ325txWuxAtJ77ZuQUS0ULWMzr6MJmfqhBZC+FqcnJU9z/CdB3L5mHaj69EpmNXvNwYts6QOkEBUEhOixpyjrhmbAXzyq0sfHJM4ZGOEOLP/yoJEAWCJbfFafTqVVswOl4ByKGa8ZuAlcYWYZMsI2I3LqDnaS2X2HVtIS3KN+kNnJCpF6xHHH1AWQloHL2wOgG5LoDgtg4IG/nuiHzYkk7Ef18Ia0qSM8oQGE75gxpyJeK5AttyioMn+LNZ2QF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HE2?= =?gb2312?B?TUdWQ2xxM2hsY2o0Z2EwOEdBT3N3NDBKMUNWc1lpazQ4WEk5MkxneXlpeXpE?= =?gb2312?B?SHJyQWt1K0lNSXlVUDBJaUxnWmJOWmhFS1BnY0xuNVU5YzkrUEVVNDc0bkZJ?= =?gb2312?B?TnRNUVNxZEFPK3VZcFNLdTBuV09NT09DYzR1Z2FnU0JFR3NXa3ZhQmFBPT0=?= Content-Type: multipart/alternative; boundary="_000_OSZP286MB141766B19BE7950C65D99BBFA8DA9OSZP286MB1417JPNP_" MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-05f45.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: OSZP286MB1417.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 24c53a2c-6981-4818-3cc2-08db07eaa1de X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Feb 2023 02:34:12.2338 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWP286MB3675 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 61142 X-Mailman-Approved-At: Mon, 06 Feb 2023 00:51:39 -0500 Cc: "61142@debbugs.gnu.org" <61142@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 (-) --_000_OSZP286MB141766B19BE7950C65D99BBFA8DA9OSZ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zZWVtaW5nbHkg d29ya2luZyBpbmRlbnRhdGlvbi4NCg0KQmVjYXVzZSB0aGUgdGVzdHMgYXJlIG5vdyB3b3JraW5n IEkgdGhpbmsgdGhpcyBpcyBnb29kIHRvIGdvLCBzbyB1bmxlc3MNCnNvbWVib2R5IG9iamVjdHMg SSdsbCBpbnN0YWxsIHRoaXMgc29tZXRpbWUgdG9tb3Jyb3cgOi0pDQoNClRoZW8NCg0K --_000_OSZP286MB141766B19BE7950C65D99BBFA8DA9OSZP286MB1417JPNP_ Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable
Hi Theo=

This patch works well for me. Great! Thanks!&= nbsp; 


=B7=A2=BC=FE=C8=CB: Theodor= Thornhill <theo@thornhill.no>
=B7=A2=CB=CD=CA=B1=BC=E4: 2023=C4=EA2=D4=C26=C8=D5 5:20
=CA=D5=BC=FE=C8=CB: Eli Zaretskii <eliz@gnu.org>
=B3=AD=CB=CD: zjyzhaojiyang@hotmail.com <zjyzhaojiyang@hotmail.co= m>; 61142@debbugs.gnu.org <61142@debbugs.gnu.org>
=D6=F7=CC=E2: Re: bug#61142: =BB=D8=B8=B4: bug#61142: 29.0.60; java-= ts-mode - Wrong indentation for the body of multiple lines conditions
 
Theodor Thornhill <theo@thornhill.no> writes= :

> Theodor Thornhill <theo@thornhill.no> writes:
>
>> Eli Zaretskii <eliz@gnu.org> writes:
>>
>>>> Cc: "61142@debbugs.gnu.org" <61142@debbugs.gn= u.org>
>>>> Date: Sun, 05 Feb 2023 20:19:19 +0100
>>>> From:  Theodor Thornhill via "Bug reports for GN= U Emacs,
>>>>  the Swiss army knife of text editors" <bug-g= nu-emacs@gnu.org>
>>>>
>>>> +(defvar c-ts-common-nestable-if-statement-p t
>>>> +  "Does the current parser nest if-else stateme= nts?
>>>> +
>>>> +T if the current tree-sitter grammar nests the else if >>>> +statements, NIL otherwise.")
>>>
>>> A nit: we use t and nil, lowercase, to refer to these two symb= ols.
>>>
>>> Thanks.
>>
>> Thanks!
>>
>> Theo
>
> I added some small tweaks, and will add the following as a test later:=
>

I made even further tweaks, and while testing the c variant I noticed
that the C tests weren't actually working. There were missing rules for
many of the cases in the tests, so I added some more rules to the
c-ts-mode indentation and added a big-ish test with some wonky but
seemingly working indentation.

Because the tests are now working I think this is good to go, so unless
somebody objects I'll install this sometime tomorrow :-)

Theo

--_000_OSZP286MB141766B19BE7950C65D99BBFA8DA9OSZP286MB1417JPNP_-- From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 06 01:45:44 2023 Received: (at 61142) by debbugs.gnu.org; 6 Feb 2023 06:45:44 +0000 Received: from localhost ([127.0.0.1]:47274 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOvG4-0005JU-7Z for submit@debbugs.gnu.org; Mon, 06 Feb 2023 01:45:44 -0500 Received: from out-178.mta0.migadu.com ([91.218.175.178]:56474) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOvG2-0005JK-9D for 61142@debbugs.gnu.org; Mon, 06 Feb 2023 01:45:43 -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=1675665940; 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=der+wy/QwJpKOVhG0atmklyWA9Dkdj1UWiyTzdh0aGY=; b=in3Q2/DyUFfsEKY6PyIhH2Bq6e25K94Xuct0lSKLF5NYsabxNylzFodv5mjMfpSgz7iXlY VhJpHHJf2liOO/9zMO4tYGuJZH+BExONv0pZFBya/74/4TfgcUWMijMLf1g9DVcU92ncwz mU0MzxWEP1Atsn/5ra01jOuzutlUbzpZSew18VAP7LS9hK9xmcqThibrH2gh733+noX8gv KrfqRSZZAne80olh2Yz0eDe1NEbKicyyOrBJ0S6vbIueYzdTZgh2Ku/zdizEMg0n080zy1 AmURUIxspK02lap4nhdGcuK1VJsOV8NbuxkkCBKMfiXW+rsoAAj+04ZglvuBsg== From: Theodor Thornhill To: =?utf-8?B?6LW1IOe6qumYsw==?= Subject: Re: =?utf-8?B?5Zue5aSNOg==?= bug#61142: =?utf-8?B?5Zue5aSNOg==?= bug#61142: 29.0.60; java-ts-mode - Wrong indentation for the body of multiple lines conditions In-Reply-To: References: <87wn4x7lpw.fsf_-_@thornhill.no> <87r0v47dky.fsf@thornhill.no> <87h6vz7weg.fsf@thornhill.no> <83ilgfrju2.fsf@gnu.org> <87edr37vrw.fsf@thornhill.no> <87bkm77ty0.fsf@thornhill.no> <878rhb7qss.fsf@thornhill.no> Date: Mon, 06 Feb 2023 07:45:37 +0100 Message-ID: <87v8kf5m26.fsf@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: 61142 Cc: "61142@debbugs.gnu.org" <61142@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 (-) =E8=B5=B5 =E7=BA=AA=E9=98=B3 writes: > Hi Theo > > This patch works well for me. Great! Thanks! > Great news - thanks for the feedback - now pushed :-) Theo From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 06 01:46:10 2023 Received: (at control) by debbugs.gnu.org; 6 Feb 2023 06:46:10 +0000 Received: from localhost ([127.0.0.1]:47283 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOvGU-0005L5-Iw for submit@debbugs.gnu.org; Mon, 06 Feb 2023 01:46:10 -0500 Received: from out-38.mta0.migadu.com ([91.218.175.38]:56985) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOvGQ-0005Kp-SF for control@debbugs.gnu.org; Mon, 06 Feb 2023 01:46:07 -0500 Date: Mon, 06 Feb 2023 07:46:04 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1675665966; h=from:from:reply-to:subject:subject:date:date:to:to:cc; bh=+qGZzW2UoEX0Ks5AImQQDIIpNvkaakGEak5aRq/ZVhA=; b=FxOi13Ay3jToJMj+DcFWxio+WwwBh0v7pp9k6m/HyKLVs5CmvHOeSvz1Kd++1LI+yrpd65 y0oXVt+hDbJxGq2eD61BxLiX0JgLeF9GfTh1gUX0OqDTzgOfkbnax6fWHuqWNbSjNQttIg BtFnTHzuc9hEGW8fMGpCG0fQJ1AWAYeFtWXhrcBfVItL67GH4vZFURkMGdUiKguCGiguBi K1P8/gtPGnJx4ol3d8hHebnRLBbuHmrTHWu/TmaOAUV4SuB8dImMmjwGp2HgC3eH12Dtcj URdfBrXpmvjwTQgGO9FJQSmJfkXi/C/JzGMOs6v06B3ztmnfZGh87vz49DeD7w== To: control@debbugs.gnu.org X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill Subject: control message for bug #61142 X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: control 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" Message-Id: X-Spam-Score: -1.0 (-) close 61142 29.1 quit From unknown Wed Jun 25 10:48:40 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 06 Mar 2023 12:24:05 +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