From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.pretest.bugs,gmane.emacs.devel Subject: Re: Exit hooks not run at logout on w32 Date: Thu, 29 Jun 2006 16:52:08 +0200 Message-ID: <44A3E918.5000304@student.lu.se> References: <44A005B7.2080904@student.lu.se> <44A01733.4010600@gnu.org> <44A03B61.8080501@student.lu.se> <44A2B99B.1020002@student.lu.se> <44A2F974.7040609@gnu.org> <44A31C19.5050000@student.lu.se> <44A3A2DE.4040507@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090104090800000506080506" X-Trace: sea.gmane.org 1151592771 25802 80.91.229.2 (29 Jun 2006 14:52:51 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 29 Jun 2006 14:52:51 +0000 (UTC) Cc: emacs-pretest-bug@gnu.org, Emacs Devel Original-X-From: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Thu Jun 29 16:52:42 2006 Return-path: Envelope-to: gebp-emacs-pretest-bug@gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FvxsV-0001u2-8B for gebp-emacs-pretest-bug@gmane.org; Thu, 29 Jun 2006 16:52:25 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FvxsU-0004dW-Sg for gebp-emacs-pretest-bug@gmane.org; Thu, 29 Jun 2006 10:52:22 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FvxsO-0004ZI-Da for emacs-pretest-bug@gnu.org; Thu, 29 Jun 2006 10:52:16 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FvxsN-0004XN-Af for emacs-pretest-bug@gnu.org; Thu, 29 Jun 2006 10:52:15 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FvxsM-0004WU-Kf; Thu, 29 Jun 2006 10:52:14 -0400 Original-Received: from [81.228.8.83] (helo=pne-smtpout1-sn2.hy.skanova.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Fvy4u-0007Qm-1g; Thu, 29 Jun 2006 11:05:12 -0400 Original-Received: from [192.168.123.121] (83.249.218.244) by pne-smtpout1-sn2.hy.skanova.net (7.2.075) id 44A2E86F00032805; Thu, 29 Jun 2006 16:52:11 +0200 User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) Original-To: Jason Rumney In-Reply-To: <44A3A2DE.4040507@gnu.org> X-BeenThere: emacs-pretest-bug@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for CVS Emacs." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Errors-To: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.pretest.bugs:12691 gmane.emacs.devel:56292 Archived-At: This is a multi-part message in MIME format. --------------090104090800000506080506 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Jason Rumney wrote: > Lennart Borgman wrote: >> Thanks. I did a post_msg and it works as I want it now. My concern >> was that data was lost on reboots and logouts (that has happened to >> me). Now it works like for other w32 apps: > > What other w32 apps are you talking about? The Windows programming > guidelines are pretty clear that the only time to interrupt shutdown > is when you are performing an operation that cannot be interrupted - > CD burning is given as an example. In that case you are supposed to > ask the user one Yes/No question about whether they want to abort the > shutdown. I was going to say I am not aware of any other application that throws away data without asking the user at logoff. However a test showed that Thunderbird behaves that way too ;-| I guess we are misunderstanding each other in some way. Let us see if we can clear this out. To see what I mean look Notepad for example. Edit a file without saving the changes and try to log off. You will be prompted by Notepad to save the changes before Notepad exits. And the log off process waits for Notepad to finish. I think that is good behaviour. I am a very surprised about what the Windows programming guideline seems to say. Can you give me a link to it? There is a message named WM_QUERYENDSESSION that I thought was sent for applications to save data. (Though Emacs does not receive this. It is not clear to me why.) > > As I said at the start of the thread, it would be correct for Emacs to > flush its autosave buffers to disk at this point, but not to start > asking all the questions that save-buffers-kill-emacs does. What if > Emacs is on a secondary monitor, and the Graphics driver shuts it off > when it receives the shutdown message? Emacs will be delaying shutdown > waiting for a response, while the user cannot see it. The problem with autosave is that data might be lost if the user happens to use some other tool to edit the files afterwards. Is there some way to discover cases like the one with secondary monitors? Should there perhaps be an option telling what Emacs should do in these situations (with the choices autosave and ask the user to save changed data)? I attach my patch as it looks now. Please try it to see how it works. --------------090104090800000506080506 Content-Type: text/plain; name="logout-patch.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="logout-patch.diff" ? logout-patch.diff Index: keyboard.c =================================================================== RCS file: /sources/emacs/emacs/src/keyboard.c,v retrieving revision 1.854 diff -u -r1.854 keyboard.c --- keyboard.c 5 May 2006 06:43:50 -0000 1.854 +++ keyboard.c 29 Jun 2006 06:35:22 -0000 @@ -530,6 +530,9 @@ #endif Lisp_Object Qdrag_n_drop; Lisp_Object Qsave_session; +#ifdef WINDOWSNT +Lisp_Object Qw32_endsession_event; +#endif #ifdef MAC_OS Lisp_Object Qmac_apple_event; #endif @@ -4061,6 +4064,13 @@ obj = Fcons (Qsave_session, Qnil); kbd_fetch_ptr = event + 1; } +#ifdef WINDOWSNT + else if (event->kind == W32_ENDSESSION_EVENT) + { + obj = Fcons (Qw32_endsession_event, Qnil); + kbd_fetch_ptr = event + 1; + } +#endif /* Just discard these, by returning nil. With MULTI_KBOARD, these events are used as placeholders when we need to randomly delete events from the queue. @@ -5872,6 +5882,11 @@ case SAVE_SESSION_EVENT: return Qsave_session; +#ifdef WINDOWSNT + case W32_ENDSESSION_EVENT: + return Qw32_endsession_event; +#endif + #ifdef MAC_OS case MAC_APPLE_EVENT: { @@ -10904,6 +10919,11 @@ Qsave_session = intern ("save-session"); staticpro (&Qsave_session); +#ifdef WINDOWSNT + Qw32_endsession_event = intern ("w32-endsession-event"); + staticpro (&Qw32_endsession_event); +#endif + #ifdef MAC_OS Qmac_apple_event = intern ("mac-apple-event"); staticpro (&Qmac_apple_event); @@ -11531,6 +11551,9 @@ * "handle-select-window"); */ initial_define_lispy_key (Vspecial_event_map, "save-session", "handle-save-session"); + /* W32 log off event */ + initial_define_lispy_key (Vspecial_event_map, "w32-endsession-event", + "save-buffers-kill-emacs"); } /* Mark the pointers in the kboard objects. Index: termhooks.h =================================================================== RCS file: /sources/emacs/emacs/src/termhooks.h,v retrieving revision 1.74 diff -u -r1.74 termhooks.h --- termhooks.h 5 May 2006 06:45:04 -0000 1.74 +++ termhooks.h 29 Jun 2006 06:39:35 -0000 @@ -328,6 +328,10 @@ save yourself before shutdown. */ SAVE_SESSION_EVENT, +#ifdef WINDOWSNT + W32_ENDSESSION_EVENT, +#endif + #ifdef MAC_OS /* Generated when an Apple event, a HICommand event, or a Services menu event is received and the corresponding handler is Index: w32console.c =================================================================== RCS file: /sources/emacs/emacs/src/w32console.c,v retrieving revision 1.45 diff -u -r1.45 w32console.c --- w32console.c 6 Feb 2006 15:23:21 -0000 1.45 +++ w32console.c 29 Jun 2006 12:35:04 -0000 @@ -41,6 +41,7 @@ #undef HAVE_WINDOW_SYSTEM #include "frame.h" #include "w32inevt.h" +#include "w32term.h" /* from window.c */ extern Lisp_Object Frecenter (); @@ -95,8 +96,31 @@ ctrl_c_handler (unsigned long type) { /* Only ignore "interrupt" events when running interactively. */ - return (!noninteractive - && (type == CTRL_C_EVENT || type == CTRL_BREAK_EVENT)); +/* return (!noninteractive */ +/* && (type == CTRL_C_EVENT || type == CTRL_BREAK_EVENT)); */ + if (!noninteractive) { + switch (type) + { + case CTRL_C_EVENT: + case CTRL_BREAK_EVENT: + return TRUE; + case CTRL_CLOSE_EVENT: // 2 + case CTRL_LOGOFF_EVENT: // 5 + case CTRL_SHUTDOWN_EVENT: // 6 + /* Ending session so tell user */ + //printf("ctrl_c_handler=%d, dwWindowsThreadid=%d\n", type, dwWindowsThreadId); fflush(stdout); + { + W32Msg wmsg; + wmsg.msg.hwnd = 0; + wmsg.msg.message = WM_EMACS_KILL; + wmsg.msg.wParam = 0; + wmsg.msg.lParam = 0; + post_msg(&wmsg); + return TRUE; + } + } + } + return FALSE; } /* If we're updating a frame, use it as the current frame Index: w32term.c =================================================================== RCS file: /sources/emacs/emacs/src/w32term.c,v retrieving revision 1.246 diff -u -r1.246 w32term.c --- w32term.c 5 Jun 2006 21:20:59 -0000 1.246 +++ w32term.c 29 Jun 2006 12:31:57 -0000 @@ -4668,6 +4668,11 @@ } break; + case WM_EMACS_KILL: + //printf("w32_read_socket WM_EMACS_KILL\n"); fflush(stdout); + inev.kind = W32_ENDSESSION_EVENT; + break; + case WM_INITMENU: f = x_window_to_frame (dpyinfo, msg.msg.hwnd); --------------090104090800000506080506 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug --------------090104090800000506080506--