I'm trying to set up XEmacs to make it hard for me to "accidentally"
shut down XEmacs. I have done much of what I want by adding an
exit-emacs hook, which asks me if I really mean to shut down, and
raises an error if I say "no".
But I'd like to go a little further. I can rebind C-x C-c to make that
key combination not exit Emacs. And I can rebind the menu entry and
M-f4 keystroke to make the menu do what I want.
But I can't see an obvious way of getting at the "system" close
methods - the close icon at the top right, and the system menu (top
left) "Close" item. These don't actually exit XEmacs - they close the
frame, and only exit XEmacs if the *last* frame is closed. I'd like to
close the frame, but if it's the last frame, minimise it - for now
just using (iconify-frame) but ideally to the system tray (but I need
to write a helper application to do that).
I can't see a way of hooking that "system close" functionality. I've
searched the "obvious" places - key bindings, menu bindings, hooks.
The only one even close is to use the exit-emacs-hook, but then (a) I
have to raise an error to stop the exit occurring, which is ugly, and
(b) it doesn't distinguish between the "system close" and any other
type (unless I can get this somehow from the current event, but I
don't know how...)
Has anyone got any suggestions?
PS Actually, having a variable mswindows-close-to-systray or
something, which if true made XEmacs respond to the "close" icon on
the last frame by minimising to the system tray (like a number of
other programs have) would be nice, but it's very MS-specific...