How to stop emacs from replacing underbar with <- in ess-mode

0 votes
asked Mar 27, 2010 by setjmp

ess-mode is "Emacs speaks statistics." This mode is useful for editing programs for R or Splus (two separate statistics packages).

In my buffer, when ever I type _ the character is replaced with <-, which is very frustrating. Is there an emacs lisp statement to turn off this behavior?

emacs: 22.1.1 ess-mode release (unknown)

3 Answers

0 votes
answered Mar 12, 2014 by wmash

From and How to change smart assign key ("_" to "<-") binding in ESS

To assign ":" to "<-" and to stop the assignment of underscore (underbar) "_" to "<-" put the following in .emacs (yes, the repeated line is correct)

(setq ess-smart-S-assign-key ":")
(ess-toggle-S-assign nil)
(ess-toggle-S-assign nil)
(ess-toggle-underscore nil) ; leave underscore key alone!
0 votes
answered Jan 29, 2015 by kushdesh

Since the feature is useful. You can assign it to other key which is less used by you in R it will automatically unassign it from underscore. I personally assign it to ";" by adding following line in .emacs file.

(setq ess-smart-S-assign-key ";")

My version of emacs is 24.3 All-in-one installation file by Vincent Goulet.(Installed on windows 7)

hope this helps

Edit In emacs 25.2 above do not work instead add following in the .emacs file

(setq ess-smart-S-assign-key ";")
(ess-toggle-S-assign nil)
(ess-toggle-S-assign nil)
0 votes
answered Sep 15, 2017 by drummermean

A more recent version which seemed to work for me, and is a lot less verbose (you essentially keep normal underscores, but can set your own key for this smart behaviour!):

(global-set-key (kbd "C-;")  (lambda () (interactive) (insert " <- ")))
(ess-toggle-underscore nil)

Insert your shortkey choice instead of C-;.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter