From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mohammed Sadiq Newsgroups: gmane.emacs.bugs Subject: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable Date: Mon, 19 Dec 2022 18:42:02 +0530 Message-ID: References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7227"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 60176@debbugs.gnu.org, monnier@iro.umontreal.ca, Juri Linkov To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 19 14:13:21 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p7FxJ-0001gh-Gx for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 19 Dec 2022 14:13:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7Fx9-00046u-T6; Mon, 19 Dec 2022 08:13:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p7Fx4-000461-Ss for bug-gnu-emacs@gnu.org; Mon, 19 Dec 2022 08:13:07 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p7Fx0-000101-PJ for bug-gnu-emacs@gnu.org; Mon, 19 Dec 2022 08:13:06 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p7Fx0-00029E-E7 for bug-gnu-emacs@gnu.org; Mon, 19 Dec 2022 08:13:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mohammed Sadiq Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Dec 2022 13:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60176 X-GNU-PR-Package: emacs Original-Received: via spool by 60176-submit@debbugs.gnu.org id=B60176.16714555348240 (code B ref 60176); Mon, 19 Dec 2022 13:13:02 +0000 Original-Received: (at 60176) by debbugs.gnu.org; 19 Dec 2022 13:12:14 +0000 Original-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 Original-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 Original-Received: (Authenticated sender: sadiq@sadiqpk.org) by mail.gandi.net (Postfix) with ESMTPA id 391A540007; Mon, 19 Dec 2022 13:12:02 +0000 (UTC) In-Reply-To: <83o7rzeflc.fsf@gnu.org> X-Sender: sadiq@sadiqpk.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:251428 Archived-At: 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.