From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable Date: Mon, 19 Dec 2022 09:39:14 +0200 Organization: LINKOV.NET Message-ID: <86359bhmfx.fsf@mail.linkov.net> References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39262"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: Stefan Monnier , 60176@debbugs.gnu.org To: Mohammed Sadiq Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 19 08:45:29 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 1p7Aq0-000A6C-Ve for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 19 Dec 2022 08:45:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7Apg-00074d-Mr; Mon, 19 Dec 2022 02:45:08 -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 1p7Apb-000740-Gs for bug-gnu-emacs@gnu.org; Mon, 19 Dec 2022 02:45:03 -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 1p7Apb-0005nG-8N for bug-gnu-emacs@gnu.org; Mon, 19 Dec 2022 02:45:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p7Apa-0001Z7-KC for bug-gnu-emacs@gnu.org; Mon, 19 Dec 2022 02:45:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Dec 2022 07:45: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.16714358665982 (code B ref 60176); Mon, 19 Dec 2022 07:45:02 +0000 Original-Received: (at 60176) by debbugs.gnu.org; 19 Dec 2022 07:44:26 +0000 Original-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 Original-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 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 1FA8AE000A; Mon, 19 Dec 2022 07:44:14 +0000 (UTC) In-Reply-To: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> (Mohammed Sadiq's message of "Sun, 18 Dec 2022 17:37:21 +0530") 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:251402 Archived-At: > 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)))