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.

asmeurer
  • 1,572
  • 12
  • 32
  • 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 00:02
  • Same thing here, can't replicate issue using GNU Emacs 24.3.1, emacsclient 24.3 – Nsukami _ Nov 11 '14 at 05:05
  • I added some info on how to reproduce. A typical server name is ttys004. – asmeurer Nov 11 '14 at 19:39
  • How have you ruled out init file issues? – purple_arrows Nov 11 '14 at 22:20
  • I'm not sure how to test that. emacsclient doesn't seem to support the -Q option. – asmeurer Nov 12 '14 at 17:22
  • The init file is evaluated run when the server starts, so you'd run emacs --daemon -Q – phils Nov 23 '14 at 07:40
  • But it doesn't happen if I start the server first. – asmeurer Nov 24 '14 at 08:35
  • @asmeurermore your init out of the way before you trigger the start of the daemon with emacsclient. – stsquad Nov 24 '14 at 16:12
  • Ah, so it does seem to be related to something in my .emacs. – asmeurer Nov 24 '14 at 20:26
  • My .emacs is at https://github.com/asmeurer/dotfiles/blob/master/.emacs. I'll try bisecting it, but I have really no idea what would be causing this, so I'm shooting in the dark. – asmeurer Nov 24 '14 at 20:30
  • 1
    I bisected the issue to flyspell (with hunspell). See my edit to the question. – asmeurer Nov 25 '14 at 23:29

1 Answers1

1

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

#!/bin/sh
export TTY=$(basename `tty`)

emacs --daemon="emacs-$TTY"
emacsclient -n -nw --socket-name="emacs-$TTY"
emacsclient -nw --socket-name="emacs-$TTY" "$@"

called emacs-server-start. Then start emacsclient with emacsclient -a 'emacs-server-start' -nw --socket-name=emacs-$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.

asmeurer
  • 1,572
  • 12
  • 32