From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#60176: 29.0.60; Fallback file variable mode if treesitter is not usable Date: Mon, 19 Dec 2022 14:35:27 +0200 Message-ID: <83o7rzeflc.fsf@gnu.org> References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12550"; mail-complaints-to="usenet@ciao.gmane.io" Cc: sadiq@sadiqpk.org, monnier@iro.umontreal.ca, 60176@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 19 13:42:11 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 1p7FT8-0002zf-J9 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 19 Dec 2022 13:42:10 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7FNL-0005lB-3N; Mon, 19 Dec 2022 07:36: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 1p7FND-0005fL-GI for bug-gnu-emacs@gnu.org; Mon, 19 Dec 2022 07:36:05 -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 1p7FNB-00016y-RM for bug-gnu-emacs@gnu.org; Mon, 19 Dec 2022 07:36:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p7FNB-0001kO-Mu for bug-gnu-emacs@gnu.org; Mon, 19 Dec 2022 07:36:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Dec 2022 12:36:01 +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.16714533266706 (code B ref 60176); Mon, 19 Dec 2022 12:36:01 +0000 Original-Received: (at 60176) by debbugs.gnu.org; 19 Dec 2022 12:35:26 +0000 Original-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 Original-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 Original-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==; Original-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 In-Reply-To: <86359bhmfx.fsf@mail.linkov.net> (message from Juri Linkov on Mon, 19 Dec 2022 09:39:14 +0200) 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:251417 Archived-At: > 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.