GNU bug report logs - #69191
30.0.50; New var `major-mode-remap-defaults`, for packages

Previous Next

Package: emacs;

Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>

Date: Sun, 18 Feb 2024 18:22:04 UTC

Severity: normal

Found in version 30.0.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 69191 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <basil <at> contovou.net>
To: 69191 <at> debbugs.gnu.org
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#69191: 30.0.50; New var `major-mode-remap-defaults`, for
 packages
Date: Wed, 21 Feb 2024 14:44:52 +0100
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




This bug report was last modified 1 year and 77 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.