I am unable to yank text into a terminal running in Emacs.
This is my procedure:
I killed the string "date" from one buffer and yanked it into the terminal in another buffer and hit return.
The terminal behaves as if I typed nothing. It just returns the prompt back.
I am using OS X 10.5.8 and Emacs 23.1. I have tried this procedure on Aquamacs, Carbon Emacs, and the release from http://emacsformacosx.com/. They all show this weird behaviour even in their default configurations with my .emacs file empty. What could possibly be causing this?
Ctrl-y - This command will yank back the text which was deleted most recently with the above command. The text will be placed at the current emacs cursor location. You can yank back the text as many times as you wish. Meta-y - When you kill or copy a region of text, it doesn't forget about previous kills.
When you copy and paste text, the terminal does it : you're taking the text that the terminal displays and not the text that is in your emacs app. That's why you have to use terminal keybindings : Ctrl-Shift-C and Ctrl-Shift-V to copy and paste text.
Copying in EmacsCopying can be achieved by doing a cut (kill) followed either by an undo (C-x u) or by a yank (paste) (C-y), or by selecting text (either with mouse or keyboard) then doing kill-ring-save (M-w).
An Emacs copy is the command kill-ring-save (usually bound to M-w ). A system copy is what you typically get from pressing C-c (or choosing "Edit->Copy" in a application window). An X copy is "physically" highlighting text with the mouse cursor. An Emacs paste is the command yank (usually bound to C-y ).
By "in a terminal" I assume you mean you're running Emacs's built-in terminal emulator. Ordinarily, the terminal emulator transmits most keys exactly as typed to the shell process. Type C-c C-j in the terminal buffer to put it into a state where ordinary Emacs key bindings are available. You'll see the mode line change from (Term: char run)
to (Term: line run)
.
Addendum:
Yanking text without leaving char mode is a little tricky; the relevant function, however, is term-paste
(not yank
, which merely inserts the text into the terminal buffer without sending it to the inferior process). term-paste
will immediately send the most recent kill to the inferior process, but doesn't provide the fancy yank functionality you're probably used to (like M-y to cycle through prior kills). You could run term-paste
as an extended command: C-c M-x term-paste RET.
Probably the easiest solution is just to temporarily go into line mode (C-c C-j) when you have something to paste, and then immediately go back into char mode (C-c C-k). Or even easier, just stay in line mode all the time. I often do this when I have a terminal logged into an Oracle SQL*Plus session. I rarely notice the difference, but I get all sorts of convenient Emacs functionality, like being able to type M-p to cycle through a long, previously-typed SQL statement.
I would have assumed that you could always start off in line mode like this:
(add-hook 'term-mode-hook 'term-line-mode)
...but it doesn't work for me. Don't know why.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With