From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 18 07:07:31 2022 Received: (at submit) by debbugs.gnu.org; 18 Dec 2022 12:07:32 +0000 Received: from localhost ([127.0.0.1]:33596 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p6sS3-0008Kj-Fz for submit@debbugs.gnu.org; Sun, 18 Dec 2022 07:07:31 -0500 Received: from lists.gnu.org ([209.51.188.17]:36316) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p6sS1-0008Kd-Rq for submit@debbugs.gnu.org; Sun, 18 Dec 2022 07:07:30 -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 1p6sS1-0006nz-80 for bug-gnu-emacs@gnu.org; Sun, 18 Dec 2022 07:07:29 -0500 Received: from relay7-d.mail.gandi.net ([2001:4b98:dc4:8::227]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p6sRz-00049T-BO for bug-gnu-emacs@gnu.org; Sun, 18 Dec 2022 07:07:29 -0500 Received: (Authenticated sender: sadiq@sadiqpk.org) by mail.gandi.net (Postfix) with ESMTPA id 5F58B20002 for ; Sun, 18 Dec 2022 12:07:21 +0000 (UTC) MIME-Version: 1.0 Date: Sun, 18 Dec 2022 17:37:21 +0530 From: Mohammed Sadiq To: bug-gnu-emacs@gnu.org Subject: 29.0.60; Fallback file variable mode if treesitter is not usable Message-ID: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> X-Sender: sadiq@sadiqpk.org Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2001:4b98:dc4:8::227; envelope-from=sadiq@sadiqpk.org; helo=relay7-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) It would be nice if the fallback mode is used when treesitter is not usable. Say for example, for the following file variable in a C file: /* -*- mode: c; mode: c-ts; -*- */ If c-ts-mode is not usable (regardless of whether the mode is available), activate c-mode instead. This bug is regarding the automatically loaded mode when a file with some mode is set, and not regarding the user explicitly setting the mode. Supporting this can help me use multiple mode file variables regardless of the GNU Emacs version used by co-developers. In GNU Emacs 29.0.60 (build 7, x86_64-pc-linux-gnu, GTK+ Version 3.24.35, cairo version 1.16.0) of 2022-12-18 built on purism Repository revision: 5b2e6d04ce271cca2de944f8f5c07c005da33e37 Repository branch: emacs-29 Windowing system distributor 'The X.Org Foundation', version 11.0.12101004 System Description: Debian GNU/Linux bookworm/sid Configured using: 'configure --prefix=/usr' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB Important settings: value of $LANG: en_IN.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: C Minor modes in effect: tooltip-mode: t global-eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util text-property-search time-date subr-x mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils warnings icons c-ts-mode treesit cl-seq cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit xinput2 x multi-tty make-network-process emacs) Memory information: ((conses 16 59479 7190) (symbols 48 7146 0) (strings 32 20640 2145) (string-bytes 1 740726) (vectors 16 12858) (vector-slots 8 184206 12553) (floats 8 29 94) (intervals 56 239 0) (buffers 984 13)) From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 19 02:44:26 2022 Received: (at 60176) by debbugs.gnu.org; 19 Dec 2022 07:44:26 +0000 Received: from localhost ([127.0.0.1]:38047 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7Aoz-0001YQ-TN for submit@debbugs.gnu.org; Mon, 19 Dec 2022 02:44:26 -0500 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:47429) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7Aox-0001YI-BN for 60176@debbugs.gnu.org; Mon, 19 Dec 2022 02:44:24 -0500 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 1FA8AE000A; Mon, 19 Dec 2022 07:44:14 +0000 (UTC) From: Juri Linkov To: Mohammed Sadiq Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable In-Reply-To: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> (Mohammed Sadiq's message of "Sun, 18 Dec 2022 17:37:21 +0530") Organization: LINKOV.NET References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> Date: Mon, 19 Dec 2022 09:39:14 +0200 Message-ID: <86359bhmfx.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 60176 Cc: Stefan Monnier , 60176@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.7 (-) > It would be nice if the fallback mode is used when treesitter is not > usable. Say for example, for the following file variable in a C file: > > /* -*- mode: c; mode: c-ts; -*- */ > > If c-ts-mode is not usable (regardless of whether the mode is > available), activate c-mode instead. > > This bug is regarding the automatically loaded mode when a file with some > mode is set, and not regarding the user explicitly setting the mode. > > Supporting this can help me use multiple mode file variables regardless > of the GNU Emacs version used by co-developers. 'major-mode-remap-alist' should be able to handle this requirement since its design is similar to MIME.TYPES and MAILCAP. But actually MAILCAP supports an additional predicate TEST that is a command executed to determine whether or not the mailcap line applies. So to completely cover all needs, 'major-mode-remap-alist' should support a predicate as well. For example, (setq major-mode-remap-alist '((c-mode #'treesit-available-p c-ts-mode))) or a more complex predicate: (setq major-mode-remap-alist '((c-mode (lambda () (and (treesit-available-p) (treesit-ready-p 'c t))) c-ts-mode))) From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 19 07:35:25 2022 Received: (at 60176) by debbugs.gnu.org; 19 Dec 2022 12:35:26 +0000 Received: from localhost ([127.0.0.1]:38386 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7FMb-0001k6-GF for submit@debbugs.gnu.org; Mon, 19 Dec 2022 07:35:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43274) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7FMZ-0001k0-MP for 60176@debbugs.gnu.org; Mon, 19 Dec 2022 07:35:24 -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 1p7FMT-0000ro-JN; Mon, 19 Dec 2022 07:35:17 -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=mI4p9L3FQs/h+9VzKRVFU3cw35yK/fg4TBssGNiVBmA=; b=khzVErawYmZm ZiG3Y4DCGMvx21KVLm1+fqSF7A/jA9obVrEIjvfb7CNjqxHnFqKRv9mjv76UaYk/wJRu6WaKkmqBP 1xI6Uq7hQpmQcsNPTvKPdab+RNXTqjT+BJA/1mJcBl41RoutGYb/ec56eCqwo/7G6yBju+6cRYq/a GqWCGu7yXeGOjMALXfdYjp14giXkDnXcWoCuFRd9yM0Wd5HeBwwUeMZ6OSX99S4okJSSCHH/raGPO HhGRyT7lTgmpnYT/BQYwZl/raw1yIvifliGEzKd0twuFaYGg+tvgjUe137TYjGLvt7ieFyNHqXeue dlJxGpfU2y4Frk76CPafwA==; 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 1p7FMS-0002md-G4; Mon, 19 Dec 2022 07:35:17 -0500 Date: Mon, 19 Dec 2022 14:35:27 +0200 Message-Id: <83o7rzeflc.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <86359bhmfx.fsf@mail.linkov.net> (message from Juri Linkov on Mon, 19 Dec 2022 09:39:14 +0200) Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60176 Cc: sadiq@sadiqpk.org, monnier@iro.umontreal.ca, 60176@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: -3.3 (---) > Cc: Stefan Monnier , 60176@debbugs.gnu.org > From: Juri Linkov > Date: Mon, 19 Dec 2022 09:39:14 +0200 > > > It would be nice if the fallback mode is used when treesitter is not > > usable. Say for example, for the following file variable in a C file: > > > > /* -*- mode: c; mode: c-ts; -*- */ > > > > If c-ts-mode is not usable (regardless of whether the mode is > > available), activate c-mode instead. > > > > This bug is regarding the automatically loaded mode when a file with some > > mode is set, and not regarding the user explicitly setting the mode. > > > > Supporting this can help me use multiple mode file variables regardless > > of the GNU Emacs version used by co-developers. > > 'major-mode-remap-alist' should be able to handle this requirement > since its design is similar to MIME.TYPES and MAILCAP. But actually > MAILCAP supports an additional predicate TEST that is a command > executed to determine whether or not the mailcap line applies. > > So to completely cover all needs, 'major-mode-remap-alist' should > support a predicate as well. For example, > > (setq major-mode-remap-alist '((c-mode #'treesit-available-p c-ts-mode))) > > or a more complex predicate: > > (setq major-mode-remap-alist '((c-mode (lambda () > (and (treesit-available-p) > (treesit-ready-p 'c t))) > c-ts-mode))) I think the idea is that this should happen by default, not as a (not-so-trivial) customization by the users. From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 19 08:12:14 2022 Received: (at 60176) by debbugs.gnu.org; 19 Dec 2022 13:12:14 +0000 Received: from localhost ([127.0.0.1]:38457 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7FwE-00028q-0F for submit@debbugs.gnu.org; Mon, 19 Dec 2022 08:12:14 -0500 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:57361) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7FwA-00028j-2I for 60176@debbugs.gnu.org; Mon, 19 Dec 2022 08:12:12 -0500 Received: (Authenticated sender: sadiq@sadiqpk.org) by mail.gandi.net (Postfix) with ESMTPA id 391A540007; Mon, 19 Dec 2022 13:12:02 +0000 (UTC) MIME-Version: 1.0 Date: Mon, 19 Dec 2022 18:42:02 +0530 From: Mohammed Sadiq To: Eli Zaretskii Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable In-Reply-To: <83o7rzeflc.fsf@gnu.org> References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> Message-ID: X-Sender: sadiq@sadiqpk.org Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 60176 Cc: 60176@debbugs.gnu.org, monnier@iro.umontreal.ca, Juri Linkov 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.7 (-) On 2022-12-19 18:05, Eli Zaretskii wrote: >> Cc: Stefan Monnier , 60176@debbugs.gnu.org >> From: Juri Linkov >> Date: Mon, 19 Dec 2022 09:39:14 +0200 >> >> > It would be nice if the fallback mode is used when treesitter is not >> > usable. Say for example, for the following file variable in a C file: >> > >> > /* -*- mode: c; mode: c-ts; -*- */ >> > >> > If c-ts-mode is not usable (regardless of whether the mode is >> > available), activate c-mode instead. >> > >> > This bug is regarding the automatically loaded mode when a file with some >> > mode is set, and not regarding the user explicitly setting the mode. >> > >> > Supporting this can help me use multiple mode file variables regardless >> > of the GNU Emacs version used by co-developers. >> >> 'major-mode-remap-alist' should be able to handle this requirement >> since its design is similar to MIME.TYPES and MAILCAP. But actually >> MAILCAP supports an additional predicate TEST that is a command >> executed to determine whether or not the mailcap line applies. >> >> So to completely cover all needs, 'major-mode-remap-alist' should >> support a predicate as well. For example, >> >> (setq major-mode-remap-alist '((c-mode #'treesit-available-p >> c-ts-mode))) >> >> or a more complex predicate: >> >> (setq major-mode-remap-alist '((c-mode (lambda () >> (and (treesit-available-p) >> (treesit-ready-p 'c t))) >> c-ts-mode))) > > I think the idea is that this should happen by default, not as a > (not-so-trivial) customization by the users. Right, that's what I was suggesting. From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 19 11:43:58 2022 Received: (at 60176) by debbugs.gnu.org; 19 Dec 2022 16:43:58 +0000 Received: from localhost ([127.0.0.1]:39133 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7JF8-0004fo-Cl for submit@debbugs.gnu.org; Mon, 19 Dec 2022 11:43:58 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:13890) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7JF7-0004fg-1Z for 60176@debbugs.gnu.org; Mon, 19 Dec 2022 11:43:57 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 536464415BB; Mon, 19 Dec 2022 11:43:51 -0500 (EST) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 0DF1F440767; Mon, 19 Dec 2022 11:43:50 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1671468230; bh=xiuC8/MP8bR3UZdwg87BbxuJip0U8MpTiKXDcwUo6+c=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=h2E+xngU28egyP22tI1PYgnqqI9+B5CpRpGlQnpWJcW3zZMp0ikcmzRUnMJh56bvV FmOWkJl0sqfkmVAG5jWJhpBhPbDYKhcKrU+Tsb82rb+fcuJfUxNa33znFtMDgf8JWC IKNbfhAJQ3DasUD+oi76ctSXIcCNi/N0aeSwalU1mbnqh4DBCGM7l9sHKPYG55hSAv ksOupd3PyNDdxtKRRAMF0jo7tCTEwJwpomwXvuKkDAUA0z30X/sSMQgdws/sExx6Fy R+L0jhmd8I1MK6OkC3VK5xr3E/4WfVqLGjexE1dNqLhcE2XSyzA6DGaSO49wPxkCDo ZDqRUnmZsiXwQ== Received: from pastel (unknown [45.72.200.228]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D7F5B123056; Mon, 19 Dec 2022 11:43:49 -0500 (EST) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable In-Reply-To: <83o7rzeflc.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 19 Dec 2022 14:35:27 +0200") Message-ID: References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> Date: Mon, 19 Dec 2022 11:43:46 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.409 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60176 Cc: sadiq@sadiqpk.org, 60176@debbugs.gnu.org, Juri Linkov 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 (---) >> (setq major-mode-remap-alist '((c-mode #'treesit-available-p c-ts-mode))) The current syntax is rather (setq major-mode-remap-alist '((c-mode . treesit-available-p c-ts-mode))) > I think the idea is that this should happen by default, not as a > (not-so-trivial) customization by the users. Agreed. `major-mode-remap-alist` is a custom var and I think we should try and keep its default value as close to nil as possible. Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 19 12:35:14 2022 Received: (at 60176) by debbugs.gnu.org; 19 Dec 2022 17:35:14 +0000 Received: from localhost ([127.0.0.1]:39376 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7K2k-0005H1-39 for submit@debbugs.gnu.org; Mon, 19 Dec 2022 12:35:14 -0500 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:56443) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7K2g-0005Gt-Dt for 60176@debbugs.gnu.org; Mon, 19 Dec 2022 12:35:12 -0500 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 8C7EB4000C; Mon, 19 Dec 2022 17:35:01 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable In-Reply-To: <83o7rzeflc.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 19 Dec 2022 14:35:27 +0200") Organization: LINKOV.NET References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> Date: Mon, 19 Dec 2022 19:29:13 +0200 Message-ID: <86o7rzfivi.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 60176 Cc: sadiq@sadiqpk.org, monnier@iro.umontreal.ca, 60176@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.7 (-) >> So to completely cover all needs, 'major-mode-remap-alist' should >> support a predicate as well. For example, >> >> (setq major-mode-remap-alist '((c-mode #'treesit-available-p c-ts-mode))) > > I think the idea is that this should happen by default, not as a > (not-so-trivial) customization by the users. Then 'c-ts-mode' should fall back to 'c-mode' when treesit is not available? Like this: ``` diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index cf941236f82..5004b9a5e1d 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -616,7 +616,7 @@ c-ts-mode (define-derived-mode c-ts-mode c-ts-base-mode "C" (unless (treesit-ready-p 'c) - (error "Tree-sitter for C isn't available")) + (c-mode)) (treesit-parser-create 'c) ``` From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 19 12:47:00 2022 Received: (at 60176) by debbugs.gnu.org; 19 Dec 2022 17:47:00 +0000 Received: from localhost ([127.0.0.1]:39432 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7KE8-0005Nn-Ew for submit@debbugs.gnu.org; Mon, 19 Dec 2022 12:47:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43046) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7KE6-0005Ng-NW for 60176@debbugs.gnu.org; Mon, 19 Dec 2022 12:46:59 -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 1p7KE0-0008VG-BH; Mon, 19 Dec 2022 12:46:52 -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=DDLW2IeANt/MnIBGFh4FFzqEuM/o7AUJlcR2SjlLA5g=; b=JUUKMsXsyc3/ 0f/U30anJEQWESMyiyzYFhrFIBDmQQp6HjK6/JcfV28OhNn9GCpF81BJb8odKYhipFdqzkvCH3ajU HNlhMsS4Pb4TWtFFSNexGdxjqh2UCwbjcRcJU/XM8pe3M1R8S4DOkAznCuq6//QXBKjydXFsyee0X QfVktV2tFSqUDhJvVIvJ0kDdWtyWa90Yc371f1qFNPQGckTBE9VID6WNsmlANZY7psf8UcPNH82QG eDUfPYCh5I7NdtJabuwrCW0Xbmq0nUjflzCFXO/lgVDB0PUPTo2pPfxhD1m/OYbzGsVj/lJCBpnZ8 61u7SL9OhPiB+gxqwoT1ag==; 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 1p7KDz-0001j9-OS; Mon, 19 Dec 2022 12:46:52 -0500 Date: Mon, 19 Dec 2022 19:47:03 +0200 Message-Id: <83v8m7cmlk.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <86o7rzfivi.fsf@mail.linkov.net> (message from Juri Linkov on Mon, 19 Dec 2022 19:29:13 +0200) Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> <86o7rzfivi.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60176 Cc: sadiq@sadiqpk.org, monnier@iro.umontreal.ca, 60176@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: -3.3 (---) > From: Juri Linkov > Cc: sadiq@sadiqpk.org, monnier@iro.umontreal.ca, 60176@debbugs.gnu.org > Date: Mon, 19 Dec 2022 19:29:13 +0200 > > >> So to completely cover all needs, 'major-mode-remap-alist' should > >> support a predicate as well. For example, > >> > >> (setq major-mode-remap-alist '((c-mode #'treesit-available-p c-ts-mode))) > > > > I think the idea is that this should happen by default, not as a > > (not-so-trivial) customization by the users. > > Then 'c-ts-mode' should fall back to 'c-mode' when treesit is not available? > Like this: > > ``` > diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el > index cf941236f82..5004b9a5e1d 100644 > --- a/lisp/progmodes/c-ts-mode.el > +++ b/lisp/progmodes/c-ts-mode.el > @@ -616,7 +616,7 @@ c-ts-mode > (define-derived-mode c-ts-mode c-ts-base-mode "C" > > (unless (treesit-ready-p 'c) > - (error "Tree-sitter for C isn't available")) > + (c-mode)) Yes. But not literally like that, because, for example, we don't want that to happen when c-ts-mode is invoked interactively by the user -- in that case we do want to signal an error. The automatic fallback should IMO happen only in situations like mode specifications in 'mode' cookies or file-local variables, where it is better to visit in a similar mode than completely fail visiting a file. From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 20 23:35:43 2022 Received: (at 60176) by debbugs.gnu.org; 21 Dec 2022 04:35:43 +0000 Received: from localhost ([127.0.0.1]:49224 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7qpT-00016f-Do for submit@debbugs.gnu.org; Tue, 20 Dec 2022 23:35:43 -0500 Received: from mail-pj1-f50.google.com ([209.85.216.50]:46917) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7qpR-00016X-1f for 60176@debbugs.gnu.org; Tue, 20 Dec 2022 23:35:41 -0500 Received: by mail-pj1-f50.google.com with SMTP id u4-20020a17090a518400b00223f7eba2c4so910078pjh.5 for <60176@debbugs.gnu.org>; Tue, 20 Dec 2022 20:35:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=08tr56+9lu35K67xAt3jx07f+u/xO46YhhzfRKeSBCQ=; b=Cs49nZ5YzfBXgCNYEd8thjl5DSM2IKmAGf5mCtrUmrjsiAcp5qcG1x06oCA5LMfB36 0jmZs3+ksEk/7hgEfrJ88oORCNtMCdIUlsptqMGq64nrd5l53AIFjo5uGV63E61HHVbX 1OTa0gbbzgunaOUltI2PzWeVuL2VSZ2JmqjHaVNhyxKh7Ub9lR6ub8bgy0QyTqJxUiRu PZYKFyG4vpnfLyUzaCDkQqStQeEZyeeRBx6PCsp3X4Si7wi6o/IUYeM4/K8tfbfMJmio /r7QG4PwwU4l/Lf6Y7bqDtY78fk7yDUe6DdA+dhMyMhBPf3H9y1nCbxs7Hyj9DFQTy6G nCtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=08tr56+9lu35K67xAt3jx07f+u/xO46YhhzfRKeSBCQ=; b=4ht7p1dEDqrq1FUgzkt5mp98pB0aKwZ/F6G17asG2+p/uD1HJIervqp0xgbc5lKpKD k0WzV94Wxi7JZYIWX2yFvKpnmyiS7Dfgy/EwRJY/IIl5ITeR62A09jUavnSh/7GPVO/l WQB0E5idzmwE2vK/tyoqONZm4WtMqQKgQy1qSbcssa7RIUXxeS3VTEf/7W5Na5fX3b6W WEz8tLn6SvU5+mAQZQ5Str6Jl0r6mZH9lWlKa9lkpPP3Vj5RQ/g/Xd0MOclRFVGAedUX XF6YELKkeUdoA2vl3oo5zMe+E/xnVPVwJMk2vIyrr2PYViizniXcQXsAZnCPdlvHjZ3K B4VA== X-Gm-Message-State: AFqh2krr7anTir2cE0l6ciAMpJrO5tWIaHTZjYwpstTUVlJgCWZOOAhQ k9VUQB+WZPozr+LXjzSE3ng= X-Google-Smtp-Source: AMrXdXu1rXUgNlwFs7O4G+i9KYPVHXDp4WBqRhALDTHfkEVO+c5qz2rRENi3o6ygIsrE4y4Amt2c0A== X-Received: by 2002:a17:902:b947:b0:185:441e:2d78 with SMTP id h7-20020a170902b94700b00185441e2d78mr640142pls.15.1671597334874; Tue, 20 Dec 2022 20:35:34 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id h13-20020a170902680d00b00186b6a04636sm10214718plk.255.2022.12.20.20.35.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Dec 2022 20:35:34 -0800 (PST) From: Yuan Fu Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable Message-Id: <2A48A6AE-F4C1-4AF6-9E14-8D032BC1D558@gmail.com> Date: Tue, 20 Dec 2022 20:35:32 -0800 To: Eli Zaretskii X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 60176 Cc: sadiq@sadiqpk.org, 60176@debbugs.gnu.org, Stefan Monnier , Juri Linkov 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: >> From: Juri Linkov >> Cc: sadiq@sadiqpk.org, monnier@iro.umontreal.ca, = 60176@debbugs.gnu.org >> Date: Mon, 19 Dec 2022 19:29:13 +0200 >>=20 >> >> So to completely cover all needs, 'major-mode-remap-alist' should >> >> support a predicate as well. For example, >> >> >> >> (setq major-mode-remap-alist '((c-mode #'treesit-available-p = c-ts-mode))) >> > >> > I think the idea is that this should happen by default, not as a >> > (not-so-trivial) customization by the users. >>=20 >> Then 'c-ts-mode' should fall back to 'c-mode' when treesit is not = available? >> Like this: >>=20 >> ``` >> diff --git a/lisp/progmodes/c-ts-mode.el = b/lisp/progmodes/c-ts-mode.el >> index cf941236f82..5004b9a5e1d 100644 >> --- a/lisp/progmodes/c-ts-mode.el >> +++ b/lisp/progmodes/c-ts-mode.el >> @@ -616,7 +616,7 @@ c-ts-mode >> (define-derived-mode c-ts-mode c-ts-base-mode "C" >> =20 >> (unless (treesit-ready-p 'c) >> - (error "Tree-sitter for C isn't available")) >> + (c-mode)) > > Yes. But not literally like that, because, for example, we don't want > that to happen when c-ts-mode is invoked interactively by the user -- > in that case we do want to signal an error. > > The automatic fallback should IMO happen only in situations like mode > specifications in 'mode' cookies or file-local variables, where it is > better to visit in a similar mode than completely fail visiting a > file. Also (mentioned by Stefan in another thread), we probably don=E2=80=99t = want c-mode-hook to run if we decide to fall back to c-ts-mode. I don=E2=80=99t have a good way to cleanly implement such fallback = without changing auto mode, local variable, define-derived-mode, etc. I used Stefan=E2=80=99s advice hack on bash-ts-mode, only because bash-ts-mode = only supports bash and it has to fallback to sh-mode for other shell scripts, otherwise it would be a pain to use. Yuan From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 07 18:20:09 2023 Received: (at control) by debbugs.gnu.org; 7 Jan 2023 23:20:09 +0000 Received: from localhost ([127.0.0.1]:59281 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEITx-0001Zo-BY for submit@debbugs.gnu.org; Sat, 07 Jan 2023 18:20:09 -0500 Received: from mail-pg1-f177.google.com ([209.85.215.177]:46915) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEITv-0001ZT-Ll for control@debbugs.gnu.org; Sat, 07 Jan 2023 18:20:07 -0500 Received: by mail-pg1-f177.google.com with SMTP id d10so3524248pgm.13 for ; Sat, 07 Jan 2023 15:20:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:from:to:cc:subject:date:message-id:reply-to; bh=On0T/7g/anpVqlwJ2MY/+NEfT3xxUf7EWBiOl3XnV5c=; b=DV9+2gS562HpPWhEZ6nwHdKyD4o4Rmr93rWGoOmagPT8QFjl+QkJB7+7sAZksxIGvo aUd3fz18Mwpk+UCMovOQU8wZ8EZgRBWNZOHFmAXKWYilEd4LJG4Xq0D4dbyg4S3JtBQF jslXN41qu8KF47RCQZpR4qVEwogpUP0DZZZ0y7JdknPK4rxQetXVYEdTE44f5bjOWkxF ZZt6kvZSv74EBZiRMZAqN2dQKY02EJz7Dd7rpezSrvfiHIeaKc+JwDZRko5jMMKVEezN 8aC1BkUyg/K+nw+XnVltgwQgq2CB9It2Q8wPnTgtFOnPScnqfFekJoQeNBE/Kfa7tk2y t2pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=On0T/7g/anpVqlwJ2MY/+NEfT3xxUf7EWBiOl3XnV5c=; b=N5NJh1nCKqamkukvG3n50XYukUPIhShlU68eYYRSiSZNAgO4lZ/A+RvDk/+sRmn/Zy sHGWf1ATYCU3qchLtLyXTlY3In/9GIxNaW9Ompa+MWqFzC5kdqHyoLfICq7b/ITJ91Qt PELrnaCV0Kf/DsESo0EmOLDsMHJa2EqWFFNgvax+LXWIYIsYg7i/bCVasZNdVUFVY+PA qReRcNBpdFZcdlneuWtkKODx5/Xz2L3nW0VVDuwx1/VcvtWuO/wVeZo9ocM7YIIarIGJ 0BT/grsSO3kOnmejMSFh+33GobwmDBvGEzeJAYJIfmAhRjqK/qq7aEEP5mspaBj1/rSL SKOA== X-Gm-Message-State: AFqh2kroUgxV4/DP1UCpo6UIxoJ+qA2hQsGnmZwpkxtAuJ9igTsiy80I ks2/aMhVaBNP95phH6KB/hTki8W8FFIHIQ== X-Google-Smtp-Source: AMrXdXv1Qhm47OQDtCnV208wL7m/SaDj6akeMtf8qm5j3Wj7kbgScg7KMcVM04w+qkErwlOCI+AFaQ== X-Received: by 2002:a62:5214:0:b0:581:b3b3:7714 with SMTP id g20-20020a625214000000b00581b3b37714mr34407912pfb.20.1673133601668; Sat, 07 Jan 2023 15:20:01 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id z5-20020aa79905000000b00574ee8cfdabsm3398253pff.148.2023.01.07.15.20.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Jan 2023 15:20:01 -0800 (PST) From: Yuan Fu Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: control message for bug #60176 Message-Id: <13C4D1D9-ED51-4612-B297-3E545ED4B755@gmail.com> Date: Sat, 7 Jan 2023 15:20:00 -0800 To: control@debbugs.gnu.org X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: 0.0 (/) 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" X-Spam-Score: -1.0 (-) severity 60176 wishlist quit From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 09 12:35:26 2023 Received: (at 60176) by debbugs.gnu.org; 9 Jan 2023 17:35:26 +0000 Received: from localhost ([127.0.0.1]:38094 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEw3R-0004DU-Nn for submit@debbugs.gnu.org; Mon, 09 Jan 2023 12:35:25 -0500 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:60275) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEw3P-0004D5-NX for 60176@debbugs.gnu.org; Mon, 09 Jan 2023 12:35:24 -0500 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id B49A5FF807; Mon, 9 Jan 2023 17:35:14 +0000 (UTC) From: Juri Linkov To: Stefan Monnier Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable In-Reply-To: (Stefan Monnier's message of "Mon, 19 Dec 2022 11:43:46 -0500") Organization: LINKOV.NET References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> Date: Mon, 09 Jan 2023 19:30:20 +0200 Message-ID: <865ydf3dnf.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 60176 Cc: Eli Zaretskii , sadiq@sadiqpk.org, 60176@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.7 (-) >> 'major-mode-remap-alist' should be able to handle this requirement >> since its design is similar to MIME.TYPES and MAILCAP. But actually >> MAILCAP supports an additional predicate TEST that is a command >> executed to determine whether or not the mailcap line applies. >> >> So to completely cover all needs, 'major-mode-remap-alist' should >> support a predicate as well. For example, >> >> (setq major-mode-remap-alist '((c-mode #'treesit-available-p c-ts-mode))) > > The current syntax is rather > > (setq major-mode-remap-alist '((c-mode . treesit-available-p c-ts-mode))) Is it possible at least to make this forward-compatible to support such a predicate in future? To enable ts-modes only in some buffers currently requires first to enable non-ts-mode, then conditionally ts-mode: (add-hook 'find-file-hook (lambda () (when (and (eq major-mode 'c-mode) ;; Unless in internal buffers: (not (string-prefix-p " " (buffer-name)))) (c-ts-mode)))) With a predicate in major-mode-remap-alist it would immediately enable the required mode: (setq major-mode-remap-alist '((c-mode . (lambda () (not (string-prefix-p " " (buffer-name)))) c-ts-mode))) Such a predicate would be useful in many other cases. For example, by default ".pl" is assigned to perl-mode, but this would help to reassign it to prolog-mode using some heuristics: (setq major-mode-remap-alist '((perl-mode . (lambda () (string-match-p "src/prolog" buffer-file-name)) prolog-mode))) From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 09 12:57:40 2023 Received: (at 60176) by debbugs.gnu.org; 9 Jan 2023 17:57:40 +0000 Received: from localhost ([127.0.0.1]:38111 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEwOy-0004nb-9R for submit@debbugs.gnu.org; Mon, 09 Jan 2023 12:57:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39874) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEwOw-0004nN-HJ for 60176@debbugs.gnu.org; Mon, 09 Jan 2023 12:57:39 -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 1pEwOp-0007y2-E9; Mon, 09 Jan 2023 12:57:32 -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=JNe4z43s0xK1qSGSMTm8R/IQtL2A630pjrJPgWOeJzg=; b=luYNGCBGm2Uv iT0Bb7Toh37s+RfSl5Znq1LgCRGCpEu8C+FFb3ti+iHyFNOzQuhHsU0LJRGqHSyKQuJxbujfrpCFv BXAHzoxCJQTITMD87Ctvo+oqGu3S6FJrp09I/0CBvz3uSrtLw00rRhIATS9qJRvXxxacXgbNer2nO w38DyXGVh8Rv1MyGHQG+xBqNyMe+AZHodM/fkoUcmS3XIMkMp2l3PvpcP6dcyW43OfSjG8HfRNOBJ Xg1IbxgM+8WiZdNuFqQpbAolf8/lnPoyM9CFVR68cCt0RxjSr0cy9HyKTuvG0CgIiv+rfmhhFa2TR RIfiTkwxs/V/iWa67MFe9g==; 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 1pEwOi-0007kg-J3; Mon, 09 Jan 2023 12:57:30 -0500 Date: Mon, 09 Jan 2023 19:57:50 +0200 Message-Id: <83y1qboajl.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <865ydf3dnf.fsf@mail.linkov.net> (message from Juri Linkov on Mon, 09 Jan 2023 19:30:20 +0200) Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> <865ydf3dnf.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60176 Cc: sadiq@sadiqpk.org, monnier@iro.umontreal.ca, 60176@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: -3.3 (---) > From: Juri Linkov > Cc: Eli Zaretskii , sadiq@sadiqpk.org, 60176@debbugs.gnu.org > Date: Mon, 09 Jan 2023 19:30:20 +0200 > > Is it possible at least to make this forward-compatible to support > such a predicate in future? To enable ts-modes only in some buffers > currently requires first to enable non-ts-mode, then conditionally ts-mode: > > (add-hook 'find-file-hook > (lambda () > (when (and (eq major-mode 'c-mode) > ;; Unless in internal buffers: > (not (string-prefix-p " " (buffer-name)))) > (c-ts-mode)))) > > With a predicate in major-mode-remap-alist it would immediately > enable the required mode: > > (setq major-mode-remap-alist > '((c-mode . (lambda () (not (string-prefix-p " " (buffer-name)))) > c-ts-mode))) Why do we need such hoops to jump through? I think we should simply add (add-to-list 'auto-mode-alist '("\\.[ch]\\'" . c-ts-mode)) to c-ts-mode.el (and similarly for C++), and that's it. From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 09 18:06:28 2023 Received: (at 60176) by debbugs.gnu.org; 9 Jan 2023 23:06:28 +0000 Received: from localhost ([127.0.0.1]:38365 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pF1Do-0004mT-Cm for submit@debbugs.gnu.org; Mon, 09 Jan 2023 18:06:28 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:31626) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pF1Dn-0004mE-2C for 60176@debbugs.gnu.org; Mon, 09 Jan 2023 18:06:27 -0500 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id C79D580861; Mon, 9 Jan 2023 18:06:21 -0500 (EST) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 44FB080224; Mon, 9 Jan 2023 18:06:19 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1673305579; bh=/r2k8yjCcdhJ6TBoSZsHelThZm5nMV/TjAfeAcBNuFQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=BzYC8hgq6viaCprXqAShfIJyhSz470ncGh5KGtoaRuCWzw3kELGFXB6Q/gW1OOPDn Ihe/N2oY5bD9naCiMEi3QMv4WSmCGV6inU15yAqzos+EvARt1RvJG68YSNpYm48eHb 2wl1ivaFmzvmtKm/47SJemFF2TAVgswLAi0aXqix/ENAfuPRL0cNZmrppSwwqLRbdx /YQYqb08RgPRwABUlM3Y/+yJDB9sNCqSOxEkYbcUP6ZSy+saeU7IWo3zWORRgBcooT S1TGXDsDle228raNEvhA/xdzzGY6/e1eBT9OIG9JC2oS55Nf0T+1UbBxm+glhwn7HF wR2lT7oQl6dFQ== Received: from pastel (unknown [45.72.200.228]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id EF2EB120BDE; Mon, 9 Jan 2023 18:06:18 -0500 (EST) From: Stefan Monnier To: Juri Linkov Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable In-Reply-To: <865ydf3dnf.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 09 Jan 2023 19:30:20 +0200") Message-ID: References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> <865ydf3dnf.fsf@mail.linkov.net> Date: Mon, 09 Jan 2023 18:06:17 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.264 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60176 Cc: Eli Zaretskii , sadiq@sadiqpk.org, 60176@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: -3.3 (---) >> The current syntax is rather >> >> (setq major-mode-remap-alist '((c-mode . treesit-available-p c-ts-mode))) > > Is it possible at least to make this forward-compatible to support > such a predicate in future? To enable ts-modes only in some buffers > currently requires first to enable non-ts-mode, then conditionally ts-mode: We can use: (setq (alist-get 'c-mode major-mode-remap-alist) (lambda () (if (treesit-available-p) (c-ts-mode) (c-mode)))) -- Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 10 07:54:51 2023 Received: (at 60176) by debbugs.gnu.org; 10 Jan 2023 12:54:51 +0000 Received: from localhost ([127.0.0.1]:39110 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFE9T-0004Yd-2I for submit@debbugs.gnu.org; Tue, 10 Jan 2023 07:54:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59154) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFE9Q-0004YM-Jv for 60176@debbugs.gnu.org; Tue, 10 Jan 2023 07:54:49 -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 1pFE9J-00032t-4U; Tue, 10 Jan 2023 07:54:41 -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=ychaaKx/4woHYgUOY3AZRqzYrL5uJUe2Cajr/gOOfuU=; b=D3EETNaa5S5p gt2VxvzLlkfTEkhlXrjSSja3O1eFOFA0vvKMEsdlcPXaKwrpQcSlk1v9Y61TsPK2zMEMR6y/kG0kZ ZYAOxaVLS/E8MhKg0DSM2LRVntWHDKzsEPJPNzn7+lEcCdzS9RFsSK4C/8Mro+62vSIoyB0q/VwrF kGWkO00Qf0ZoYq/g1YDa4Qdvi+blKZKlnafKkohXk+iwXrQMb6vI1gFiZ7WOkO8S/NhJJ8PdRbhi4 ItyNKNkGK2BlsSs/vtyyUu15y8uSVbEvGNdMTS40EoQnLahZyX3Y26XtSh/ZucwbPsvqCIxJwtVF2 4g9PSYWvq+ExlV3QEQ3VUg==; 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 1pFE9I-0005FL-89; Tue, 10 Jan 2023 07:54:40 -0500 Date: Tue, 10 Jan 2023 14:55:08 +0200 Message-Id: <83lemao8gj.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Mon, 09 Jan 2023 18:06:17 -0500) Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> <865ydf3dnf.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60176 Cc: sadiq@sadiqpk.org, 60176@debbugs.gnu.org, juri@linkov.net 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: Stefan Monnier > Cc: Eli Zaretskii , sadiq@sadiqpk.org, 60176@debbugs.gnu.org > Date: Mon, 09 Jan 2023 18:06:17 -0500 > > >> The current syntax is rather > >> > >> (setq major-mode-remap-alist '((c-mode . treesit-available-p c-ts-mode))) > > > > Is it possible at least to make this forward-compatible to support > > such a predicate in future? To enable ts-modes only in some buffers > > currently requires first to enable non-ts-mode, then conditionally ts-mode: > > We can use: > > (setq (alist-get 'c-mode major-mode-remap-alist) > (lambda () (if (treesit-available-p) (c-ts-mode) (c-mode)))) Who is "we" here? I don't want to do this by default, because we want users of Emacs 29 to turn on TS modes manually, if and when they want that and think they are ready. Of course, I don't mind if the above is done in local customizations by users who are willing to use TS modes whenever they become available. From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 10 09:30:06 2023 Received: (at 60176) by debbugs.gnu.org; 10 Jan 2023 14:30:06 +0000 Received: from localhost ([127.0.0.1]:39187 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFFdd-00077O-WD for submit@debbugs.gnu.org; Tue, 10 Jan 2023 09:30:06 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:60435) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFFdb-00076b-OL for 60176@debbugs.gnu.org; Tue, 10 Jan 2023 09:30:04 -0500 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 3D88580DCA; Tue, 10 Jan 2023 09:29:58 -0500 (EST) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id B097B80CFB; Tue, 10 Jan 2023 09:29:56 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1673360996; bh=aRZAhB01QeXhwGqd1rW6aXARm9B/d8vCFlMHlEUSuak=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=TeNibU6dNHwmoCxPdS8ZK4thZU6F+VlnIX3H/Lwxg8J0df/tw1XjA6ag9QaY+62a9 8Vf94Dzadlu8mvfv5jqzU9/gQO0hGs/WZMSc1LDdwhZhA4lM+i8YPLQKfoxitJwAXT B/LIwa9omARf2DvD4ZNaP2pOgP3rvJEmbJanomsIdE4RSN7kYSdUXWSaPfcfmDEDFW QntuRSSNTcQ+rI6DW+U8A7f0cJeD5RrnnT2VhTTmSZmFmRrZaBQTR7OdQ3iS3K2exe uZztHL3cGHbgyZ/nt02E8g4vjQ2n7+jnr9nvUdz8/V1fUt9dFr9EU+aMB2KyQmvj2v uwFEfM47gqkDQ== Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6DBDF120C3E; Tue, 10 Jan 2023 09:29:56 -0500 (EST) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable In-Reply-To: <83lemao8gj.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 10 Jan 2023 14:55:08 +0200") Message-ID: References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> <865ydf3dnf.fsf@mail.linkov.net> <83lemao8gj.fsf@gnu.org> Date: Tue, 10 Jan 2023 09:29:55 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.053 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60176 Cc: sadiq@sadiqpk.org, 60176@debbugs.gnu.org, juri@linkov.net 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 (---) >> We can use: >> >> (setq (alist-get 'c-mode major-mode-remap-alist) >> (lambda () (if (treesit-available-p) (c-ts-mode) (c-mode)))) > > Who is "we" here? "we" as in "we can recommend this to those users who want to do that". > I don't want to do this by default, because we want users of Emacs 29 I don't either. I was just answering to the request to make room in the format of `major-mode-remap-alist` for a potential future "predicate", by pointing out that the current format already allows that. Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 10 13:10:23 2023 Received: (at 60176) by debbugs.gnu.org; 10 Jan 2023 18:10:23 +0000 Received: from localhost ([127.0.0.1]:41091 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFJ4p-0007O8-FC for submit@debbugs.gnu.org; Tue, 10 Jan 2023 13:10:23 -0500 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:36409) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFJ4n-0007Nu-TR for 60176@debbugs.gnu.org; Tue, 10 Jan 2023 13:10:22 -0500 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id A3FD8FF806; Tue, 10 Jan 2023 18:10:14 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable In-Reply-To: <83lemao8gj.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 10 Jan 2023 14:55:08 +0200") Organization: LINKOV.NET References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> <865ydf3dnf.fsf@mail.linkov.net> <83lemao8gj.fsf@gnu.org> Date: Tue, 10 Jan 2023 20:08:15 +0200 Message-ID: <86lemap8j4.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 60176 Cc: sadiq@sadiqpk.org, Stefan Monnier , 60176@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.7 (-) >> (setq (alist-get 'c-mode major-mode-remap-alist) >> (lambda () (if (treesit-available-p) (c-ts-mode) (c-mode)))) > > I don't want to do this by default, because we want users of Emacs 29 > to turn on TS modes manually, if and when they want that and think > they are ready. > > Of course, I don't mind if the above is done in local customizations > by users who are willing to use TS modes whenever they become > available. Shouldn't we help users by simplifying such complex customization and provide a customizable list of modes where tree-sitter is enabled, e.g. (defcustom treesit-enable-modes nil :type '(repeat (choice (function-item c-ts-mode) (function-item c++-ts-mode) (function-item c-or-c++-ts-mode) ... :initialize #'custom-initialize-default :set (lambda (sym val) (set-default sym val) (dolist (mode treesit-enable-modes) (pcase mode ('c-ts-mode (when (treesit-ready-p 'c t) (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode)))) ... From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 10 13:21:40 2023 Received: (at 60176) by debbugs.gnu.org; 10 Jan 2023 18:21:40 +0000 Received: from localhost ([127.0.0.1]:41112 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFJFj-0007fs-MJ for submit@debbugs.gnu.org; Tue, 10 Jan 2023 13:21:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51948) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFJFg-0007fe-Nl for 60176@debbugs.gnu.org; Tue, 10 Jan 2023 13:21:38 -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 1pFJFa-0007Ve-UJ; Tue, 10 Jan 2023 13:21:30 -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=6X0EOV22OATLkacIxQHhGzV00omoiPXnFA5fL8yrkAs=; b=TCiocg5eCoUH bhwC2xkFCe4IGfDSIRsuKHI7E50vyX2lY66y3bQucltXbQgtKSQAagSElClb80G4/QqWRSetq4Aby H3wJS+zOKGTshSEZP7QRM/T/AEGyfvIBl6DslYVfiHITIjKQ62Q5GNSh9MlGBCSThcfdaPM+U/yID rywqaCbLFEWOFYn26zFXx3C0admvQD06bpRxFPCXpLbF2cTTNGZvJoIwbleJ9T9Tm3OfRIw4eHRTJ 5cIhZjhTSUay3mbJrBT/Ec5/qzwbdbd8Y4oh2lJHCDR7MtNhUNPIKA+iu2hLyMXkZdgHOqtENuV6g wfzUByRZNY6GS82p+sj/kg==; 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 1pFJFa-0003gR-4S; Tue, 10 Jan 2023 13:21:30 -0500 Date: Tue, 10 Jan 2023 20:21:58 +0200 Message-Id: <83r0w2merd.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <86lemap8j4.fsf@mail.linkov.net> (message from Juri Linkov on Tue, 10 Jan 2023 20:08:15 +0200) Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> <865ydf3dnf.fsf@mail.linkov.net> <83lemao8gj.fsf@gnu.org> <86lemap8j4.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60176 Cc: sadiq@sadiqpk.org, monnier@iro.umontreal.ca, 60176@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: -3.3 (---) > From: Juri Linkov > Cc: Stefan Monnier , sadiq@sadiqpk.org, > 60176@debbugs.gnu.org > Date: Tue, 10 Jan 2023 20:08:15 +0200 > > >> (setq (alist-get 'c-mode major-mode-remap-alist) > >> (lambda () (if (treesit-available-p) (c-ts-mode) (c-mode)))) > > > > I don't want to do this by default, because we want users of Emacs 29 > > to turn on TS modes manually, if and when they want that and think > > they are ready. > > > > Of course, I don't mind if the above is done in local customizations > > by users who are willing to use TS modes whenever they become > > available. > > Shouldn't we help users by simplifying such complex customization What is so complex in activating a mode with a single command or a function call? Users do that all the time in their init files and manually. > and provide a customizable list of modes where tree-sitter is enabled, > e.g. > > (defcustom treesit-enable-modes nil > :type '(repeat > (choice (function-item c-ts-mode) > (function-item c++-ts-mode) > (function-item c-or-c++-ts-mode) > ... I disagree that asking users to customize lists of modes is helping them. I think just activating the modes they want, either manually or in the init files, is a much simpler way of customization. I don't understand why you think the above is helping the users in any way. > ('c-ts-mode > (when (treesit-ready-p 'c t) > (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode)))) And this bit is completely unacceptable, from where I stand: it basically means that the user activated a certain major mode he/she wanted to use, but the result could be that an entirely different mode was silently activated instead. What kind of UX is that, and for a shining new feature at that?? From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 16 12:46:14 2023 Received: (at 60176) by debbugs.gnu.org; 16 Jan 2023 17:46:14 +0000 Received: from localhost ([127.0.0.1]:34634 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHTYk-0008IH-9W for submit@debbugs.gnu.org; Mon, 16 Jan 2023 12:46:14 -0500 Received: from relay11.mail.gandi.net ([217.70.178.231]:36701) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHTYi-0008I4-L0 for 60176@debbugs.gnu.org; Mon, 16 Jan 2023 12:46:13 -0500 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 6A61E10000A; Mon, 16 Jan 2023 17:46:03 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable In-Reply-To: <83r0w2merd.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 10 Jan 2023 20:21:58 +0200") Organization: LINKOV.NET References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> <865ydf3dnf.fsf@mail.linkov.net> <83lemao8gj.fsf@gnu.org> <86lemap8j4.fsf@mail.linkov.net> <83r0w2merd.fsf@gnu.org> Date: Mon, 16 Jan 2023 19:32:06 +0200 Message-ID: <86ilh64cox.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 60176 Cc: sadiq@sadiqpk.org, monnier@iro.umontreal.ca, 60176@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.7 (-) >> (defcustom treesit-enable-modes nil >> :type '(repeat >> (choice (function-item c-ts-mode) >> (function-item c++-ts-mode) >> (function-item c-or-c++-ts-mode) >> ... >> ('c-ts-mode >> (when (treesit-ready-p 'c t) >> (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode)))) > > And this bit is completely unacceptable, from where I stand: it > basically means that the user activated a certain major mode he/she > wanted to use, but the result could be that an entirely different mode > was silently activated instead. What kind of UX is that, and for a > shining new feature at that?? It could update 'auto-mode-alist' instead of 'major-mode-remap-alist'. >From the user's point of view this would be more manageable than what you proposed on emacs-devel with some obscure logic of activating ts modes when the package is loaded or when the mode is enabled first time. From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 16 13:21:39 2023 Received: (at 60176) by debbugs.gnu.org; 16 Jan 2023 18:21:39 +0000 Received: from localhost ([127.0.0.1]:34822 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHU71-0003GX-FZ for submit@debbugs.gnu.org; Mon, 16 Jan 2023 13:21:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37766) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHU6v-0003G9-85 for 60176@debbugs.gnu.org; Mon, 16 Jan 2023 13:21:37 -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 1pHU6g-0006OZ-3O; Mon, 16 Jan 2023 13:21:27 -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=WPM1cVera8ff6m4soSSUM3tLdTQJDGigUNRhkZWLVAU=; b=FepuSPjnxkiv UUHGwXtOV3bPHHGDDiFZ/rqzSGyEC5Gc7z0hulK+G1yLw/2xU1l0uqrTqlTKS1w6VstDejHaqM0v2 /qq9dBgjFbh9KWTOx9A4s5/aCjiguimvgE6UUR167BhDkjJPdL5jGZmG8ozTfE7pI+CvIq/1lVfLw VRKx4r6D4vUvgYS/Zd7SrRHl3mpdmEbbtgZSOMACh88jpTCwzsVc5w6DWqHiMUbkhfn7D2IYPUiiG Uxl3WxlCjg+IMkU9KyI+CjSYMe5rKNEBo7AR04J433+OLzG5hIHGsEAtHh3NZEd+3SWB1jLuGbUu1 kU6PaPx2e2lYgCKlZt9cGg==; 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 1pHU6c-0007Ir-HM; Mon, 16 Jan 2023 13:21:16 -0500 Date: Mon, 16 Jan 2023 20:21:22 +0200 Message-Id: <838ri249y5.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <86ilh64cox.fsf@mail.linkov.net> (message from Juri Linkov on Mon, 16 Jan 2023 19:32:06 +0200) Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> <865ydf3dnf.fsf@mail.linkov.net> <83lemao8gj.fsf@gnu.org> <86lemap8j4.fsf@mail.linkov.net> <83r0w2merd.fsf@gnu.org> <86ilh64cox.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60176 Cc: sadiq@sadiqpk.org, monnier@iro.umontreal.ca, 60176@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: -3.3 (---) > From: Juri Linkov > Cc: monnier@iro.umontreal.ca, sadiq@sadiqpk.org, 60176@debbugs.gnu.org > Date: Mon, 16 Jan 2023 19:32:06 +0200 > > >> (defcustom treesit-enable-modes nil > >> :type '(repeat > >> (choice (function-item c-ts-mode) > >> (function-item c++-ts-mode) > >> (function-item c-or-c++-ts-mode) > >> ... > >> ('c-ts-mode > >> (when (treesit-ready-p 'c t) > >> (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode)))) > > > > And this bit is completely unacceptable, from where I stand: it > > basically means that the user activated a certain major mode he/she > > wanted to use, but the result could be that an entirely different mode > > was silently activated instead. What kind of UX is that, and for a > > shining new feature at that?? > > It could update 'auto-mode-alist' instead of 'major-mode-remap-alist'. > >From the user's point of view this would be more manageable than > what you proposed on emacs-devel with some obscure logic of activating > ts modes when the package is loaded or when the mode is enabled first time. I don't understand the "obscure" part: the logic was exactly as above: test that treesit-ready-p returns non-nil for the mode's language. Other than that, my proposal does exactly what you say here: it updates auto-mode-alist. So it sounds like we are in violent agreement. From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 16 13:37:59 2023 Received: (at 60176) by debbugs.gnu.org; 16 Jan 2023 18:37:59 +0000 Received: from localhost ([127.0.0.1]:34866 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHUMo-00066E-S5 for submit@debbugs.gnu.org; Mon, 16 Jan 2023 13:37:59 -0500 Received: from relay10.mail.gandi.net ([217.70.178.230]:33401) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHUMm-00065u-AJ for 60176@debbugs.gnu.org; Mon, 16 Jan 2023 13:37:56 -0500 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 1FB82240006; Mon, 16 Jan 2023 18:37:47 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable In-Reply-To: <838ri249y5.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 16 Jan 2023 20:21:22 +0200") Organization: LINKOV.NET References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> <865ydf3dnf.fsf@mail.linkov.net> <83lemao8gj.fsf@gnu.org> <86lemap8j4.fsf@mail.linkov.net> <83r0w2merd.fsf@gnu.org> <86ilh64cox.fsf@mail.linkov.net> <838ri249y5.fsf@gnu.org> Date: Mon, 16 Jan 2023 20:36:45 +0200 Message-ID: <86r0vu1g3m.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 60176 Cc: sadiq@sadiqpk.org, monnier@iro.umontreal.ca, 60176@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.7 (-) >> >> (defcustom treesit-enable-modes nil >> >> :type '(repeat >> >> (choice (function-item c-ts-mode) >> >> (function-item c++-ts-mode) >> >> (function-item c-or-c++-ts-mode) >> >> ... >> >> ('c-ts-mode >> >> (when (treesit-ready-p 'c t) >> >> (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode)))) >> > >> > And this bit is completely unacceptable, from where I stand: it >> > basically means that the user activated a certain major mode he/she >> > wanted to use, but the result could be that an entirely different mode >> > was silently activated instead. What kind of UX is that, and for a >> > shining new feature at that?? >> >> It could update 'auto-mode-alist' instead of 'major-mode-remap-alist'. >> >From the user's point of view this would be more manageable than >> what you proposed on emacs-devel with some obscure logic of activating >> ts modes when the package is loaded or when the mode is enabled first time. > > I don't understand the "obscure" part: the logic was exactly as above: > test that treesit-ready-p returns non-nil for the mode's language. > > Other than that, my proposal does exactly what you say here: it > updates auto-mode-alist. So it sounds like we are in violent agreement. The difference is that an explicit option is more controllable by the user. When the user needs to use some ts-mode then it's easier just to customize the option instead of tweaking 'auto-mode-alist' when the user want to start using that mode without first loading its package or calling it the first time that modifies 'auto-mode-alist' as the side effect. Or when the user wants to remove the mode from 'auto-mode-alist' after accidentally loading the corresponding ts package. From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 16 14:27:09 2023 Received: (at 60176) by debbugs.gnu.org; 16 Jan 2023 19:27:09 +0000 Received: from localhost ([127.0.0.1]:34898 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHV8O-0007Ut-MM for submit@debbugs.gnu.org; Mon, 16 Jan 2023 14:27:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34210) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHV8K-0007UL-9t for 60176@debbugs.gnu.org; Mon, 16 Jan 2023 14:27:07 -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 1pHV7z-0000W9-Ke; Mon, 16 Jan 2023 14:26:53 -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=Loa/0cPaIz/IWP8/4jeODsHTpchVDDCDiJa72XGUxbQ=; b=DyTqXUozYLkU vR/HMuNnLUO/f/SU8gSyhYXE6Db71/O+921XpR6MKXJ1HyBVNynu4KofFY5ALFjUNI9Fl4JJYbopf 6GdFcByLFGPRCW3n8R16lQX7EC3qvfypkVtKaPFkd0h2Pz0v0s+FQ0sAB7V31X2cP2n0+n9UiA+Q3 ylMPtV1yuGIcwrBkGndLX6SGMBfxQR4+3pQCW4mxaLtJoQmBaV3N8GdgyXGO6DsYfPe3HH2DumOQq ENXIYpy/USXUhwHj6Y+OCA06gCBMG5hi69wCCBC+22Y2SXPZWh0bI2sf8LKj6Ukd/pIWaBqBJXrgV 0Os7Z4BghuZC1x+zCmYw7Q==; 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 1pHV7x-0005Vd-Vp; Mon, 16 Jan 2023 14:26:43 -0500 Date: Mon, 16 Jan 2023 21:26:50 +0200 Message-Id: <835yd646x1.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <86r0vu1g3m.fsf@mail.linkov.net> (message from Juri Linkov on Mon, 16 Jan 2023 20:36:45 +0200) Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> <865ydf3dnf.fsf@mail.linkov.net> <83lemao8gj.fsf@gnu.org> <86lemap8j4.fsf@mail.linkov.net> <83r0w2merd.fsf@gnu.org> <86ilh64cox.fsf@mail.linkov.net> <838ri249y5.fsf@gnu.org> <86r0vu1g3m.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60176 Cc: sadiq@sadiqpk.org, monnier@iro.umontreal.ca, 60176@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: -3.3 (---) > From: Juri Linkov > Cc: monnier@iro.umontreal.ca, sadiq@sadiqpk.org, 60176@debbugs.gnu.org > Date: Mon, 16 Jan 2023 20:36:45 +0200 > > >> >> (defcustom treesit-enable-modes nil > >> >> :type '(repeat > >> >> (choice (function-item c-ts-mode) > >> >> (function-item c++-ts-mode) > >> >> (function-item c-or-c++-ts-mode) > >> >> ... > >> >> ('c-ts-mode > >> >> (when (treesit-ready-p 'c t) > >> >> (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode)))) > >> > > >> > And this bit is completely unacceptable, from where I stand: it > >> > basically means that the user activated a certain major mode he/she > >> > wanted to use, but the result could be that an entirely different mode > >> > was silently activated instead. What kind of UX is that, and for a > >> > shining new feature at that?? > >> > >> It could update 'auto-mode-alist' instead of 'major-mode-remap-alist'. > >> >From the user's point of view this would be more manageable than > >> what you proposed on emacs-devel with some obscure logic of activating > >> ts modes when the package is loaded or when the mode is enabled first time. > > > > I don't understand the "obscure" part: the logic was exactly as above: > > test that treesit-ready-p returns non-nil for the mode's language. > > > > Other than that, my proposal does exactly what you say here: it > > updates auto-mode-alist. So it sounds like we are in violent agreement. > > The difference is that an explicit option is more controllable by the user. > When the user needs to use some ts-mode then it's easier just to customize > the option instead of tweaking 'auto-mode-alist' when the user want to > start using that mode without first loading its package or calling it > the first time that modifies 'auto-mode-alist' as the side effect. With the changes I proposed, there's no need to tweak auto-mode-alist. A simple load or require of the mode will install the mode in auto-mode-alist. What can be easier and simpler? From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 17 02:36:52 2023 Received: (at 60176) by debbugs.gnu.org; 17 Jan 2023 07:36:52 +0000 Received: from localhost ([127.0.0.1]:35563 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHgWa-0003fp-3S for submit@debbugs.gnu.org; Tue, 17 Jan 2023 02:36:52 -0500 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:42499) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHgWY-0003fa-6P for 60176@debbugs.gnu.org; Tue, 17 Jan 2023 02:36:51 -0500 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 99A0624000D; Tue, 17 Jan 2023 07:36:41 +0000 (UTC) From: Juri Linkov To: Eli Zaretskii Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable In-Reply-To: <835yd646x1.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 16 Jan 2023 21:26:50 +0200") Organization: LINKOV.NET References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> <865ydf3dnf.fsf@mail.linkov.net> <83lemao8gj.fsf@gnu.org> <86lemap8j4.fsf@mail.linkov.net> <83r0w2merd.fsf@gnu.org> <86ilh64cox.fsf@mail.linkov.net> <838ri249y5.fsf@gnu.org> <86r0vu1g3m.fsf@mail.linkov.net> <835yd646x1.fsf@gnu.org> Date: Tue, 17 Jan 2023 09:33:02 +0200 Message-ID: <864jspd5l5.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 60176 Cc: sadiq@sadiqpk.org, monnier@iro.umontreal.ca, 60176@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.7 (-) >> >> >> (defcustom treesit-enable-modes nil >> >> >> :type '(repeat >> >> >> (choice (function-item c-ts-mode) >> >> >> (function-item c++-ts-mode) >> >> >> (function-item c-or-c++-ts-mode) >> >> >> ... >> >> >> ('c-ts-mode >> >> >> (when (treesit-ready-p 'c t) >> >> >> (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode)))) >> >> > >> >> > And this bit is completely unacceptable, from where I stand: it >> >> > basically means that the user activated a certain major mode he/she >> >> > wanted to use, but the result could be that an entirely different mode >> >> > was silently activated instead. What kind of UX is that, and for a >> >> > shining new feature at that?? >> >> >> >> It could update 'auto-mode-alist' instead of 'major-mode-remap-alist'. >> >> >From the user's point of view this would be more manageable than >> >> what you proposed on emacs-devel with some obscure logic of activating >> >> ts modes when the package is loaded or when the mode is enabled first time. >> > >> > I don't understand the "obscure" part: the logic was exactly as above: >> > test that treesit-ready-p returns non-nil for the mode's language. >> > >> > Other than that, my proposal does exactly what you say here: it >> > updates auto-mode-alist. So it sounds like we are in violent agreement. >> >> The difference is that an explicit option is more controllable by the user. >> When the user needs to use some ts-mode then it's easier just to customize >> the option instead of tweaking 'auto-mode-alist' when the user want to >> start using that mode without first loading its package or calling it >> the first time that modifies 'auto-mode-alist' as the side effect. > > With the changes I proposed, there's no need to tweak > auto-mode-alist. A simple load or require of the mode will install > the mode in auto-mode-alist. What can be easier and simpler? This doesn't address the problems mentioned above and below. >> Or when the user wants to remove the mode from 'auto-mode-alist' after >> accidentally loading the corresponding ts package. From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 17 07:07:46 2023 Received: (at 60176) by debbugs.gnu.org; 17 Jan 2023 12:07:46 +0000 Received: from localhost ([127.0.0.1]:35965 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHkkj-00076j-Qa for submit@debbugs.gnu.org; Tue, 17 Jan 2023 07:07:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47130) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHkkg-00076U-SR for 60176@debbugs.gnu.org; Tue, 17 Jan 2023 07:07:44 -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 1pHkka-00033O-Gl; Tue, 17 Jan 2023 07:07:36 -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=tvnrmGQUDZtF/MObuP3DxVOk6IqWQgKYjwxlZGMQ0i0=; b=Ki7zJOi/IZsa WqyNunDAf2OLEaH+rprw3eDbvL/rs24nglN6aaX3DLm5wBg6iek3VmkwZtT8qQYXQddkbvi946oRt 0muw3XBdfXR9yl1ptKspr4Hh7ZlEQXnoHURDMewVkRilRoEcRAs65GIoymacKqTwA1PtaoEpSlJ9L LGI4I3L3oF2b1QSF3j5D5B2t7t9kdYHVHy9RWGlbkhkIBHsLbV2BcBM8IIqNIGw0OYfxo8fKwPD5u zisxftWgVaQ3nUQSJ20UeTeqVGEM+sjRdbHmqtnSiXszGJhzZi2DoONFxa0SZA/VSVW2tdGRSK9ke WMwzLd5CjD9AW5OrrgL4VQ==; 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 1pHkkZ-00038K-BN; Tue, 17 Jan 2023 07:07:36 -0500 Date: Tue, 17 Jan 2023 14:07:45 +0200 Message-Id: <831qnt4b5a.fsf@gnu.org> From: Eli Zaretskii To: Juri Linkov In-Reply-To: <864jspd5l5.fsf@mail.linkov.net> (message from Juri Linkov on Tue, 17 Jan 2023 09:33:02 +0200) Subject: Re: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> <865ydf3dnf.fsf@mail.linkov.net> <83lemao8gj.fsf@gnu.org> <86lemap8j4.fsf@mail.linkov.net> <83r0w2merd.fsf@gnu.org> <86ilh64cox.fsf@mail.linkov.net> <838ri249y5.fsf@gnu.org> <86r0vu1g3m.fsf@mail.linkov.net> <835yd646x1.fsf@gnu.org> <864jspd5l5.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 60176 Cc: sadiq@sadiqpk.org, monnier@iro.umontreal.ca, 60176@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: -3.3 (---) > From: Juri Linkov > Cc: monnier@iro.umontreal.ca, sadiq@sadiqpk.org, 60176@debbugs.gnu.org > Date: Tue, 17 Jan 2023 09:33:02 +0200 > > >> >> >> (defcustom treesit-enable-modes nil > >> >> >> :type '(repeat > >> >> >> (choice (function-item c-ts-mode) > >> >> >> (function-item c++-ts-mode) > >> >> >> (function-item c-or-c++-ts-mode) > >> >> >> ... > >> >> >> ('c-ts-mode > >> >> >> (when (treesit-ready-p 'c t) > >> >> >> (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode)))) > >> >> > > >> >> > And this bit is completely unacceptable, from where I stand: it > >> >> > basically means that the user activated a certain major mode he/she > >> >> > wanted to use, but the result could be that an entirely different mode > >> >> > was silently activated instead. What kind of UX is that, and for a > >> >> > shining new feature at that?? > >> >> > >> >> It could update 'auto-mode-alist' instead of 'major-mode-remap-alist'. > >> >> >From the user's point of view this would be more manageable than > >> >> what you proposed on emacs-devel with some obscure logic of activating > >> >> ts modes when the package is loaded or when the mode is enabled first time. > >> > > >> > I don't understand the "obscure" part: the logic was exactly as above: > >> > test that treesit-ready-p returns non-nil for the mode's language. > >> > > >> > Other than that, my proposal does exactly what you say here: it > >> > updates auto-mode-alist. So it sounds like we are in violent agreement. > >> > >> The difference is that an explicit option is more controllable by the user. > >> When the user needs to use some ts-mode then it's easier just to customize > >> the option instead of tweaking 'auto-mode-alist' when the user want to > >> start using that mode without first loading its package or calling it > >> the first time that modifies 'auto-mode-alist' as the side effect. > > > > With the changes I proposed, there's no need to tweak > > auto-mode-alist. A simple load or require of the mode will install > > the mode in auto-mode-alist. What can be easier and simpler? > > This doesn't address the problems mentioned above and below. Which parts "above" were not addressed? As for below: > >> Or when the user wants to remove the mode from 'auto-mode-alist' after > >> accidentally loading the corresponding ts package. I addressed that in the discussion on emacs-devel, see https://lists.gnu.org/archive/html/emacs-devel/2023-01/msg00278.html (I suggest to discuss this there, not here.) From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 17 08:01:44 2023 Received: (at control) by debbugs.gnu.org; 17 Jan 2023 13:01:45 +0000 Received: from localhost ([127.0.0.1]:36063 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHlay-0004r2-OJ for submit@debbugs.gnu.org; Tue, 17 Jan 2023 08:01:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50330) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHlav-0004qk-7B for control@debbugs.gnu.org; Tue, 17 Jan 2023 08:01:43 -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 1pHlap-0004Ey-T9 for control@debbugs.gnu.org; Tue, 17 Jan 2023 08:01:35 -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=7q6lEDvVkW3/eXqGkFkZF+nAe2b/StG3LVo9S0B2Y4w=; b=USkrZWdEti3X yefTdVdzqAqJsmtXA5e9Bjs5cEd2kbTMz4FVRh1E1FiKftTFagnhCGkU7VMFKNh1azGhyXl0sTw6J GJNSmNa0t4e5/bTNl3p6QmagUlM4Nw7LYF+SL36Nrswq+S5muwyYAz7lA3XoxDgbBoigRkYA/Y+Hm GRtGKBrXXn9vcj1kY5HE/V0tkekiTq5bQqBjGTYkhCmpRhrmc6slEf5w/ubOzQ7wgC2qRKEB4qIvR DYoCQsdiMQ/6wM7osZxrnnjNweTkCISFiBLmNEdZUhDOZPbrMMkk0pAv6GfzBWzFy6vfVu5gQZjgB c0KUyz5fLapRqWcDa9Bigw==; 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 1pHlao-0007qD-P0 for control@debbugs.gnu.org; Tue, 17 Jan 2023 08:01:35 -0500 Date: Tue, 17 Jan 2023 15:01:45 +0200 Message-Id: <83v8l52u2u.fsf@gnu.org> From: Eli Zaretskii To: control@debbugs.gnu.org (GNU bug tracker automated control server) In-Reply-To: (control@debbugs.gnu.org) Subject: Re: Processed (with 1 errors): Re: bug#60874: References: <83wn5l2ule.fsf@gnu.org> X-Spam-Score: -2.3 (--) 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" X-Spam-Score: -3.3 (---) severity 60176 normal tags 60559 merge 60559 60176 60874 thanks From unknown Wed Jun 18 00:15:37 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, 20 Feb 2023 12:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator