-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bindings from latex layer are not available when editing latex files #16282
Comments
After digging into this more, the place for a deeper fix would be upstream and most likely in bind-map, but I'm not even sure it makes sense for it to try to compensate for major mode remapping. The simplest fix is probably to just tweak the |
The issue with UPDATE: upstream PR is now submitted |
See syl20bnr#16282 for discussion
See syl20bnr#16282 for discussion
See syl20bnr#16282 for discussion
Do the auctex changes affect also the local variables definition? EDIT: It seems that the
However, it is not read again when reopening the file later. May be it due to the fact that the mode is called |
@tigerjack the local variable
where there is a Your issue did make me realize that I had missed some keybinds in my PR, e.g., those dealing with reftex features (e.g., |
This is a bigger pain than I thought. When Configuring for both does kind of cover our bases, but it makes the code pretty ugly and duplicative. In addition, if Instead, I'm now of the opinion that it'd be cleaner for I've locally patched In related news, my fix to I'm going to leave this issue open and its associated PR in draft status for now, because if we can get |
This patch tries to make `bind-map` aware of two ways in which major modes can be remapped: via aliasing or via `major-mode-remap-alist`. The motivating scenario is AUCTeX, which as of version 14.0.1 has renamed several major modes, e.g., latex-mode has been renamed as LaTeX-mode. AUCTeX attempts to offer backwards compatibility using a mix of remapping and aliasing. For users of emacs < 29, `latex-mode` is redefined as an alias for `LaTeX-mode`, whereas for users of emacs 29+, `latex-mode` is remapped to `LaTeX-mode` using `major-mode-remap-alist`. However, if a user had configured keymaps for `latex-mode` using `bind-map`, they will not be available in `LaTeX-mode`. This is especially problematic for distributions like `spacemacs` which need to support users of both old and new AUCTeX (see syl20bnr/spacemacs#16282 for more discussion). This patch introduces two new customizable options, `bind-map-use-remapped-modes` and `bind-map-use-aliased-modes`. Both options default to `t`, in which case when `bind-map` is deciding whether to activate a given keymap, it will compare the value of `major-mode` to not only the symbol for which the keymap was configured configured (e.g., `latex-mode`), but any remapped or aliased modes (e.g., `'(latex-mode LaTeX-mode)`. This logic is implemented in the new (private) function `bind-map--lookup-major-modes` to facilitate lookup of applicable major-modes on the fly. As a result, if a user adjusts `major-mode-remap-alist` or adjusts aliased, `bind-map`'s behavior will change accordingly.
This patch tries to make `bind-map` aware of two ways in which major modes can be remapped: via aliasing or via `major-mode-remap-alist`. The motivating scenario is AUCTeX, which as of version 14.0.1 has renamed several major modes, e.g., latex-mode has been renamed as LaTeX-mode. AUCTeX attempts to offer backwards compatibility using a mix of remapping and aliasing. For users of emacs < 29, `latex-mode` is redefined as an alias for `LaTeX-mode`, whereas for users of emacs 29+, `latex-mode` is remapped to `LaTeX-mode` using `major-mode-remap-alist`. However, if a user had configured keymaps for `latex-mode` using `bind-map`, they will not be available in `LaTeX-mode`. This is especially problematic for distributions like `spacemacs` which need to support users of both old and new AUCTeX (see syl20bnr/spacemacs#16282 for more discussion). This patch introduces two new customizable options, `bind-map-use-remapped-modes` and `bind-map-use-aliased-modes`. Both options default to `t`, in which case when `bind-map` is deciding whether to activate a given keymap, it will compare the value of `major-mode` to not only the symbol for which the keymap was configured configured (e.g., `latex-mode`), but any remapped or aliased modes (e.g., `'(latex-mode LaTeX-mode)`. This logic is implemented in the new (private) function `bind-map--lookup-major-modes` to facilitate lookup of applicable major-modes on the fly. As a result, if a user adjusts `major-mode-remap-alist` or adjusts aliased, `bind-map`'s behavior will change accordingly.
I have opened a PR against |
This patch tries to make `bind-map` aware of two ways in which major modes can be remapped: via aliasing or via `major-mode-remap-alist`. The motivating scenario is AUCTeX, which as of version 14.0.1 has renamed several major modes, e.g., latex-mode has been renamed as LaTeX-mode. AUCTeX attempts to offer backwards compatibility using a mix of remapping and aliasing. For users of emacs < 29, `latex-mode` is redefined as an alias for `LaTeX-mode`, whereas for users of emacs 29+, `latex-mode` is remapped to `LaTeX-mode` using `major-mode-remap-alist`. However, if a user had configured keymaps for `latex-mode` using `bind-map`, they will not be available in `LaTeX-mode`. This is especially problematic for distributions like `spacemacs` which need to support users of both old and new AUCTeX (see syl20bnr/spacemacs#16282 for more discussion). This patch introduces two new customizable options, `bind-map-use-remapped-modes` and `bind-map-use-aliased-modes`. Both options default to `t`, in which case when `bind-map` is deciding whether to activate a given keymap, it will compare the value of `major-mode` to not only the symbol for which the keymap was configured configured (e.g., `latex-mode`), but any remapped or aliased modes (e.g., `'(latex-mode LaTeX-mode)`. This logic is implemented in the new (private) function `bind-map--lookup-major-modes` to facilitate lookup of applicable major-modes on the fly. As a result, if a user adjusts `major-mode-remap-alist` or adjusts aliased, `bind-map`'s behavior will change accordingly.
I am not sure of what's happening behind the scenes to be honest. It seems that some files are opened in When I try to force the activation of the On the other hand, if I do a I am still unsure if the behaviour is related to the auctex update, but I did not have this issue before. If you need some testing, I will be glad to help. |
@tigerjack I suspect the issue is with the way your major-modes are getting specified. If I understand correctly, in the new version of AUCTeX, TeX-mode isn't really a mode you should ever be in explicitly. From the "Changes" section of the AUCTeX manual:
Can you confirm which version of My understanding of the way AUCTeX handles mode mapping (with new AUCTeX and emacs 29+) is as follows.
When you somehow land in |
Is there a quick fix for this issue at the moment? |
@James-Hanson asks:
One hack is to (painstakingly) duplicate the logic for I have "fixed" this for myself locally by using the version of You can accomplish this by adding this entry to
After restarting emacs, if you update packages with I frequently use this approach (of telling Unfortunately, the renaming of PS: the EDIT: added quotes around the repo name; thanks @jajpater for catching that |
Its value is "14.0.2"
I suspect it was related to a failure of the undo-tree history (a similar error is reported here). Despite that, even if I force the LaTeX-mode, the |
Upon further investigation, the problem seems to be related to this line of my configuration file (add-hook 'LaTeX-mode-hook #'latex-extra-mode) So I think it's a bug of the EDIT: I fixed this error here Malabarba/latex-extra#38 |
@dankessler @James-Hanson File variableInside the
Directory variableCreate a ((latex-mode
(mode . LaTeX ))) |
@tigerjack glad you got it sorted out and were able to submit a fix upstream |
@tigerjack I'm a little surprised that this works for you, because I would expect that after the mode becomes |
@dankessler I honestly don't know what is the sequence of instructions that leads to this behaviour. What I can add, that maybe can help you in debugging the issue, is
Let me know if I can help in any other way. |
@dankessler thanks a lot for your |
Also a big thanks from me. It indeed fixes the issue for me. I had to add quotation marks to the repo part:
|
@dankessler Thank you for the help,
I realized I was trying to do this with Emacs 28.2. I built 29.2 and was able to get it to work. Thanks again. |
@James-Hanson thanks for letting me know and for sharing this update. I thought my fix would work for emacs 28, too, so I may take a slightly closer look to see if I can adjust the patch accordingly. |
@jajpater thanks for noticing that! For whatever reason, it works for me without quotes, but it looks like surrounding with quotes is indeed the idiomatic way to specify recipes. I'll updated my earlier comment to use quotes for anyone who is copy-pasting it. |
I am coming back on this again. In my case, while the |
Just here to say that I am expriencing this issue with
I worked around it by downgrading AUCTeX to 13.3.0, which is obviously not a fix, but I depend too much on it. Regards. |
My PR to It sounds like some people (@tigerjack) are having different, but likely closely-related, issues with the newest version of AUCTeX. I'd suggest that we close this issue and open a fresh one to track any of those specific problems. Also, I'd suggest people remove this hack from their config:
restart emacs, and then update packages to grab the latest version of bind-map which has this change integrated. You'll then continue to get any new updates from the upstream |
Can you explain how you downgraded AUCTeX? |
Even though I do not find any latex-related change in the latest emacs version (29.3), the upgrade nonetheless fixed all my problems when used with auctex 14.0.3.2024-03-17 |
In brief, this is because However, AFAIK, |
@dankessler yes, I was on board with all these problems on 29.2 :) However, I was still experiencing strange behaviour that you couldn't reproduce (as an example, Today's upgrade to emacs 29.3 fixed those strange behaviours as far as I can tell; maybe it was simply due to a recompilation of all the packages?!. On the other hand, opening |
Good; sorry for over-explaining :)
Interesting! I'm on emacs 29.1 and not encountering any issues, but glad that upgrading to 29.3 fixed things for you! |
A tex file uses |
I never used this shortcut, and I don't have it in my key bindings. What is the command executed? |
|
@zzjjzzgggg which is an Ivy command. I never used it, nor it. But in theory, you should be able to use |
I have worked a bit with my latex layer and it seems that with the many fixes from @dankessler this issue is obsolete now. If you run into other strange behaviors please open a new issue for them and I am sure folks will have a look at it. |
With Emacs 30, this problem appears again due to the introduction of |
Description
Even with the
latex
layer enabled, when editinglatex
files (that end in.tex
) none of the major mode bindings are available and alsolsp
falls down.Reproduction guide 🪲
.tex
SPC m
Observed behaviour: 👀 💔
RE key bindings, observe this in minibuffer
RE LSP: this message appears (after visiting a
.tex
file)Expected behaviour: ❤️ 😄
which-key
pop-up showing the many useful commands I can run when editing a latex file.Also, I expect lsp support to work (since I have
texlab
installed)System Info 💻
Explanation
This seems to be a consequence of recent changes in AUCTeX (that are live in the version on ELPA) and explained in the AUCTeX documentation.
In brief, AUCTeX has changed conventions for its major mode names. Whereas previously its modes had names like
{tex,latex}-mode
, it now names its major modes like{TeX,LaTeX}-mode
. It then makes use of emacs 29.1+'smajor-mode-remap-alist
so that e.g., activatinglatex-mode
will instead callLaTeX-mode
.However, spacemacs sets up its bindings using
spacemacs/set-leader-keys-for-major-mode
. The key binding setup forlatex
is in thelatex
layer'spackages.el
file, but it refers to these modes like{tex,latex}-mode
. So, it does all of its configuration in thespacemacs-latex-mode-map
, but I suspect that when I open a.tex
file, due to the remapping it's now looking for aspacemacs-LaTeX-mode-map
that does not exist.This could be fixed quickly by just updating the case used when referring to major mode's throughout the
latex
layer'spackages.el
file.A deeper fix would involve adjusting either
spacemacs/set-leader-keys-for-major-mode
or the way spacecmacs loads keymaps to be aware ofmajor-mode-remap-alist
.The text was updated successfully, but these errors were encountered: