From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Make all tree-sitter modes optional Date: Tue, 14 Feb 2023 21:02:25 +0000 Message-ID: References: <84973.1672843723@hassadar.pretzelnet.org> <83wn62xi3k.fsf@gnu.org> <83o7rexe2n.fsf@gnu.org> <83h6x5xym7.fsf@gnu.org> <83h6wr6gmz.fsf@gnu.org> <868ri140sr.fsf@mail.linkov.net> <83fsc92gbz.fsf@gnu.org> <83cz6ccagy.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2493"; mail-complaints-to="usenet@ciao.gmane.io" Cc: juri@linkov.net, casouri@gmail.com, monnier@iro.umontreal.ca, larsi@gnus.org, theo@thornhill.no, jostein@secure.kjonigsen.net, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Feb 14 22:03:25 2023 Return-path: Envelope-to: ged-emacs-devel@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 1pS2SS-0000NC-Ud for ged-emacs-devel@m.gmane-mx.org; Tue, 14 Feb 2023 22:03:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pS2Rh-0001Cg-LQ; Tue, 14 Feb 2023 16:02:37 -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 1pS2Rf-0001CB-64 for emacs-devel@gnu.org; Tue, 14 Feb 2023 16:02:35 -0500 Original-Received: from mx3.muc.de ([193.149.48.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pS2RZ-0005gP-Ml for emacs-devel@gnu.org; Tue, 14 Feb 2023 16:02:34 -0500 Original-Received: (qmail 21007 invoked by uid 3782); 14 Feb 2023 22:02:26 +0100 Original-Received: from acm.muc.de (pd953a83b.dip0.t-ipconnect.de [217.83.168.59]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 14 Feb 2023 22:02:26 +0100 Original-Received: (qmail 10036 invoked by uid 1000); 14 Feb 2023 21:02:25 -0000 Content-Disposition: inline In-Reply-To: <83cz6ccagy.fsf@gnu.org> X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.5; envelope-from=acm@muc.de; helo=mx3.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:303291 Archived-At: Hello, Eli. On Tue, Feb 14, 2023 at 21:29:01 +0200, Eli Zaretskii wrote: > > Date: Tue, 14 Feb 2023 19:08:42 +0000 > > Cc: Juri Linkov , casouri@gmail.com, > > monnier@iro.umontreal.ca, larsi@gnus.org, theo@thornhill.no, > > jostein@secure.kjonigsen.net, emacs-devel@gnu.org > > From: Alan Mackenzie [ .... ] > > No, it is not adequate. It is horrible. > Not a very kind remark, to say the least. Sorry, I should have written "It is horrible for me." - which is true. > > How about commands c-make-ts-default-mode and c-make-ts-undefault-mode > I'm okay with adding the latter, if it turns out easy enough and safe > enough (of which I'm not sure at all), and if such a command will be > implemented for all the *-ts-modes which have non-ts siblings, but I > see no reason for the former, since there are several simple ways to > cause the same effect, and they are all documented in NEWS. OK, Try this (so far only on c-ts-mode.): diff --git a/etc/NEWS b/etc/NEWS index 2d15e39036a..0a745d7cde9 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -3239,10 +3239,13 @@ for which a "built-in" mode would be turned on. For example: (add-to-list 'major-mode-remap-alist '(ruby-mode . ruby-ts-mode)) -If you try these modes and don't like them, you can go back to the -"built-in" modes by restarting Emacs. But please tell us why you -didn't like the tree-sitter based modes, so that we could try -improving them. +Normally, the loading of one of the new modes amends 'auto-mode-alist' +such that future visiting of the same type of file will continue to +use that new mode. If this is not what you want, do M-x +-make-ts-undefault-mode. For a more permanent effect, put, for +example, the following into your initialization file: + + (eval-after-load 'c-ts-mode '(c-make-ts-undefault-mode)) Each major mode based on tree-sitter needs a language grammar library, usually named "libtree-sitter-LANG.so" ("libtree-sitter-LANG.dll" on diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 5093c3980b6..d6ea95a2980 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -904,6 +904,20 @@ c-or-c++-ts-mode (treesit-ready-p 'c)) (add-to-list 'auto-mode-alist '("\\.h\\'" . c-or-c++-ts-mode))) +(defun c-make-ts-undefault-mode () + "Make the older C and C++ Modes the default major modes for C(++) files." + (interactive) + (setq auto-mode-alist (delete '("\\.h\\'" . c-or-c++-ts-mode) + auto-mode-alist)) + (setq auto-mode-alist + (delete '("\\(\\.[chi]\\|\\.lex\\|\\.y\\(acc\\)?\\|\\.x[bp]m\\)\\'" . c-ts-mode) + auto-mode-alist)) + (setq auto-mode-alist + (delete + '("\\(\\.ii\\|\\.\\(CC?\\|HH?\\)\\|\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\|\\.\\(cc\\|hh\\)\\)\\'" + . c++-ts-mode) + auto-mode-alist))) + (provide 'c-ts-mode) ;;; c-ts-mode.el ends here [ .... ] > I think you have a very simplistic idea of what loading a *-ts-mode > does, but if you can come up with a simple and safe implementation, I > won't object adding such a command -- it cannot do any harm by just > being there, and if it turns to be not what users want, we can always > advise them not to use it. [ .... ] > > Either of these would allow the user to try out the new modes freely > > without being coerced against their will to use the new -ts- modes. > "Try out" is not what I had in mind for users who'd like to use these > modes. Some will want to try them out first, before definitively committing to them. I am such a user. [ .... ] > Then they [proposed amendments] aren't "reasonable" at this time. > Maybe later, maybe on master. That will be too late, the damage will have been done. It is the first experience people have of the new modes which will create their long term impressions of them. I remember something similar happening in Emacs 21.1, when the new fringes were not made optional. Lots of users complained loudly and bitterly. > As I said several times, we have no good idea yet how users will react > to what we have. Maybe, after we hear from them, we decide to > implement such switches, who knows. We are ourselves all users, too. We know how we have reacted, and it is reasonable to try to prevent bad experiences for users similar to ourselves. [ .... ] -- Alan Mackenzie (Nuremberg, Germany).