2

I'm running OSX 10.6.8. Lets say I have two terminal windows open and in each window I begin editing a different file using emacs. In the first file I select some text and then copy it (M-w), and in the second file I then try and paste it (C-y). I thought this would paste what I copied from the other file but instead I get the error message "previous command was not a yank".

Those commands work just fine for copying and pasting within a single file, how do I copy and paste between different files?

2 Answers 2

3

As far as I know, emacs has no idea that a completely different instance of emacs is running in a separate Terminal.app window. You need to use the Mac's Cmd-C and Cmd-V.

I could be wrong, perhaps emacs can be set up to use some form of IPC to find other separate running instances of emacs and try to share things like clipboards between them, but that seems unusual.See @IvanAndrus' Answer for how to use emacsclient to have emacs instances work together.

If you want emacs in separate GUI windows, you might also look at Aquamacs.

Updated to add: You could also learn to use emacs' native ability to edit multiple files/buffers within the same instance: http://www.gnu.org/software/emacs/manual/html_node/emacs/Buffers.html

3
  • 2
    You can (and should) use emacsclient if you want to use emacs in another terminal window. Then you'll be running the same emacs session in both terminals and copy/paste will work correctly. Mar 23, 2012 at 8:57
  • 1
    @IvanAndrus Please post that as an Answer. I might keep my Answer up to give people other options to consider, but I think your answer is more in the spirit of what JStarx was trying to do.
    – Spiff
    Mar 23, 2012 at 9:01
  • It was what I was trying to do, but I wasn't aware I could open more than one file! Thanx.
    – Jim
    Mar 23, 2012 at 21:09
2

You can (and should) use emacsclient if you want to use emacs in another terminal window (or even on a remote server). Then you'll be running the same emacs session in both terminals and copy/paste will work correctly. You can also combine this with GUI sessions. You do have to start the server in your .emacs file.

On this EmacsWiki page there are many examples of how to write scripts which will start an Emacs session if one isn't already running or connect to it if it's started. You may also want to try running Emacs as a daemon so that Emacs will keep running even though you have disconnected all your terminals.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.