2

I'm using terminal.app on OS X, and when typing in emacs I often want to copy the text and paste it into some other program. When I do, I find that copied text has some spaces unexpectedly replaced by tabs.

I assume I'm copying the text that emacs has sent to the terminal which I suppose doesn't have to match the actual document, but what's the right way to do this?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Jon Hess
  • 141
  • 2

1 Answers1

4

If the buffer doesn't actually contain tabs, then you can use the Mac utility pbcopy to copy its contents into the cut buffer.

  1. Set a region with mark and point around the text you want to copy.
  2. Run shell-command-on-region, normally bound to M-| .
  3. Type pbcopy Return.

The contents of the region are now in the cut buffer and you can paste them normally. I would roll the last two steps into some Lisp to save typing. Put this code in .emacs

(defun copy-region-to-cut-buffer (beg end)
  (interactive "r")
  (call-process-region beg end "pbcopy"))

and bind the new command to a key of your choice.

Kyle Jones
  • 14,845
  • 3
  • 40
  • 51