11

I'm on a Macintosh and am using "terminal" for my shell. When I copy text from any window (via mouse drag then right mouse button menu -> copy) and then I paste the text (right mouse button -> paste) into a terminal with emacs running, it doesn't act as a paste. Instead, it is just like entering or typing in text. The problem occurs when the text is indented. Emacs does its auto-indentation on top of that so I get a cascading staircase-like look of text. I just want it to be a true "paste" so that whatever was copied shows up exactly as it was. Any ideas on how to change something to get this to work?

1
  • I'm not sure how you expect this to work. A text terminal doesn't have a "paste". Terminal.app implements paste by typing in all the characters on the clipboard. If you want paste to work differently, don't run programs in a text terminal. Commented Oct 18, 2010 at 14:40

2 Answers 2

18

Try this:

(defun pt-pbpaste () "Paste data from pasteboard." (interactive) (shell-command-on-region (point) (if mark-active (mark) (point)) "pbpaste" nil t)) (defun pt-pbcopy () "Copy region to pasteboard." (interactive) (print (mark)) (when mark-active (shell-command-on-region (point) (mark) "pbcopy") (kill-buffer "*Shell Command Output*"))) (global-set-key [?\C-x ?\C-y] 'pt-pbpaste) (global-set-key [?\C-x ?\M-w] 'pt-pbcopy) 

Use C-x C-y to paste and C-x M-w to copy.

Sign up to request clarification or add additional context in comments.

1 Comment

Does C stand for "Control or Ctrl" key in the keyboard here?
2

For a quick and dirty solution which doesn't require configuring custom commands, you can run shell-command with a prefix argument to insert the results of calling pbpaste into the current buffer.

Thus:

C-u M-! pbpaste <RET> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.