[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacsclient, multiple displays and hanging

From: Colin S. Miller
Subject: Re: Emacsclient, multiple displays and hanging
Date: Mon, 01 Oct 2007 21:30:54 +0100
User-agent: Icedove (X11/20070607)

Greg Detre wrote:
Dear all,

When I'm at work, I want to be able to use that same
emacs session on my desktop. So I sit at my desktop and ssh into my
laptop, using emacsclient and 'make-frame-on-display' to bring up a
new emacsclient session on my desktop, continuing where I left off.

The problem comes when I remove my laptop. If I forgot to close all
the running emacsclient windows on my desktop, then emacs on my laptop
hangs (since it's waiting for some kind of X input from the
emacsclient running on my desktop). Obviously the solution is to
always shut all the emacsclients on my desktop before unplugging my
laptop, but I forget about twice a week, and have to kill -9 my laptop
emacs :(


the following function will kill all X-Frames on a named display

(defun csm-kill-frames-on-device (display)
  "kill all frames on display DISPLAY"

  (let ((dvce))
    (loop for frm in (frame-list)
        (setq dvce (frame-device frm))
        (if (device-on-window-system-p dvce)
              (if (string-equal (device-connection dvce) display)
                  (delete-frame frm)))))))


(defun csm-kill-all-non-local-x-frames ()
  "kill all frames that are not on :0.0"

  (let ((dvce))
    (loop for frm in (frame-list)
        (setq dvce (frame-device frm))
        (if (device-on-window-system-p dvce)
              (if (not (string-equal (device-connection dvce) '":0.0"))
          (delete-frame frm)))))))

If you close your laptop's lid before unplugging it, you can catch the
kill -SIGPWR with an external script, have it run emacsclient, calling either 
above functions to kill connections from your desktop.

SIGPWR is sent when a UPS connected machine switches to UPS power, I'd assume 
it's also sent
when a machine is hibernated/suspended (or resumed).

I can't see of a way to handle signals inside emacs, so an external script is a 
necessary evil.

Colin S. Miller

Replace the obvious in my email address with the first three letters of the 
hostname to reply.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]