3

This is somewhat of a follow up to Prevent emacsclient from blocking other instances.

I am using emacsclient -a '' -nw --socket-name=$TTY where TTY=$(basename tty). I use emacs in the terminal and this gives a unique daemon for each terminal session.

If I start the daemon by running emacsclient with no arguments, it starts and everything works fine. However, if I start it by running emacsclient file, it locks down. It opens the scratch buffer and then gets frozen. The only way to fix it is to kill -9 the daemon process and to restart it without opening a file.

I am using emacs 24.4 compiled with --without-x with Mac OS X in iTerm 2. You can get the exact build of emacs I am using with conda conda install -c asmeurer emacs.

EDIT

I found after disabling flyspell (commenting out these lines from my .emacs), it fixes it. It still hangs on the scratch buffer for a few seconds, but then goes to the file. I suspect it has something to do with starting the hunspell process.

  • A workaround would be to always start an emacs daemon with each terminal session (i.e., in the bash profile). This would slow down the terminal start time, though, and would lead to many unused servers. – asmeurer Nov 10 '14 at 23:54
  • I can't replicate this issue. Can you detail an exact sequence of commands to recreate the problem, including the value for $TTY in that instance, and confirming the versions of both emacs and emacsclient (check both emacsclient --version from the command line, and M-x emacs-version from within emacs, and confirm they match). – phils Nov 11 '14 at 0:02
  • Same thing here, can't replicate issue using GNU Emacs 24.3.1, emacsclient 24.3 – Nsukami _ Nov 11 '14 at 5:05
  • I added some info on how to reproduce. A typical server name is ttys004. – asmeurer Nov 11 '14 at 19:39
  • 1
    I bisected the issue to flyspell (with hunspell). See my edit to the question. – asmeurer Nov 25 '14 at 23:29
1

I have found a reasonable workaround. First, add a script to your PATH with

#!/bin/sh
emacs --daemon="$TTY"
emacsclient -n -nw --socket-name="$TTY"
emacsclient -nw --socket-name="$TTY" "$@"

called emacs-server-start. Then start emacsclient with emacsclient -a 'emacs-server-start' -nw --socket-name=$TTY (I have e aliased to this in my bash configuration).

You basically are creating a custom "start emacs server" alternate editor for emacsclient -a, since emacsclient -a '' doesn't work. Saving this to a file is necessary because the argument to -a must be a single command (i.e., emacsclient -a 'emacs --daemon' does not work).

The extra emacsclient -n, which causes emacsclient to start and immediately close with no file, is there because otherwise emacs will sometimes still freeze at startup.

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.