[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Popup when buffer file is changed on disk
From: |
moheb missaghi |
Subject: |
Popup when buffer file is changed on disk |
Date: |
Sat, 5 Feb 2005 13:56:19 -0700 |
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
- find-file-hook as illustration of Custom problems, Luc Teirlinck, 2005/02/03
- Re: find-file-hook as illustration of Custom problems, Lennart Borgman, 2005/02/04
- Re: find-file-hook as illustration of Custom problems, Richard Stallman, 2005/02/05
- Re: find-file-hook as illustration of Custom problems, Lennart Borgman, 2005/02/05
- Popup when buffer file is changed on disk,
moheb missaghi <=
- Re: Popup when buffer file is changed on disk, Eli Zaretskii, 2005/02/05
- Re: Popup when buffer file is changed on disk, Lennart Borgman, 2005/02/05
- Re: Popup when buffer file is changed on disk, Eli Zaretskii, 2005/02/06
- Re: Popup when buffer file is changed on disk, Lennart Borgman, 2005/02/06
- Re: Popup when buffer file is changed on disk, Eli Zaretskii, 2005/02/06
- Re: Popup when buffer file is changed on disk, Lennart Borgman, 2005/02/06
- Re: Popup when buffer file is changed on disk, Luc Teirlinck, 2005/02/06
- Re: Popup when buffer file is changed on disk, Lennart Borgman, 2005/02/06
- Re: Popup when buffer file is changed on disk, Luc Teirlinck, 2005/02/06
- Re: Popup when buffer file is changed on disk, Luc Teirlinck, 2005/02/10