From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "moheb missaghi" Newsgroups: gmane.emacs.devel Subject: Popup when buffer file is changed on disk Date: Sat, 5 Feb 2005 13:56:19 -0700 Message-ID: <000c01c50bc5$248dc1e0$6501a8c0@y8h26> References: <200502040036.j140atb03430@raven.dms.auburn.edu> <009d01c50bbb$9aa2fd50$0200a8c0@sedrcw11488> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="Windows-1252"; reply-type=original Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1107638052 4734 80.91.229.2 (5 Feb 2005 21:14:12 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 5 Feb 2005 21:14:12 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 05 22:14:12 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1CxXFS-0004Np-Hb for ged-emacs-devel@m.gmane.org; Sat, 05 Feb 2005 22:13:46 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CxXTF-0006L3-4U for ged-emacs-devel@m.gmane.org; Sat, 05 Feb 2005 16:28:01 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1CxXQD-000539-6Q for emacs-devel@gnu.org; Sat, 05 Feb 2005 16:24:53 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1CxXQ1-0004zb-Bz for emacs-devel@gnu.org; Sat, 05 Feb 2005 16:24:44 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CxXQ0-0004uz-VS for emacs-devel@gnu.org; Sat, 05 Feb 2005 16:24:41 -0500 Original-Received: from [204.127.202.64] (helo=sccrmhc13.comcast.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CxWyh-00021P-3D for emacs-devel@gnu.org; Sat, 05 Feb 2005 15:56:27 -0500 Original-Received: from y8h26 (pcp03531757pcs.sntafe01.nm.comcast.net[68.35.4.113]) by comcast.net (sccrmhc13) with SMTP id <20050205205625016004h6pfe>; Sat, 5 Feb 2005 20:56:25 +0000 Original-To: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org X-MailScanner-To: ged-emacs-devel@m.gmane.org Xref: main.gmane.org gmane.emacs.devel:32922 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:32922 Hi: As great as emacs is, sometimes I'd like to use an IDE simultaneously with emacs which has features not currently available in emacs. To give an example, Microsoft's Visual Studio which has something called Intelisense which has a knowledge of object hierarchy and allows object name completion. Most IDE's prompt the user when the file is changed outside them (for example by an editor such as emacs) by poping up a dialog box asking the user if he/she wants to reload the file. emacs gives this warning a bit too late in my opinion, i.e., when the buffer is about to be modified rather than when its frame gets the focus. In the following I am presenting changes for NT emacs which allow poping up of a dialog box to notify the user that the file is changed on disk and the buffer is going to be refreshed. This is my first attempt and I can already think of some improvements (for example if the user doesn't want the file to be reloaded but the warning should popup only once). Just wanted to get some feed back from this group before going further. Here are the changes in cvs diff format delimited by a user flag named USING_WITH_IDE. Please note that this feature is not specific to any IDE and the code on Windows is simply an example. Regards Moheb Index: nt/nmake.defs =================================================================== RCS file: /cvsroot/emacs/emacs/nt/nmake.defs,v retrieving revision 1.20 diff -r1.20 nmake.defs 132a133,135 > > USER_CFLAGS = -DUSING_WITH_IDE > cvs diff: Diffing nt/icons cvs diff: Diffing nt/inc cvs diff: Diffing nt/inc/arpa cvs diff: Diffing nt/inc/netinet cvs diff: Diffing nt/inc/sys cvs diff: Diffing oldXMenu cvs diff: Diffing site-lisp cvs diff: Diffing src Index: src/buffer.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/buffer.c,v retrieving revision 1.473 diff -r1.473 buffer.c 55a56,59 > #if USING_WITH_IDE > #include "w32term.h" > #endif > 1662a1667,1671 > #if USING_WITH_IDE > Lisp_Object buf; > HWND hwnd = FRAME_W32_WINDOW (SELECTED_FRAME ()); > #endif > 1670a1680,1703 > #if USING_WITH_IDE > buf = switch_to_buffer_1 (buffer, norecord); > > // see if file is changed > if (!NILP (current_buffer->filename) > && SAVE_MODIFF >= MODIFF > && NILP (Fverify_visited_file_modtime (Fcurrent_buffer ())) > && !NILP (Ffile_exists_p (current_buffer->filename))) > { > int fileChangedDialogAnswer = MessageBox (NULL, "Buffer file changed > on disk. Buffer will be reloaded from disk.", "Emacs", > MB_OK|MB_ICONWARNING|MB_APPLMODAL|MB_SETFOREGROUND); > char msg[80]; > > if (fileChangedDialogAnswer == IDOK) > { > call3 (intern ("revert-buffer"), Qt, Qt, Qt); > strcpy(msg, "File reverted: "); > strcat(msg, XSTRING(current_buffer->filename)->data); > message (msg); > SetFocus(hwnd); > } > } > > return buf; > #else 1671a1705 > #endif Index: src/w32fns.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/w32fns.c,v retrieving revision 1.246 diff -r1.246 w32fns.c 3558a3559,3578 > #if USING_WITH_IDE > // see if file is changed > if (!NILP (current_buffer->filename) > && SAVE_MODIFF >= MODIFF > && NILP (Fverify_visited_file_modtime (Fcurrent_buffer ())) > && !NILP (Ffile_exists_p (current_buffer->filename))) > { > int fileChangedDialogAnswer = MessageBox (NULL, "Buffer file changed > on disk. Buffer will be reloaded from disk.", "Emacs", > MB_OK|MB_ICONWARNING|MB_APPLMODAL|MB_SETFOREGROUND); > char msg[80]; > > if (fileChangedDialogAnswer == IDOK) > { > call3 (intern ("revert-buffer"), Qt, Qt, Qt); > strcpy(msg, "File reverted: "); > strcat(msg, XSTRING(current_buffer->filename)->data); > message (msg); > SetFocus(hwnd); > } > } > #endif