From: "moheb missaghi" <moheb1333@comcast.net>
Subject: Popup when buffer file is changed on disk
Date: Sat, 5 Feb 2005 13:56:19 -0700 [thread overview]
Message-ID: <000c01c50bc5$248dc1e0$6501a8c0@y8h26> (raw)
In-Reply-To: 009d01c50bbb$9aa2fd50$0200a8c0@sedrcw11488
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
next prev parent reply other threads:[~2005-02-05 20:56 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-04 0:36 find-file-hook as illustration of Custom problems Luc Teirlinck
2005-02-04 7:16 ` Lennart Borgman
2005-02-05 17:38 ` Richard Stallman
2005-02-05 18:54 ` Luc Teirlinck
2005-02-06 21:01 ` Richard Stallman
2005-02-06 22:19 ` Lennart Borgman
2005-02-05 19:43 ` Lennart Borgman
2005-02-05 20:56 ` moheb missaghi [this message]
2005-02-05 22:57 ` Popup when buffer file is changed on disk Eli Zaretskii
2005-02-06 0:51 ` Lennart Borgman
2005-02-06 7:20 ` Eli Zaretskii
2005-02-06 9:02 ` Lennart Borgman
2005-02-06 9:53 ` Eli Zaretskii
2005-02-06 10:41 ` Lennart Borgman
2005-02-06 16:34 ` Luc Teirlinck
2005-02-06 17:52 ` Lennart Borgman
2005-02-06 17:04 ` Luc Teirlinck
2005-02-11 0:33 ` Luc Teirlinck
2005-02-11 15:40 ` Eli Zaretskii
2005-02-11 16:51 ` David Kastrup
2005-02-11 19:38 ` Luc Teirlinck
2005-02-12 11:03 ` Eli Zaretskii
2005-02-12 8:37 ` Richard Stallman
2005-02-13 1:41 ` Luc Teirlinck
2005-02-13 4:36 ` Eli Zaretskii
2005-02-15 3:05 ` Luc Teirlinck
2005-02-15 4:59 ` Eli Zaretskii
2005-02-16 2:59 ` moheb missaghi
2005-02-16 9:31 ` Richard Stallman
2005-02-16 10:37 ` David Kastrup
2005-02-16 15:06 ` Luc Teirlinck
2005-02-16 15:21 ` David Kastrup
2005-02-17 1:08 ` Luc Teirlinck
2005-02-06 12:42 ` Richard Stallman
2005-02-06 18:00 ` Lennart Borgman
2005-02-06 18:17 ` Jan D.
2005-02-06 19:59 ` Lennart Borgman
2005-02-06 20:40 ` Jan D.
2005-02-07 4:34 ` Eli Zaretskii
2005-02-07 4:04 ` Luc Teirlinck
2005-02-06 18:11 ` Luc Teirlinck
2005-02-06 18:45 ` Luc Teirlinck
2005-02-06 13:24 ` Jason Rumney
2005-02-06 13:54 ` Lennart Borgman
2005-02-06 7:23 ` Eli Zaretskii
2005-02-06 21:01 ` find-file-hook as illustration of Custom problems Richard Stallman
2005-02-06 1:50 ` Luc Teirlinck
2005-02-06 3:26 ` Luc Teirlinck
2005-02-06 4:02 ` Luc Teirlinck
2005-02-06 21:02 ` Richard Stallman
2005-02-08 1:50 ` Luc Teirlinck
2005-02-09 8:10 ` Richard Stallman
2005-02-09 10:42 ` Kim F. Storm
2005-02-10 18:39 ` Richard Stallman
2005-02-10 21:42 ` Kim F. Storm
2005-02-12 8:37 ` Richard Stallman
2005-02-10 5:12 ` Luc Teirlinck
2005-02-10 18:40 ` Richard Stallman
2005-02-11 0:09 ` Luc Teirlinck
2005-02-12 8:37 ` Richard Stallman
2005-02-11 0:21 ` Luc Teirlinck
2005-02-11 14:59 ` Luc Teirlinck
2005-02-10 5:26 ` Luc Teirlinck
2005-02-06 2:07 ` Luc Teirlinck
2005-02-06 3:16 ` Luc Teirlinck
-- strict thread matches above, loose matches on Subject: below --
2005-02-14 20:18 Popup when buffer file is changed on disk moheb1333
2006-01-01 16:10 ` Richard M. Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='000c01c50bc5$248dc1e0$6501a8c0@y8h26' \
--to=moheb1333@comcast.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).