Messing about with emacs server

Posted on Tue 02 June 2009 by alex in misc

I've been messing around with some weird-ass behaviour with my emacs-server. I had some code in it to deal with automatically opening a fresh frame (while in X) which I had plugged from the emacsclient wiki page. In one of my more recent updates the bleeding edge emacs I run on most (but not all) of my boxes gained -c option to create a new frame for editing.

This caused all sorts of confusion and I started seeing inconsistent behaviour between invocations of emacsclient causing new frames to maybe appear or multiple frames being created. A bunch of (message)'s latter I started making the code more defencive and detecting the case when the current frame was the original server frame.

It was at this point the inconsistent behaviour disappeared and I was able to reliably bring up a fresh focused frame for everything I was editing. Calls without the -c parameter will cause the code to spawn a new frame automatically although it doesn't benefit from correct workspace focus -c will give you. I can only think that the code as it was would break at some subtle point (I'm guessing the server-edit-hook) and at that point not be able to recover. Still the changes I've made do seem to have improved things for now. Now all I need to do is test it on the other boxen with emacsen.