1

I have been struggling to get emacs CUA-mode working in the console where it works fine in X (in an xterm using emacs -nw).

The main features I want are shift-movement selection and ^C,^V,^X but any more would be helpful. So far I am using a local keyboard and monitor but ultimate goal is to get all this working over ssh using something like putty.

So far I have been working on getting my terminal to output the same control sequences that emacs expects to see for shift-movement (specifically S-<down> or <S-down>) and this works in the console when shift-select-mode is set in .emacs. So far so good, so I can shift select text from any emacs invocation type: X-windows, terminal ($TERM=linux or $TERM=xterm). This site has been very useful.

Shift-<down> displays as follows using cat -v and emacs happily maps <S-down> to this control sequence.

cat -v            (then type shift-down)
^[O2B

Here's the problem, switch on cua-mode and the shift-selection stops working but ^C,^V and ^X starts working !? So I can either have shift-selection or ^C,^V,^X but not both at the same time.

-------
Setup:
emacs 23
Raspberry Pi
Raspian (similar to Debian)
tashuhka
  • 5,028
  • 4
  • 45
  • 64
Richard
  • 11
  • 1
  • Does emacs insert the same thing when you type `C-q ` regardless of whether or not `cua-mode` is enabled? What does `C-u C-h c ` report in each state? – phils Mar 18 '14 at 11:02
  • Also, this may help: http://stackoverflow.com/questions/4351044/binding-m-up-m-down-in-emacs-23-1-1/4360658 – phils Mar 18 '14 at 11:08
  • Thanks phils, will try this but it will be 12 hours before I can try it. What is your theory of what is going on? – Richard Mar 18 '14 at 11:30
  • I don't have a theory, I'm afraid, and I'm not very familiar with cua-mode either, so I don't know why that would affect this. I'm just thinking that those results might be additional useful pieces of information. (I think they are most likely to produce identical pairs of results, but if they didn't then you'd have a reason for the difference.) – phils Mar 18 '14 at 13:14
  • @phils interesting experiment, was not aware emacs could do that so useful. cua-mode on/off made no difference but all states had a slightly different result. C-q in X GUI gave ^@, in xterm gave ^[[1;2A and console gave ^[O2B. C-u C-h c in X GUI gave: (translated from ) runs the command next-line whilst in xterm and console gave: runs the command next-line. Some differences to investigate but not sure I'm any closer to understanding what is happening. Thanks all the same. – Richard Mar 18 '14 at 22:22
  • From what Stefan says it certainly sounds as if upgrading Emacs is the way to go. As a general comment regarding those various escape sequences, be sure to look at the link in my earlier comment. If the escape sequences sent for `` and `` were different, then Emacs would be able to handle them differently, but you might need to use `input-decode-map` to tell it how to interpret them. Things will invariably vary between terminals. In particular, terminals typically have a rather limited set of allowable key sequences, so many sequences are not possible. – phils Mar 19 '14 at 02:42

1 Answers1

1

You might like to try a more recent version of Emacs, since cua-mode has been slowly changed to use the same code as shift-select-mode. In Emacs-24.4, cua-mode actually uses shift-select-mode directly.

Stefan
  • 27,908
  • 4
  • 53
  • 82
  • That's a good idea but I'm not sure how to do it. On my raspberrypi if I do: sudo apt-get upgrade emacs this informs me I'm up to date although obviously I realise version 23.4.1 is not up to date. I don't know how familiar you are with raspberry pi but it's an ARM processor and I don't know how easy it is to get later package versions than the default approach gives you. I'm not too familiar with how this works or what the platform limitations might me. – Richard Mar 18 '14 at 20:41
  • `apt-get install emacs24` should get you 24.3 if you have `testing` in your `sources.list` file. For 24.4 (not released yet), you'll need at least `emacs-snapshot` and I'm not sure how up to date it is. – Stefan Mar 19 '14 at 00:33
  • Looks like this.`pi@raspberrypi /etc/apt $ more sources.list deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi pi@raspberrypi /etc/apt $ ` – Richard Mar 19 '14 at 22:52