syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.56k stars 4.9k forks source link

fix inferior R mode #16364

Closed gdkrmr closed 2 months ago

gdkrmr commented 2 months ago

R and related modes (R markdown, quarto mode, ...) were broken because spacemacs tried to assign a keybinding to inferior-ess-r-mode-map, which doesn't exist. I have done a quick fix by removing the assignment. In the R repl you cannot type <- by pressing M-- any more, in a .R file it still works.

dankessler commented 2 months ago

Thanks for this quick fix! I came across the same bug and before I noticed your PR, did a deep dive myself that led to a separate PR (#16366).

In brief, the issue is not that inferior-ess-r-mode-map doesn't exist in general (it is defined in ess-r-mode.el), the problem is that it doesn't exist when spacemacs/ess-bind-keys-for-inferior is called.

Currently, spacemacs/ess-bind-keys-for-inferior is called from within an :init block for ess-site here:

    (with-eval-after-load 'ess-inf
      (spacemacs/ess-bind-keys-for-inferior))

However, ess-site is (implicitly) deferred, so it does not get loaded at startup. At some point, when the user tries to edit an R file (or does most things ess-related), the autoload system will cause ess-inf.el to get loaded, which will fire off this code, but this can happen before ess-r-mode has been loaded.

gdkrmr commented 2 months ago

Nice! Thanks for taking the time and doing it right! Your PR should be merged.