Search code examples
macosemacsemacs23

Emacs 23 on OS X - use multiple instances or emacsclient?


I wonder if anyone has any recommendations as to setup of emacs 23 on OS X. I have been using Linux/Windows for a while and there, I would just open many instances of emacs and they were self-contained - for instance, I could have two separate files in separate frames, each with their own R, Python, and/or shell running. I think this is frowned upon(?) - but it kept the working directory for each script file separate, which I loved.

I understand there is some advantage to setting (server-start) in my .emacs file and calling 'emacsclient' rather than 'Emacs' is now the preferred way(?). I found this thread which facilitates this to occur through an Applescript: Emacs 23, OS X, multi-tty and emacsclient

But I wonder if this the only way to go about it - when I open two emacs instances on OS X it gives me the error:

** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x3803, name = 'org.gnu.Emacs.ServiceProvider'

but opens a new frame allows me to edit files. I understand that for vim on OS X there is something called 'mvim' which allows multiple instances of vim to be launched, but is there something similar for emacs? Sorry for the long-winded question - in summary, I guess these are the questions for which I would like to solicit your expertise:

(1) Is 'emacsclient' the way of the experts, and (2) if not necessarily, is there a way to get multiple instances of emacs 23 (not just frames) running on OS X?

Thanks!


Solution

  • Let me answer your questions indirectly.

    As you know, emacsclient provides a service, allowing users to open documents from outside Emacs in an existing Emacs. Is this "the way" of the experts? Depends on the expert. I'm a heavy user of Emacs, but never use emacsclient. Why? Because I never leave Emacs in the first place. All the shells I run are inside Emacs (using a home-brewed screen package), I read mail in Emacs, etc. There's never a reason for me to type emacsclient at a command line.

    Your usage model seems to be that you prefer having multiple Emacsen running, making it easier to keep track of which processes and files are being used together. And that makes sense. You could do it all in one Emacs if you wish, but it might take some changes in your usage model, or some customizations to help manage multiple interpreters/shells/whatever to your liking.

    So, if you like multiple instances of Emacs running, then by all means, continue doing so.

    Regarding the second question, it appears as though having (server-start) in your .emacs is causing problems - likely because there's a conflict with two Emacsen trying to use the same port. Check out the documentation for starting the server, and perhaps remove that line from your .emacs, and instead start the server once by using the --daemon command line option.

    Then, at the command line, you have the choice of whether you want to start a new emacs (by typing emacs) or connect to the server you started (by typing emacsclient).