How to avoid ESS underscore automatic subsitution with '<-' when pasting text but keep it when writing an underscore
Asked Answered
K

1

7

When using ESS under emacs for writing R code, is useful to have the default behavior os having '_' substituted by '<-' (inserting two consecutive '_' would insert the underscore itself). But when pasting code to any buffer in ESS-mode, this substituion also happens and any '_' gets substituted by '<-' and this is not a desired behavior by me.

Is there a way of preventing the substitution only when pasting text?

At the moment I have fully disabled the substitution adding this code to my .emacs

(ess-toggle-underscore nil)

But I would like to recover the '_' to '<-' substitution only when writing not when pasting.

Any idea?

Kharif answered 16/12, 2012 at 16:48 Comment(6)
Underscore hasn't worked as an assignment operator since version 1.8.0, so ESS is "helping" you. Why not use = for assignment if you don't want to type <-?Checkbook
Can't reproduce this. If I put this_foo = 99 into a file, and copy and paste it into ESS, I get exactly that, assignment to a thing called this_foo. Doesn't matter if I copy/paste it with the mouse or the commands. What exactly are you doing?Burdick
if I paste 'this_and_that' it becomes 'this <- and <- that' (when ess-toggle-underscore set to true ). I am using emacs -nw, emacs is 23.3.1. How can I know the ESS version in use?Kharif
@PabloMarin-Garcia -- M-x ess-version <RET> will get the ESS version info for you.Mohenjodaro
How are you pasting? With the middle mouse button (Linux), Ctrl-V (windows), Ctrl-Y (emacs)? I've tested only on Linux with ESS 12.09. Perhaps this is best discussed on the ESS mailing list?Burdick
Just a guess: if you try doing this while running a GUI-ized version of emacs (ie., not emacs -nw from the terminal), it all "just works", yeah?Kimberliekimberlin
S
2

This should not happen. Please report a bug with more details to ess-help or with M-x ess-submit-bug-report. You are pasting in a terminal session right?

Sasser answered 16/12, 2012 at 22:57 Comment(4)
Not so sure it's a bug? If the OP is pasting text into a terminal, can the terminal (or emacs running it) know that it is actually being pasted in, vs. someone is typing über fast? I always just thought this was something one couldn't avoid.Kimberliekimberlin
@SteveLianoglou, for more than 10 years now I have been using emacs from the terminal (with emacs -nw) and now I find that using it from a GUI has an advantage. What other pros and cos are there between windows and terminal emacs mode?Guildsman
ergoemacs.org/emacs/emacs_gui_vs_terminal.html And another pro for the GUI: copy and paste of underscore from the clipboard works correctly!Guildsman
Now how do I work? I normally have two tabs in my terminal. One emacs, and the other a terminal for compiling. Now I have two switch between the GUI and a terminal. This disrupts my workflow.Guildsman

© 2022 - 2024 — McMap. All rights reserved.