From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#69191: 30.0.50; New var `major-mode-remap-defaults`, for packages Date: Wed, 21 Feb 2024 14:44:52 +0100 Message-ID: <875xyiext7.fsf@epfl.ch> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40594"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Stefan Monnier To: 69191@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 21 16:57:20 2024 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 1rcoyF-000ALr-01 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 21 Feb 2024 16:57:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcobI-0003Yx-6b; Wed, 21 Feb 2024 10:33:36 -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 1rcoZH-0000JR-IB for bug-gnu-emacs@gnu.org; Wed, 21 Feb 2024 10:31:31 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rcmuq-0002qi-5j for bug-gnu-emacs@gnu.org; Wed, 21 Feb 2024 08:45:42 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rcmvC-0000Nb-0Z for bug-gnu-emacs@gnu.org; Wed, 21 Feb 2024 08:46:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Feb 2024 13:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69191 X-GNU-PR-Package: emacs Original-Received: via spool by 69191-submit@debbugs.gnu.org id=B69191.17085231301416 (code B ref 69191); Wed, 21 Feb 2024 13:46:01 +0000 Original-Received: (at 69191) by debbugs.gnu.org; 21 Feb 2024 13:45:30 +0000 Original-Received: from localhost ([127.0.0.1]:48039 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcmuf-0000Ml-Ut for submit@debbugs.gnu.org; Wed, 21 Feb 2024 08:45:30 -0500 Original-Received: from mail-ej1-f47.google.com ([209.85.218.47]:40997) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcmua-0000MK-Aw for 69191@debbugs.gnu.org; Wed, 21 Feb 2024 08:45:28 -0500 Original-Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a27e7b70152so287203766b.0 for <69191@debbugs.gnu.org>; Wed, 21 Feb 2024 05:45:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708523094; x=1709127894; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=QuZOwxQN4hmRAx/vVXjLIlTQVznrEti7ZXKjtBbhbyM=; b=UTGitMnYubmknxy8V4QB5yObfBo1qk4IMUQWp2ECUswHJrp0O8B8Ow4qqx6/R2Yj+n PyL5x2g4w90Wz05t0ydsD3g7bF2Hczu3X9/efS9S21XOour2VgqDyQb5SZNjyLNY3W8X 8ektHw3aQdgvpN4km7vj5dtq5MHiXgHKYIgbqz+CuOWOKZrCWypwX+ZewvNZY2KoU/kV gxINc6+OGFqF98zZD1s6spwLeuhUXM+JLGw49BQ0XqiHKFW6vrkn4E6RFAJEwCcO6SS+ HwVL9Iah8w69XhPUzMknBM8lmixLSfA/9Xeild/GWCAKQADvsK0SDSZUUIitz+WyLtxc uLDg== X-Gm-Message-State: AOJu0YziC0Y8jaQXOsH3qAHEXCP/3l9OGn7C1Ja9dPC9Wj7++iDgjJeh 11MANHpWIShzu9Mq4sM6vea4AM2Q/WiHsd7D2oKz9T8AbCZgJendX2NyaqQs X-Google-Smtp-Source: AGHT+IHfX9vMQU4rY6oalByqj/kRvYDvnr3wpxKoxPTm036aHMpM+MvIB4oqA6xzToX/js8enoowzg== X-Received: by 2002:a17:906:30d1:b0:a3d:1457:147 with SMTP id b17-20020a17090630d100b00a3d14570147mr8486403ejb.1.1708523093927; Wed, 21 Feb 2024 05:44:53 -0800 (PST) Original-Received: from localhost ([2001:620:618:5c0:2:80b3:0:239]) by smtp.gmail.com with ESMTPSA id s5-20020a1709067b8500b00a3f63b267b0sm67008ejo.101.2024.02.21.05.44.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 05:44:53 -0800 (PST) In-Reply-To: (Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors"'s message of "Fri, 16 Feb 2024 10:45:13 -0500") 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:280398 Archived-At: Stefan Monnier [2024-02-16 10:45 -0500] wrote: > While `major-mode-remap-alist` provides a way for users to indicate the > major mode of their choice, I think we need a similar variable for the > use of packages. > > The package below accordingly adds a new `major-mode-remap-defaults` > and changes various packages to obey it or make use of it. > I think it nicely cleans the regexp duplication between CC-mode and > `c-ts-mode.el` and also makes it easier/cleaner for users to override > the changes made by `*-ts-mode.el`. SGTM. > There are some FIXMEs that one might want to address, most importantly > whether we should use an indirection through `major-mode-remap-defaults` > for all TS modes or only for those for which we provide a non-TS mode. My gut says: we shouldn't add out-of-tree modes (e.g. go-mode) to auto-mode-alist (they should and already do that themselves); and so long as TS modes are viewed as an optional alternative, then they should be responsible for setting up major-mode-remap-defaults (so it should be a no-op if they remap from an out-of-tree mode that is not installed). If/as TS modes become more canonical, perhaps the remapping should be bidirectional? > + (let ((mode > + (if (save-excursion > + (save-restriction > + (save-match-data ; Why `save-match-data'? > + (widen) > + (goto-char (point-min)) > + (re-search-forward c-ts-mode--c-or-c++-regexp nil t)))) > + 'c++-ts-mode) > + 'c-ts-mode)) I'm excited for this new let-syntax to catch on, but maybe as a separate feature request. > -;;;###autoload (defalias 'TeX-mode #'tex-mode) > -;;;###autoload (defalias 'plain-TeX-mode #'plain-tex-mode) > -;;;###autoload (defalias 'LaTeX-mode #'latex-mode) > +;;;###autoload (add-to-list 'major-mode-remap-defaults '(TeX-mode . tex-mode)) > +;;;###autoload (add-to-list 'major-mode-remap-defaults '(plain-TeX-mode . plain-tex-mode)) > +;;;###autoload (add-to-list 'major-mode-remap-defaults '(LaTeX-mode . latex-mode)) Can we really afford to lose the aliases in loaddefs.el? There are at least a few in-tree uses of the AUCTeX names. Thanks, -- Basil