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, 09 Jan 2023 19:57:50 +0200 Message-ID: <83y1qboajl.fsf@gnu.org> References: <61db3ccacc2697d0b740315af495fca2@sadiqpk.org> <86359bhmfx.fsf@mail.linkov.net> <83o7rzeflc.fsf@gnu.org> <865ydf3dnf.fsf@mail.linkov.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2614"; 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 Jan 09 18:58:12 2023 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 1pEwPT-0000Tr-AD for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 09 Jan 2023 18:58:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEwPN-0008IR-1w; Mon, 09 Jan 2023 12:58:05 -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 1pEwPK-0008Hu-R1 for bug-gnu-emacs@gnu.org; Mon, 09 Jan 2023 12:58: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 1pEwPK-00083w-Fp for bug-gnu-emacs@gnu.org; Mon, 09 Jan 2023 12:58:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pEwPK-0004oC-Bi for bug-gnu-emacs@gnu.org; Mon, 09 Jan 2023 12:58:02 -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, 09 Jan 2023 17:58: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.167328706018455 (code B ref 60176); Mon, 09 Jan 2023 17:58:02 +0000 Original-Received: (at 60176) by debbugs.gnu.org; 9 Jan 2023 17:57:40 +0000 Original-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 Original-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 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 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==; 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 1pEwOi-0007kg-J3; Mon, 09 Jan 2023 12:57:30 -0500 In-Reply-To: <865ydf3dnf.fsf@mail.linkov.net> (message from Juri Linkov on Mon, 09 Jan 2023 19:30:20 +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:253037 Archived-At: > 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.