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?

Pablo Marin-Garcia
  • 4,151
  • 2
  • 32
  • 50
  • 1
    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 `<-`? – Matthew Lundberg Dec 16 '12 at 17:04
  • 2
    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? – Spacedman Dec 16 '12 at 17:24
  • 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? – Pablo Marin-Garcia Dec 16 '12 at 18:38
  • 1
    @PabloMarin-Garcia -- `M-x ess-version ` will get the ESS version info for you. – Josh O'Brien Dec 16 '12 at 19:47
  • 1
    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? – Spacedman Dec 16 '12 at 19:51
  • 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? – Steve Lianoglou Dec 17 '12 at 17:39

1 Answers1

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?

VitoshKa
  • 8,387
  • 3
  • 35
  • 59
  • 1
    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. – Steve Lianoglou Dec 17 '12 at 17:41
  • @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? – Z boson May 31 '17 at 14:18
  • http://ergoemacs.org/emacs/emacs_gui_vs_terminal.html And another pro for the GUI: copy and paste of underscore from the clipboard works correctly! – Z boson May 31 '17 at 14:22
  • 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. – Z boson May 31 '17 at 14:23