4

I am using the railwaycat brew install version of emacs.

24.5.1

I have the following alias in my .bashrc:

alias edit="emacsclient -a '' -nw"

I also have $EDITOR set to the same command.

If I run edit in a terminal before I open the gui version, it starts a daemon in the background, and opens emacs in the terminal, which is what I want.

However, if I run the GUI version of emacs first, and then type edit in the terminal, it opens a new frame, which is NOT what I want.

How can I get it to always open the terminal version in the terminal?

  • That is a known and documented limitation of the mac port. Please, do read documentation. – lunaryorn Nov 30 '15 at 19:49
  • 2
    Honestly, the documentation could use some work. Since I have no idea what multi-tty with GUI means, the documentation wouldn't have helped, but, I admit, I did not look for it. – synic Nov 30 '15 at 22:44
  • 1
    I'm an experienced Emacs user (though not a programmer), and I also didn't know what that meant. (And ran into the same issue.) – incandescentman Dec 4 '15 at 7:51
  • Just for the record -- this works in the official Emacs for OS X (known as the "ns" port, rather than the "mac" port). You can download it from www.emacsforosx.com – Lindydancer Mar 23 '16 at 6:07
7

This behaviour is actually a known and documented limitation of this port, see README-mac (emphasis mine):

The Mac port doesn't support multi-tty with GUI. The developer has no idea how to detach Emacs as a GUI application from Window Server or Dock without separating a GUI process (not thread) from the main Emacs (Lisp evaluator) process. TTY-only multi-tty is supposed to work.

In other words, it's impossible to attach a client TTY frame to a server running in a GUI frame.


You can run two different server instances, though, one for the GUI and another for TTY, by setting server-name accordingly, i.e.

(setq server-name "gui-server")
(server-start)

You have to explicitly give the socket file name to emacsclient now:

$ emacsclient -f "$TMPDIR/emacs-$(id -i)/gui-server …

Both instances will not be able to share any state at all, though, and they'll potentially override each other's state and history in ~/.emacs.d.

In other words, both have separate buffer lists, undo history, save place history, etc., the instance which exists lasts wins for all files in ~/.emacs.d (i.e. save place history, minibuffer history, projectile project list, etc.) unless you give each data file a unique name, and if you save custom variables in one instance and then in the other, the values from the first instance are lost.

Emacs is really not made two run independently in two long-running separate interactive instances.


Finally, please don't refer to it as “railwaycat” port. This variant of Emacs is actually maintained by Yamamoto Mitsuharu; the Github account railwaycat just maintains the Homebrew formula and keeps a Git mirror. “railwaycat port” doesn't really give proper attribution.

  • 1
    I wasn't aware that I used the word port at all, but I'm sorry if I offended someone. What I typed gives you a pretty good idea of what version I'm using, though. – synic Nov 30 '15 at 22:37
  • Is it possible to run two separate instances? I've unchecked this answer, as it doesn't actually answer my question. – synic Dec 1 '15 at 16:03
  • @synic Sure, but that's not particularly convenient. I've edited my answer accordingly. – lunaryorn Dec 1 '15 at 17:01
  • Will this issue ever be resolved? Is there a version of Emacs for OSX that has the pixel scrolling and improved font display of Emacs-Mac-Port, but would still allow me to run in daemon mode? My goal is to be able to quit out of GUI Emacs, but still have Emacs running in the background so that startup is instant. – incandescentman Dec 4 '15 at 7:56
  • 1
    @incandescentman That Is mit a question which anyone here can answer. You need to ask the maintainer of that port. As for font display, though, Emacs proper now uses core text, too. – lunaryorn Dec 4 '15 at 8:50

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.