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?

1
  • I'm also curious as to why this happens.
    – Jon Hess
    Mar 6, 2014 at 22:48

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .