I've read the answers in Disable smart underscore for good ESS and ESS smart underscore does not work in emacs25 reasonably carefully and don't seem to be getting any of them to work. Maybe that's because the emacs/ESS ecosystem has changed, or maybe I'm just missing something.
Emacs version:
GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.30,
cairo version 1.16.0) of 2022-01-24, modified by Debian
and ESS 18.10.2.
When I open an R session and type _
I get the <-
(as expected) and a message:
‘ess-smart-S-assign’ is an obsolete command (as of ESS 18.10); use ‘ess-insert-assign’ instead.
(I don't know if this is a sign that I'm doing something wrong, or just a generic startup warning message).
There are a lot of recipes out there; I've tried adding
(setq ess-insert-assign nil)
, which doesn't appear to change the behavior.
I've tried
(add-hook 'ess-mode-hook
(define-key ess-r-mode-map "_" #'ess-insert-assign)
(define-key inferior-ess-r-mode-map "_" #'ess-insert-assign)
)
which similarly doesn't seem to work.
I am admittedly cargo culting my way through this, but if anyone has suggestions for recipes and/or diagnostics ...
I have also installed polymode
and poly-R
(in case that matters).
My entire .emacs
file, other than the attempts to tame the underscore, consists of
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages
'(default-text-scale poly-R polymode tabbar session pod-mode parsebib muttrc-mode mutt-alias markdown-mode magit initsplit htmlize graphviz-dot-mode folding ess eproject diminish csv-mode company color-theme-modern cmake-mode browse-kill-ring boxquote bm bar-cursor apache-mode))
'(safe-local-variable-values '((TeX-master . t) (ess-swv-processor . knitr)))