unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Popup when buffer file is changed on disk
  2005-02-05 19:43   ` Lennart Borgman
@ 2005-02-05 20:56     ` moheb missaghi
  2005-02-05 22:57       ` Eli Zaretskii
  0 siblings, 1 reply; 40+ messages in thread
From: moheb missaghi @ 2005-02-05 20:56 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-05 20:56     ` Popup when buffer file is changed on disk moheb missaghi
@ 2005-02-05 22:57       ` Eli Zaretskii
  2005-02-06  0:51         ` Lennart Borgman
  2005-02-06  7:23         ` Eli Zaretskii
  0 siblings, 2 replies; 40+ messages in thread
From: Eli Zaretskii @ 2005-02-05 22:57 UTC (permalink / raw)
  Cc: emacs-devel

> From: "moheb missaghi" <moheb1333@comcast.net>
> Date: Sat, 5 Feb 2005 13:56:19 -0700
> 
> Microsoft's Visual Studio which has something called Intelisense which has a
> knowledge of object hierarchy and allows object name completion.

Doesn't ECB provide that feature?

> 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.

Would switching on auto-revert-mode solve your problem here?

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-05 22:57       ` Eli Zaretskii
@ 2005-02-06  0:51         ` Lennart Borgman
  2005-02-06  7:20           ` Eli Zaretskii
  2005-02-06  7:23         ` Eli Zaretskii
  1 sibling, 1 reply; 40+ messages in thread
From: Lennart Borgman @ 2005-02-06  0:51 UTC (permalink / raw)
  Cc: emacs-devel

----- Original Message ----- 
From: "Eli Zaretskii" <eliz@gnu.org>

> > 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.
>
> Would switching on auto-revert-mode solve your problem here?

I have been missing this feature too. Emacs behaviour is quite confusing if
you are used to the behavior Moheb mentions.

I do not believe that auto-revert-mode can do what Moheb (and I myself)
wants. What we want to happen is that Emacs should warn at the moment when
it gets focus that the file has changed.

So the message that the operating system sends to Emacs to tell it that it
has got focus must be catched by Emacs message queue and given to elisp. I
do not know exactly how to do that but it should be done by letting the
detection of the message start a timer that then runs the wanted code. (I
mean I don't remember the message name and I do not know how Emacs handles
messages.)

This description is from my knowledge of w32 but I guess something similar
should apply to for example GNU/Linux?

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-06  0:51         ` Lennart Borgman
@ 2005-02-06  7:20           ` Eli Zaretskii
  2005-02-06  9:02             ` Lennart Borgman
  0 siblings, 1 reply; 40+ messages in thread
From: Eli Zaretskii @ 2005-02-06  7:20 UTC (permalink / raw)
  Cc: emacs-devel, moheb1333

> From: "Lennart Borgman" <lennart.borgman.073@student.lu.se>
> Cc: <emacs-devel@gnu.org>
> Date: Sun, 6 Feb 2005 01:51:43 +0100
> 
> > Would switching on auto-revert-mode solve your problem here?
> 
> I have been missing this feature too. Emacs behaviour is quite confusing if
> you are used to the behavior Moheb mentions.
> 
> I do not believe that auto-revert-mode can do what Moheb (and I myself)
> wants. What we want to happen is that Emacs should warn at the moment when
> it gets focus that the file has changed.

When Emacs warns you that the file was changed, what would you do in
response?  I thought that you would revert the buffer, so auto-revert
seemed like a good solution.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-05 22:57       ` Eli Zaretskii
  2005-02-06  0:51         ` Lennart Borgman
@ 2005-02-06  7:23         ` Eli Zaretskii
  1 sibling, 0 replies; 40+ messages in thread
From: Eli Zaretskii @ 2005-02-06  7:23 UTC (permalink / raw)


> Date: Sun, 06 Feb 2005 00:57:59 +0200
> From: "Eli Zaretskii" <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
> 
> > From: "moheb missaghi" <moheb1333@comcast.net>
> > Date: Sat, 5 Feb 2005 13:56:19 -0700
> > 
> > Microsoft's Visual Studio which has something called Intelisense which has a
> > knowledge of object hierarchy and allows object name completion.
> 
> Doesn't ECB provide that feature?

It is perhaps noteworthy that Ebrowse and maybe even Speedbar, both
bundled with Emacs 21.x, offer similar, if less elaborate,
functionality.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-06  7:20           ` Eli Zaretskii
@ 2005-02-06  9:02             ` Lennart Borgman
  2005-02-06  9:53               ` Eli Zaretskii
                                 ` (2 more replies)
  0 siblings, 3 replies; 40+ messages in thread
From: Lennart Borgman @ 2005-02-06  9:02 UTC (permalink / raw)
  Cc: emacs-devel, moheb1333

----- Original Message ----- 
From: "Eli Zaretskii" <eliz@gnu.org>
To: "Lennart Borgman" <lennart.borgman.073@student.lu.se>
Cc: <moheb1333@comcast.net>; <emacs-devel@gnu.org>
Sent: Sunday, February 06, 2005 8:20 AM
Subject: Re: Popup when buffer file is changed on disk


> > From: "Lennart Borgman" <lennart.borgman.073@student.lu.se>
> > Cc: <emacs-devel@gnu.org>
> > Date: Sun, 6 Feb 2005 01:51:43 +0100
> >
> > > Would switching on auto-revert-mode solve your problem here?
> >
> > I have been missing this feature too. Emacs behaviour is quite confusing
if
> > you are used to the behavior Moheb mentions.
> >
> > I do not believe that auto-revert-mode can do what Moheb (and I myself)
> > wants. What we want to happen is that Emacs should warn at the moment
when
> > it gets focus that the file has changed.
>
> When Emacs warns you that the file was changed, what would you do in
> response?  I thought that you would revert the buffer, so auto-revert
> seemed like a good solution.

auto-revert-mode does what it does later, not at the moment Emacs gets
focus. I believe that at the moment when Emacs gets focus it should for all
files that are visited in buffers and changed outside of Emacs should ask:

     "File AA.C has changed on disk. Do you want to reload it?"

I think a popup should be used for this since it is more visible. Emacs
should also keep track of when this question was asked last time (to avoid
asking to many times).

After this the usual Emacs handling of the situation should persist.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-06  9:02             ` Lennart Borgman
@ 2005-02-06  9:53               ` Eli Zaretskii
  2005-02-06 10:41                 ` Lennart Borgman
  2005-02-06 12:42               ` Richard Stallman
  2005-02-06 13:24               ` Jason Rumney
  2 siblings, 1 reply; 40+ messages in thread
From: Eli Zaretskii @ 2005-02-06  9:53 UTC (permalink / raw)
  Cc: emacs-devel, moheb1333

> From: "Lennart Borgman" <lennart.borgman.073@student.lu.se>
> Cc: <moheb1333@comcast.net>, <emacs-devel@gnu.org>
> Date: Sun, 6 Feb 2005 10:02:20 +0100
> 
> > When Emacs warns you that the file was changed, what would you do in
> > response?  I thought that you would revert the buffer, so auto-revert
> > seemed like a good solution.
> 
> auto-revert-mode does what it does later, not at the moment Emacs gets
> focus.

??? auto-revert-mode periodically checks all buffers that are visiting
a file.  The frequency of these checks is determined by the variable
auto-revert-interval, by default every 5 seconds.

Perhaps you need to set auto-revert-stop-on-user-input to nil and
maybe also play with auto-revert-interval's value, to get almost
instanteneous automatic reverts whenever a file changes.

> I believe that at the moment when Emacs gets focus it should for all
> files that are visited in buffers and changed outside of Emacs should ask:
> 
>      "File AA.C has changed on disk. Do you want to reload it?"

Perhaps a feature can be added to autorevert.el, whereby it checks the
buffers when a focus event arrives.  All the rest is already there, I
believe.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  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:04                   ` Luc Teirlinck
  0 siblings, 2 replies; 40+ messages in thread
From: Lennart Borgman @ 2005-02-06 10:41 UTC (permalink / raw)
  Cc: Emacs Devel

----- Original Message ----- 
From: "Eli Zaretskii" <eliz@gnu.org>

> > auto-revert-mode does what it does later, not at the moment Emacs gets
> > focus.
>
> ??? auto-revert-mode periodically checks all buffers that are visiting
> a file.  The frequency of these checks is determined by the variable
> auto-revert-interval, by default every 5 seconds.

Hm. Thanks. Looks like I tested too fast. Sorry.

> Perhaps you need to set auto-revert-stop-on-user-input to nil and
> maybe also play with auto-revert-interval's value, to get almost
> instanteneous automatic reverts whenever a file changes.

Setting auto-revert-stop-on-user-input to nil does not work for me. Using
CVS, any ideas of what could be wrong.

> Perhaps a feature can be added to autorevert.el, whereby it checks the
> buffers when a focus event arrives.  All the rest is already there, I
> believe.

The timer is surely good, but checking at the focus event is still
desireable IMO since it is more instantaneous when switching to Emacs.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-06  9:02             ` Lennart Borgman
  2005-02-06  9:53               ` Eli Zaretskii
@ 2005-02-06 12:42               ` Richard Stallman
  2005-02-06 18:00                 ` Lennart Borgman
  2005-02-06 18:11                 ` Luc Teirlinck
  2005-02-06 13:24               ` Jason Rumney
  2 siblings, 2 replies; 40+ messages in thread
From: Richard Stallman @ 2005-02-06 12:42 UTC (permalink / raw)
  Cc: eliz, moheb1333, emacs-devel

    focus. I believe that at the moment when Emacs gets focus it should for all
    files that are visited in buffers and changed outside of Emacs should ask:

	 "File AA.C has changed on disk. Do you want to reload it?"

I don't want to install this; I think it would be annoying.  However,
you could write it and post a patch, and people could try it and
report whether they like it.  If people generally agree it is a good
thing, I will install it.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-06  9:02             ` Lennart Borgman
  2005-02-06  9:53               ` Eli Zaretskii
  2005-02-06 12:42               ` Richard Stallman
@ 2005-02-06 13:24               ` Jason Rumney
  2005-02-06 13:54                 ` Lennart Borgman
  2 siblings, 1 reply; 40+ messages in thread
From: Jason Rumney @ 2005-02-06 13:24 UTC (permalink / raw)
  Cc: Eli Zaretskii, moheb1333, emacs-devel

"Lennart Borgman" <lennart.borgman.073@student.lu.se> writes:

> I think a popup should be used for this since it is more visible.

The dialog code has been waiting for someone to implement it on w32
for years. It would be better to put effort into implementing general
dialog support than to create a dialog especially for this purpose.

> Emacs should also keep track of when this question was asked last
> time (to avoid asking to many times).

I don't understand the rationale for this. If Emacs decides it has
asked too many times, what should it do?

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-06 13:24               ` Jason Rumney
@ 2005-02-06 13:54                 ` Lennart Borgman
  0 siblings, 0 replies; 40+ messages in thread
From: Lennart Borgman @ 2005-02-06 13:54 UTC (permalink / raw)
  Cc: Eli Zaretskii, moheb1333, emacs-devel

----- Original Message ----- 
From: "Jason Rumney" <jasonr@gnu.org>

> > Emacs should also keep track of when this question was asked last
> > time (to avoid asking to many times).
>
> I don't understand the rationale for this. If Emacs decides it has
> asked too many times, what should it do?

Sorry, "too many times" was not really what I meant. When Emacs asks about a
file change it should keep track of the modification (or write time) of the
changed file. If that time has not changed then do not ask again.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  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
  1 sibling, 1 reply; 40+ messages in thread
From: Luc Teirlinck @ 2005-02-06 16:34 UTC (permalink / raw)
  Cc: eliz, emacs-devel

Lennart Borgman wrote:

   Setting auto-revert-stop-on-user-input to nil does not work for me. Using
   CVS, any ideas of what could be wrong.

I believe that what is wrong is that you misunderstand what it is
supposed to do.  Basically, setting this to nil is only going to make a
noticeable difference when a bunch og huge files are changing on disk
while you are trying to type.  My best guess is that you are not going
to enjoy it being nil in such a situation.

Do you still believe that it "does not work" after reading the
following expanded docstring?

===File ~/autorevert-diff===================================
*** autorevert.el	29 Dec 2004 21:08:55 -0600	1.42
--- autorevert.el	06 Feb 2005 10:14:45 -0600	
***************
*** 150,156 ****
  	      (auto-revert-set-timer))))
  
  (defcustom auto-revert-stop-on-user-input t
!   "When non-nil Auto-Revert Mode stops checking files on user input."
    :group 'auto-revert
    :type 'boolean)
  
--- 150,160 ----
  	      (auto-revert-set-timer))))
  
  (defcustom auto-revert-stop-on-user-input t
!   "When non-nil Auto-Revert Mode stops checking files on user input.
! This prevents Auto Revert from interrupting you while you are typing.
! This option controls when files are auto-reverted, not which files
! are auto-reverted.  Modified files are never auto-reverted,
! regardless of the value of this option."
    :group 'auto-revert
    :type 'boolean)
  
============================================================

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-06 10:41                 ` Lennart Borgman
  2005-02-06 16:34                   ` Luc Teirlinck
@ 2005-02-06 17:04                   ` Luc Teirlinck
  2005-02-11  0:33                     ` Luc Teirlinck
  1 sibling, 1 reply; 40+ messages in thread
From: Luc Teirlinck @ 2005-02-06 17:04 UTC (permalink / raw)
  Cc: eliz, emacs-devel

I believe that the following is better than my original patch.  Only
the second line of the docstring has changed.  The thing that can go
wrong if the option is nil is less often that you get "interrupted".
than that Emacs fails to respond (whether to typing or to other commands).

===File ~/autorevert-diff-b=================================
*** autorevert.el	29 Dec 2004 21:08:55 -0600	1.42
--- autorevert.el	06 Feb 2005 10:48:08 -0600	
***************
*** 150,156 ****
  	      (auto-revert-set-timer))))
  
  (defcustom auto-revert-stop-on-user-input t
!   "When non-nil Auto-Revert Mode stops checking files on user input."
    :group 'auto-revert
    :type 'boolean)
  
--- 150,160 ----
  	      (auto-revert-set-timer))))
  
  (defcustom auto-revert-stop-on-user-input t
!   "When non-nil Auto-Revert Mode stops checking files on user input.
! This prevents Auto Revert from interfering with your normal Emacs usage.
! This option controls when files are auto-reverted, not which files
! are auto-reverted.  Modified files are never auto-reverted,
! regardless of the value of this option."
    :group 'auto-revert
    :type 'boolean)
  
============================================================

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-06 16:34                   ` Luc Teirlinck
@ 2005-02-06 17:52                     ` Lennart Borgman
  0 siblings, 0 replies; 40+ messages in thread
From: Lennart Borgman @ 2005-02-06 17:52 UTC (permalink / raw)
  Cc: eliz, emacs-devel

----- Original Message ----- 
From: "Luc Teirlinck" <teirllm@dms.auburn.edu>

> Do you still believe that it "does not work" after reading the
> following expanded docstring?

No. Thanks.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-06 12:42               ` Richard Stallman
@ 2005-02-06 18:00                 ` Lennart Borgman
  2005-02-06 18:17                   ` Jan D.
  2005-02-07  4:04                   ` Luc Teirlinck
  2005-02-06 18:11                 ` Luc Teirlinck
  1 sibling, 2 replies; 40+ messages in thread
From: Lennart Borgman @ 2005-02-06 18:00 UTC (permalink / raw)
  Cc: eliz, emacs-devel, moheb1333

----- Original Message ----- 
From: "Richard Stallman" <rms@gnu.org>

> "File AA.C has changed on disk. Do you want to reload it?"
>
> I don't want to install this; I think it would be annoying.  However,
> you could write it and post a patch, and people could try it and
> report whether they like it.  If people generally agree it is a good
> thing, I will install it.

I tried to implement it to see how it could work. I took a little bit
different road. I let the app activate event call a lisp function (which I
named "handle-app-activation"). This should handle both app activation and
app deactivation.

Any ideas around this?

I am only able to implement this on w32. I guess it should be
straightforward to do the same for other OS:es if there are events for app
activation/deactivation (which I suppose there are). The only part that
differs is the "real message loop".

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-06 12:42               ` Richard Stallman
  2005-02-06 18:00                 ` Lennart Borgman
@ 2005-02-06 18:11                 ` Luc Teirlinck
  2005-02-06 18:45                   ` Luc Teirlinck
  1 sibling, 1 reply; 40+ messages in thread
From: Luc Teirlinck @ 2005-02-06 18:11 UTC (permalink / raw)
  Cc: lennart.borgman.073, eliz, emacs-devel, moheb1333

Richard Stallman wrote:

   I don't want to install this; I think it would be annoying.

I believe that it would be very annoying.  It is apparently something
people who use MS Windows applications are used to, but I guess that
is because they have systematically adapted their customizations and
work habits to it.

I believe that autorevert mostly covers the functionality.  The only
problem is that autorevert quits either reverting or warning if the
buffer is modified.  (Emacs _does_ warn when you try to save your
changes to disk.)

I believe that it would not be too difficult to adapt the code in
autorevert to put a flag in the modeline that says whether the visited
file has changed on disk or not, regardless of whether the buffer is
modified or not.  This would be a mode (more of a mode line feature)
that could be enabled independently from Auto Revert.  If you do not
use Auto Revert, it would just tell you that the file had changed on
disk, leaving the decision of whether to revert or not up to the user.
It would be analogous to the flag telling you that you have new mail.
It would also not be very difficult to add a global flag indicating
that at least one file visited in some buffer has changed on disk, but
I believe that would be less useful than the "local" variant.

While I do not believe that would be terribly difficult to implement,
I personally do not have the time right now and we are in a feature freeze.

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-06 18:00                 ` Lennart Borgman
@ 2005-02-06 18:17                   ` Jan D.
  2005-02-06 19:59                     ` Lennart Borgman
  2005-02-07  4:04                   ` Luc Teirlinck
  1 sibling, 1 reply; 40+ messages in thread
From: Jan D. @ 2005-02-06 18:17 UTC (permalink / raw)
  Cc: eliz, moheb1333, rms, emacs-devel

>
> I am only able to implement this on w32. I guess it should be
> straightforward to do the same for other OS:es if there are events for 
> app
> activation/deactivation (which I suppose there are). The only part that
> differs is the "real message loop".

I haven't seen other OS:es (i.e. Unix) use the terms 
activate/deactivate for applications.  What does it mean?  That some 
GUI window for the application gets focus?  In that case a better 
implementation is to generate a lisp event for FOCUS_IN.  That should 
work on all platforms directly.

	Jan D.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-06 18:11                 ` Luc Teirlinck
@ 2005-02-06 18:45                   ` Luc Teirlinck
  0 siblings, 0 replies; 40+ messages in thread
From: Luc Teirlinck @ 2005-02-06 18:45 UTC (permalink / raw)
  Cc: lennart.borgman.073, eliz, moheb1333, rms, emacs-devel

>From my previous message:

   I believe that it would not be too difficult to adapt the code in
   autorevert to put a flag in the modeline that says whether the visited
   file has changed on disk or not,

In addition the Buffer Menu could display the flag.  You can enable
Auto Revert in the Buffer Menu, thereby updating the flag every
auto-revert-interval seconds.

In as far as I am concerned, all stuff for Emacs 22, not 21.4.

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-06 18:17                   ` Jan D.
@ 2005-02-06 19:59                     ` Lennart Borgman
  2005-02-06 20:40                       ` Jan D.
  0 siblings, 1 reply; 40+ messages in thread
From: Lennart Borgman @ 2005-02-06 19:59 UTC (permalink / raw)
  Cc: emacs-devel

----- Original Message ----- 
From: "Jan D." <jan.h.d@swipnet.se>

> I haven't seen other OS:es (i.e. Unix) use the terms
> activate/deactivate for applications.  What does it mean?  That some
> GUI window for the application gets focus?  In that case a better
> implementation is to generate a lisp event for FOCUS_IN.  That should
> work on all platforms directly.

Thanks. I will see what I will do. It gets more complicated in that case
(because of the structure of the code) and I do not want to break anything
now.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-06 19:59                     ` Lennart Borgman
@ 2005-02-06 20:40                       ` Jan D.
  2005-02-07  4:34                         ` Eli Zaretskii
  0 siblings, 1 reply; 40+ messages in thread
From: Jan D. @ 2005-02-06 20:40 UTC (permalink / raw)
  Cc: emacs-devel

> ----- Original Message -----
> From: "Jan D." <jan.h.d@swipnet.se>
>
>> I haven't seen other OS:es (i.e. Unix) use the terms
>> activate/deactivate for applications.  What does it mean?  That some
>> GUI window for the application gets focus?  In that case a better
>> implementation is to generate a lisp event for FOCUS_IN.  That should
>> work on all platforms directly.
>
> Thanks. I will see what I will do. It gets more complicated in that 
> case
> (because of the structure of the code) and I do not want to break 
> anything
> now.

I spoke too soon, w32 and msdos doesn't seem to generate FOCUS_IN, so 
perhaps a new event is called for.

	Jan D.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-06 18:00                 ` Lennart Borgman
  2005-02-06 18:17                   ` Jan D.
@ 2005-02-07  4:04                   ` Luc Teirlinck
  1 sibling, 0 replies; 40+ messages in thread
From: Luc Teirlinck @ 2005-02-07  4:04 UTC (permalink / raw)
  Cc: eliz, moheb1333, rms, emacs-devel

If you are going to do this, at least make it an option that is by
default off.

The rationale behind checking for and warning about files that have
changed on disk _after a focus change_ is apparently the assumption
that most files change on disk because you edited them with another
editor.  Many people only use one editor, Emacs.  For them that
assumption is completely wrong.

Files can change on disk for several reasons, including:

1.  Because you edited them with another editor.

2.  Because some process is writing to them.

3.  Because another person is editing them.

4.  Because you changed them from within Emacs in some way that
    bypassed the buffer.  (To be avoided, but can inadvertently happen.)

(2), (3) and (4) are unrelated to focus changes.  They can happen any
time.  For people that only edit files using Emacs, (1) never happens.

If processes are writing to files visited in buffers, files are going
to change on disk all the time.  I would be reminded about that on
just about every focus change, even though I know that autorevert is
going to revert them within 5 seconds or less.  This is senseless.

Clearly, the best way to deal with all ways that a file can change on
disk is a combination of mode line and Buffer Menu.  (And still this
would only be needed if for some reason you do not want to use
autorevert or if you are editing files that could change on disk.)
The mode line and Buffer Menu features would not be very difficult to
implement.  But we are in a feature freeze, so I believe it can wait
till Emacs 22.

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-06 20:40                       ` Jan D.
@ 2005-02-07  4:34                         ` Eli Zaretskii
  0 siblings, 0 replies; 40+ messages in thread
From: Eli Zaretskii @ 2005-02-07  4:34 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

> From: "Jan D." <jan.h.d@swipnet.se>
> Date: Sun, 6 Feb 2005 21:40:29 +0100
> Cc: emacs-devel@gnu.org
> 
> I spoke too soon, w32 and msdos doesn't seem to generate FOCUS_IN, so 
> perhaps a new event is called for.

The MSDOS case is irrelevant: it's not a multi-frame configuration, so
focus-in events are meaningless there.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-06 17:04                   ` Luc Teirlinck
@ 2005-02-11  0:33                     ` Luc Teirlinck
  2005-02-11 15:40                       ` Eli Zaretskii
  2005-02-12  8:37                       ` Richard Stallman
  0 siblings, 2 replies; 40+ messages in thread
From: Luc Teirlinck @ 2005-02-11  0:33 UTC (permalink / raw)
  Cc: lennart.borgman.073, eliz, emacs-devel

I will install the following doc patch to autorevert.el if there are
no objections.  The patch would be silly if the first line of the
docstring were clear enough without it.  But I believe that it is not.

===File ~/autorevert-diff-b=================================
*** autorevert.el	29 Dec 2004 21:08:55 -0600	1.42
--- autorevert.el	06 Feb 2005 10:48:08 -0600	
***************
*** 150,156 ****
		 (auto-revert-set-timer))))

  (defcustom auto-revert-stop-on-user-input t
!   "When non-nil Auto-Revert Mode stops checking files on user input."
    :group 'auto-revert
    :type 'boolean)

--- 150,160 ----
		 (auto-revert-set-timer))))

  (defcustom auto-revert-stop-on-user-input t
!   "When non-nil Auto-Revert Mode stops checking files on user input.
! This prevents Auto Revert from interfering with your normal Emacs usage.
! This option controls when files are auto-reverted, not which files
! are auto-reverted.  Modified files are never auto-reverted,
! regardless of the value of this option."
    :group 'auto-revert
    :type 'boolean)

============================================================

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-11  0:33                     ` Luc Teirlinck
@ 2005-02-11 15:40                       ` Eli Zaretskii
  2005-02-11 16:51                         ` David Kastrup
  2005-02-12  8:37                       ` Richard Stallman
  1 sibling, 1 reply; 40+ messages in thread
From: Eli Zaretskii @ 2005-02-11 15:40 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

> Date: Thu, 10 Feb 2005 18:33:13 -0600 (CST)
> From: Luc Teirlinck <teirllm@dms.auburn.edu>
> Cc: lennart.borgman.073@student.lu.se, eliz@gnu.org, emacs-devel@gnu.org
> 
>   (defcustom auto-revert-stop-on-user-input t
> !   "When non-nil Auto-Revert Mode stops checking files on user input.
> ! This prevents Auto Revert from interfering with your normal Emacs usage.
> ! This option controls when files are auto-reverted, not which files
> ! are auto-reverted.  Modified files are never auto-reverted,
> ! regardless of the value of this option."

I don't see why the doc string should mention modified files.
Modified files have nothing to do with this option.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-11 15:40                       ` Eli Zaretskii
@ 2005-02-11 16:51                         ` David Kastrup
  2005-02-11 19:38                           ` Luc Teirlinck
  0 siblings, 1 reply; 40+ messages in thread
From: David Kastrup @ 2005-02-11 16:51 UTC (permalink / raw)
  Cc: lennart.borgman.073, Luc Teirlinck, emacs-devel

"Eli Zaretskii" <eliz@gnu.org> writes:

>> Date: Thu, 10 Feb 2005 18:33:13 -0600 (CST)
>> From: Luc Teirlinck <teirllm@dms.auburn.edu>
>> Cc: lennart.borgman.073@student.lu.se, eliz@gnu.org, emacs-devel@gnu.org
>> 
>>   (defcustom auto-revert-stop-on-user-input t
>> !   "When non-nil Auto-Revert Mode stops checking files on user input.
>> ! This prevents Auto Revert from interfering with your normal Emacs usage.
>> ! This option controls when files are auto-reverted, not which files
>> ! are auto-reverted.  Modified files are never auto-reverted,
>> ! regardless of the value of this option."
>
> I don't see why the doc string should mention modified files.
> Modified files have nothing to do with this option.

Actually, modified files have _everything_ to do with autorevert-mode.

But I think that in this case "modified buffers" was much more likely
the intended meaning, and this should be changed accordingly.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-11 16:51                         ` David Kastrup
@ 2005-02-11 19:38                           ` Luc Teirlinck
  2005-02-12 11:03                             ` Eli Zaretskii
  0 siblings, 1 reply; 40+ messages in thread
From: Luc Teirlinck @ 2005-02-11 19:38 UTC (permalink / raw)
  Cc: lennart.borgman.073, eliz, emacs-devel

Sorry, I mistakenly used the word "file" where "buffer" was meant.
Of course, the option has nothing to do with modified buffers either,
but it is exactly the purpose of the patch to point this out.

"on user input" could be misinterpreted as meaning "after you modify
the buffer" and "checking files" could be misunderstood as implicitly
meaning to revert them, so the user could get the impression that if
he sets the option to nil, autorevert will even autorevert modified
buffers.  For instance, I had the impression that this was how Lennart
understood it, when he said that the option "did not work".

===File ~/autorevert-diff-b=================================
*** autorevert.el	29 Dec 2004 21:08:55 -0600	1.42
--- autorevert.el	06 Feb 2005 10:48:08 -0600	
***************
*** 150,156 ****
		 (auto-revert-set-timer))))

  (defcustom auto-revert-stop-on-user-input t
!   "When non-nil Auto-Revert Mode stops checking files on user input."
    :group 'auto-revert
    :type 'boolean)

--- 150,160 ----
		 (auto-revert-set-timer))))

  (defcustom auto-revert-stop-on-user-input t
!   "When non-nil Auto-Revert Mode stops checking files on user input.
! This prevents Auto Revert from interfering with your normal Emacs usage.
! This option controls when buffers are auto-reverted, not which buffers
! are auto-reverted.  Modified buffers are never auto-reverted,
! regardless of the value of this option."
    :group 'auto-revert
    :type 'boolean)

============================================================

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-11  0:33                     ` Luc Teirlinck
  2005-02-11 15:40                       ` Eli Zaretskii
@ 2005-02-12  8:37                       ` Richard Stallman
  2005-02-13  1:41                         ` Luc Teirlinck
  1 sibling, 1 reply; 40+ messages in thread
From: Richard Stallman @ 2005-02-12  8:37 UTC (permalink / raw)
  Cc: lennart.borgman.073, eliz, teirllm, emacs-devel

    !   "When non-nil Auto-Revert Mode stops checking files on user input.

I don't understand that sentence.  Does it mean,

  "When nil, Auto-Revert Mode checks files on user input--otherwise, it doesn't?

If so, what does it mean to "check files on user input"?

    ! This prevents Auto Revert from interfering with your normal Emacs usage.

That is so general that it doesn't mean much.  What kind of
"interference" does it refer to?

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-11 19:38                           ` Luc Teirlinck
@ 2005-02-12 11:03                             ` Eli Zaretskii
  0 siblings, 0 replies; 40+ messages in thread
From: Eli Zaretskii @ 2005-02-12 11:03 UTC (permalink / raw)
  Cc: lennart.borgman.073, emacs-devel

> Date: Fri, 11 Feb 2005 13:38:23 -0600 (CST)
> From: Luc Teirlinck <teirllm@dms.auburn.edu>
> CC: eliz@gnu.org, lennart.borgman.073@student.lu.se, emacs-devel@gnu.org
> 
> Sorry, I mistakenly used the word "file" where "buffer" was meant.

I understood that, and this is why I objected to mentioning modified
files in the doc string.

> Of course, the option has nothing to do with modified buffers either,
> but it is exactly the purpose of the patch to point this out.

I'm certain that you didn't mean to mention something that is
unrelated to the option, as the above sentence seems to imply.

> "on user input" could be misinterpreted as meaning "after you modify
> the buffer"

If ``user input'' is ambiguous, it would be okay to explain in more
clear manner what user input means.

> and "checking files" could be misunderstood as implicitly
> meaning to revert them

It would be okay to explain that as well, so that the confusing text
is replaced with a more clear one.

But mentioning modified buffers is not the way to make these
explanations more clear, IMHO.  On the contrary, it might make things
more confusing, since it makes the doc string less self-contained.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-12  8:37                       ` Richard Stallman
@ 2005-02-13  1:41                         ` Luc Teirlinck
  2005-02-13  4:36                           ` Eli Zaretskii
  0 siblings, 1 reply; 40+ messages in thread
From: Luc Teirlinck @ 2005-02-13  1:41 UTC (permalink / raw)
  Cc: lennart.borgman.073, eliz, emacs-devel

What about the following docstring?

===File ~/autorevert-diff===================================
diff -c /home/teirllm/emacscvsdir/emacs/lisp/autorevert.el.\~1.42.\~ /home/teirllm/emacscvsdir/emacs/lisp/autorevert.el
*** /home/teirllm/emacscvsdir/emacs/lisp/autorevert.el.~1.42.~	Wed Dec 29 21:08:55 2004
--- /home/teirllm/emacscvsdir/emacs/lisp/autorevert.el	Sat Feb 12 19:22:19 2005
***************
*** 150,156 ****
  	      (auto-revert-set-timer))))
  
  (defcustom auto-revert-stop-on-user-input t
!   "When non-nil Auto-Revert Mode stops checking files on user input."
    :group 'auto-revert
    :type 'boolean)
  
--- 150,161 ----
  	      (auto-revert-set-timer))))
  
  (defcustom auto-revert-stop-on-user-input t
!   "When non-nil, user input temporarily interrupts Auto-Revert Mode.
! When nil, Auto-Revert Mode checks files and reverts buffers, with
! quitting disabled, without paying attention to user input.  Thus,
! Emacs could appear to be hung for a while.  When non-nil,
! Auto-Revert Mode checks for user input after handling each buffer
! and does not process any further buffers (until the next run of
! the timer) if user input is available."
    :group 'auto-revert
    :type 'boolean)

Diff finished.  Sat Feb 12 19:24:50 2005
============================================================

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-13  1:41                         ` Luc Teirlinck
@ 2005-02-13  4:36                           ` Eli Zaretskii
  2005-02-15  3:05                             ` Luc Teirlinck
  0 siblings, 1 reply; 40+ messages in thread
From: Eli Zaretskii @ 2005-02-13  4:36 UTC (permalink / raw)
  Cc: lennart.borgman.073, rms, emacs-devel

> Date: Sat, 12 Feb 2005 19:41:53 -0600 (CST)
> From: Luc Teirlinck <teirllm@dms.auburn.edu>
> CC: lennart.borgman.073@student.lu.se, eliz@gnu.org, emacs-devel@gnu.org
> 
>   (defcustom auto-revert-stop-on-user-input t
> !   "When non-nil, user input temporarily interrupts Auto-Revert Mode.
> ! When nil, Auto-Revert Mode checks files and reverts buffers, with
> ! quitting disabled, without paying attention to user input.  Thus,
> ! Emacs could appear to be hung for a while.  When non-nil,
> ! Auto-Revert Mode checks for user input after handling each buffer
> ! and does not process any further buffers (until the next run of
> ! the timer) if user input is available."

I think you should describe the effects of each possible value (nil
and non-nil) without intermixing them.  The way this doc string goes,
it's confusing: first you say what happens under a non-nil value, then
under nil value, then again under non-nil.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
@ 2005-02-14 20:18 moheb1333
  2006-01-01 16:10 ` Richard M. Stallman
  0 siblings, 1 reply; 40+ messages in thread
From: moheb1333 @ 2005-02-14 20:18 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 5597 bytes --]

Hi,
Thanks for all the responses to my proposed patch. Autorevert doesn't quite do
what Lennart and I want because it is not deterministic, i.e., depends on some
frequency value to be set. Also it has to be turned on/off for each buffer
unless you set it globally. Problem with global setting is that you might
forget that buffers are automatically reverted unless some message or symbol
appears on the modeline.
Following Lennart's idea, I added a flag to the buffer struct
(leaveBufferAlone) which persists the state of whether the user chose to ignore
that the buffer file was changed on disk or not. When working with an IDE, the
popup provides a symmetric editing experience in that emacs and the IDE notify
the user whenever the file is changed on disk and give him/her the chance to
ignore or revert. In the case of emacs, this works fine with
ask-user-about-supersession-threat if user chooses not to revert. When he/she
finally saves the buffer, the leaveBufferAlone flag is reset. It is also a bit
more efficient than the current emacs functionality in that it involves one
less key stroke. Currently, if the file is changed on disk you have to do an
edit action in order to get to choose to revert or not via
ask-user-about-supersession-threat whereas with the popup, you'll get the
message by switching to the buffer or when the emacs frame gets the focus if
the buffer is currently visited.
Moheb
cvs diff: Diffing nt
Index: nt/nmake.defs
===================================================================
RCS file: /cvsroot/emacs/emacs/nt/nmake.defs,v
retrieving revision 1.20
diff -w -r1.20 nmake.defs
132a133,136
> 
> 
> USER_CFLAGS = -DUSING_WITH_IDE
> 
cvs diff: Diffing src
Index: src/buffer.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/buffer.c,v
retrieving revision 1.473
diff -w -r1.473 buffer.c
55a56,59
> #if USING_WITH_IDE
> #include "w32term.h"
> #endif 
> 
684a689,693
> 
> #if USING_WITH_IDE
>  b->leaveBufferAlone = 0;
> #endif
>  
1662a1672,1676
> #if USING_WITH_IDE
>   Lisp_Object buf;
>   HWND hwnd = FRAME_W32_WINDOW (SELECTED_FRAME ());   
> #endif  
> 
1670a1685,1720
> #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))) &&
>    current_buffer->leaveBufferAlone == 0)
>     {
>       int fileChangedDialogAnswer = MessageBox (NULL, "Buffer file changed on disk, revert?", "Emacs", MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL|MB_SETFOREGROUND);
>    char msg[80];    
>       
>       if (fileChangedDialogAnswer == IDYES)
>         {
>      /* reset the don't change flag */
>      current_buffer->leaveBufferAlone = 0;
>           call3 (intern ("revert-buffer"), Qt, Qt, Qt);
>           strcpy(msg, "File reverted: ");
>           strcat(msg, XSTRING(current_buffer->filename)->data);    
>           message (msg);
>           SetFocus(hwnd);
>         }
>    else
>     {
>      /* persist that the question was asked and the answer was no */
>      current_buffer->leaveBufferAlone = 1;  
>      strcpy(msg, "File changed on disk: ");
>      strcat(msg, XSTRING(current_buffer->filename)->data);
>      message (msg);
>      SetFocus(hwnd);        
>     }
>     }
>   
>   return buf;
> #else
1671a1722
> #endif 
Index: src/buffer.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/buffer.h,v
retrieving revision 1.100
diff -w -r1.100 buffer.h
510a511,515
> #if USING_WITH_IDE
>  /* for persistance when buffer file changes on disk */
>  int leaveBufferAlone;
> #endif  
> 
Index: src/fileio.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/fileio.c,v
retrieving revision 1.526
diff -w -r1.526 fileio.c
5276a5277,5281
> #if USING_WITH_IDE
>  /* reset leaveBufferAlone flag */
>  current_buffer->leaveBufferAlone = 0;
> #endif  
> 
Index: src/w32fns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32fns.c,v
retrieving revision 1.246
diff -w -r1.246 w32fns.c
3558a3559,3590
> #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))) &&
>      current_buffer->leaveBufferAlone == 0) 
>           {
>       int fileChangedDialogAnswer = MessageBox (NULL, "Buffer file changed on disk, revert?", "Emacs", MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL|MB_SETFOREGROUND);
>             char msg[80];
>             
>             if (fileChangedDialogAnswer == IDYES)
>               {
>         /* reset the flag */
>         current_buffer->leaveBufferAlone = 0;
>                 call3 (intern ("revert-buffer"), Qt, Qt, Qt);
>                 strcpy(msg, "File reverted: ");
>                 strcat(msg, XSTRING(current_buffer->filename)->data);    
>                 message (msg);
>         SetFocus(hwnd);
>               }
>       else
>        {
>         /* don't let the dialog to be annoying */
>         current_buffer->leaveBufferAlone = 1;        
>         strcpy(msg, "File changed on disk: ");
>         strcat(msg, XSTRING(current_buffer->filename)->data);
>         message (msg);
>         SetFocus(hwnd);        
>        }
>           }
> #endif   

[-- Attachment #1.2: Type: text/html, Size: 9216 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-13  4:36                           ` Eli Zaretskii
@ 2005-02-15  3:05                             ` Luc Teirlinck
  2005-02-15  4:59                               ` Eli Zaretskii
  2005-02-16  9:31                               ` Richard Stallman
  0 siblings, 2 replies; 40+ messages in thread
From: Luc Teirlinck @ 2005-02-15  3:05 UTC (permalink / raw)
  Cc: lennart.borgman.073, rms, emacs-devel

Eli Zaretskii wrote:
   
   I think you should describe the effects of each possible value (nil
   and non-nil) without intermixing them.  The way this doc string goes,
   it's confusing: first you say what happens under a non-nil value, then
   under nil value, then again under non-nil.

What about the following?

(defcustom auto-revert-stop-on-user-input t
  "When non-nil, user input temporarily interrupts Auto-Revert Mode.
More precisely, Auto-Revert Mode checks for user input after
handling each buffer and does not process any further
buffers (until the next run of the timer) if user input is
available.  When nil, Auto-Revert Mode checks files and reverts
buffers, with quitting disabled, without paying attention to user
input.  Thus, Emacs could appear to be hung for a while."
  :group 'auto-revert
  :type 'boolean)

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  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
  1 sibling, 1 reply; 40+ messages in thread
From: Eli Zaretskii @ 2005-02-15  4:59 UTC (permalink / raw)
  Cc: lennart.borgman.073, rms, emacs-devel

> Date: Mon, 14 Feb 2005 21:05:01 -0600 (CST)
> From: Luc Teirlinck <teirllm@dms.auburn.edu>
> CC: lennart.borgman.073@student.lu.se, rms@gnu.org, emacs-devel@gnu.org
> 
> What about the following?
> 
> (defcustom auto-revert-stop-on-user-input t
>   "When non-nil, user input temporarily interrupts Auto-Revert Mode.
> More precisely, Auto-Revert Mode checks for user input after
> handling each buffer and does not process any further
> buffers (until the next run of the timer) if user input is
> available.  When nil, Auto-Revert Mode checks files and reverts
> buffers, with quitting disabled, without paying attention to user
> input.  Thus, Emacs could appear to be hung for a while."
>   :group 'auto-revert
>   :type 'boolean)

I think this is okay, except that I'd remove "More precisely", and
replace the last sentence with something like

   Thus, Emacs could appear sluggish in reacting to user input.

(I don't like telling users that Emacs appears to be hung.)

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-15  4:59                               ` Eli Zaretskii
@ 2005-02-16  2:59                                 ` moheb missaghi
  0 siblings, 0 replies; 40+ messages in thread
From: moheb missaghi @ 2005-02-16  2:59 UTC (permalink / raw)


Hi,

I posted the following yesterday but I am not sure if it made it to the 
list.
Sorry if it did post but noone chose to comment.

Thanks for all the responses to my proposed patch. Autorevert doesn't quite 
do
what Lennart and I want because it is not deterministic, i.e., depends on 
some
frequency value to be set. Also it has to be turned on/off for each buffer
unless you set it globally. Problem with global setting is that you might
forget that buffers are automatically reverted unless some message or symbol
appears on the modeline.

Following Lennart's idea, I added a flag to the buffer struct
(leaveBufferAlone) which persists the state of whether the user chose to 
ignore
that the buffer file was changed on disk or not. When working with an IDE, 
the
popup provides a symmetric editing experience in that emacs and the IDE 
notify
the user whenever the file is changed on disk (by the other) and give 
him/her
the chance to ignore or revert. In the case of emacs, this works fine with
ask-user-about-supersession-threat, if user chooses not to revert. When 
he/she
finally saves the buffer, the leaveBufferAlone flag is reset. It is also a 
bit
more efficient than the current emacs functionality in that it involves one
less key stroke. Currently, if the file is changed on disk you have to do an
edit action in order to get to choose to revert or not via
ask-user-about-supersession-threat (which is a bit annoying to my taste!)
whereas with the popup, you'll get the message as soon as you switch to the
buffer or as soon as the emacs frame gets the focus if the buffer is 
currently
visited. The new code follows.

Regards,

Moheb

cvs diff: Diffing nt
Index: nt/nmake.defs
===================================================================
RCS file: /cvsroot/emacs/emacs/nt/nmake.defs,v
retrieving revision 1.20
diff -w -r1.20 nmake.defs
132a133,136
>
>
> USER_CFLAGS = -DUSING_WITH_IDE
>

cvs diff: Diffing src
Index: src/buffer.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/buffer.c,v
retrieving revision 1.473
diff -w -r1.473 buffer.c
55a56,59
> #if USING_WITH_IDE
> #include "w32term.h"
> #endif
>
684a689,693
>
> #if USING_WITH_IDE
>  b->leaveBufferAlone = 0;
> #endif
>
1662a1672,1676
> #if USING_WITH_IDE
>   Lisp_Object buf;
>   HWND hwnd = FRAME_W32_WINDOW (SELECTED_FRAME ());
> #endif
>
1670a1685,1720
> #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))) &&
>    current_buffer->leaveBufferAlone == 0)
>     {
>       int fileChangedDialogAnswer = MessageBox (NULL, "Buffer file changed 
> on disk, revert?", "Emacs", 
> MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL|MB_SETFOREGROUND);
>    char msg[80];
>
>       if (fileChangedDialogAnswer == IDYES)
>         {
>      /* reset the don't change flag */
>      current_buffer->leaveBufferAlone = 0;
>           call3 (intern ("revert-buffer"), Qt, Qt, Qt);
>           strcpy(msg, "File reverted: ");
>           strcat(msg, XSTRING(current_buffer->filename)->data);
>           message (msg);
>           SetFocus(hwnd);
>         }
>    else
>     {
>      /* persist that the question was asked and the answer was no */
>      current_buffer->leaveBufferAlone = 1;
>      strcpy(msg, "File changed on disk: ");
>      strcat(msg, XSTRING(current_buffer->filename)->data);
>      message (msg);
>      SetFocus(hwnd);
>     }
>     }
>
>   return buf;
> #else
1671a1722
> #endif
Index: src/buffer.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/buffer.h,v
retrieving revision 1.100
diff -w -r1.100 buffer.h
510a511,515
> #if USING_WITH_IDE
>  /* for persistance when buffer file changes on disk */
>  int leaveBufferAlone;
> #endif
>
Index: src/fileio.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/fileio.c,v
retrieving revision 1.526
diff -w -r1.526 fileio.c
5276a5277,5281
> #if USING_WITH_IDE
>  /* reset leaveBufferAlone flag */
>  current_buffer->leaveBufferAlone = 0;
> #endif
>
Index: src/w32fns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32fns.c,v
retrieving revision 1.246
diff -w -r1.246 w32fns.c
3558a3559,3590
> #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))) &&
>      current_buffer->leaveBufferAlone == 0)
>           {
>       int fileChangedDialogAnswer = MessageBox (NULL, "Buffer file changed 
> on disk, revert?", "Emacs", 
> MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL|MB_SETFOREGROUND);
>             char msg[80];
>
>             if (fileChangedDialogAnswer == IDYES)
>               {
>         /* reset the flag */
>         current_buffer->leaveBufferAlone = 0;
>                 call3 (intern ("revert-buffer"), Qt, Qt, Qt);
>                 strcpy(msg, "File reverted: ");
>                 strcat(msg, XSTRING(current_buffer->filename)->data);
>                 message (msg);
>         SetFocus(hwnd);
>               }
>       else
>        {
>         /* don't let the dialog to be annoying */
>         current_buffer->leaveBufferAlone = 1;
>         strcpy(msg, "File changed on disk: ");
>         strcat(msg, XSTRING(current_buffer->filename)->data);
>         message (msg);
>         SetFocus(hwnd);
>        }
>           }
> #endif

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-15  3:05                             ` Luc Teirlinck
  2005-02-15  4:59                               ` Eli Zaretskii
@ 2005-02-16  9:31                               ` Richard Stallman
  2005-02-16 10:37                                 ` David Kastrup
  1 sibling, 1 reply; 40+ messages in thread
From: Richard Stallman @ 2005-02-16  9:31 UTC (permalink / raw)
  Cc: lennart.borgman.073, eliz, emacs-devel

    What about the following?

    (defcustom auto-revert-stop-on-user-input t
      "When non-nil, user input temporarily interrupts Auto-Revert Mode.
    More precisely, Auto-Revert Mode checks for user input after
    handling each buffer and does not process any further
    buffers (until the next run of the timer) if user input is
    available.  When nil, Auto-Revert Mode checks files and reverts
    buffers, with quitting disabled, without paying attention to user
    input.  Thus, Emacs could appear to be hung for a while."

It seems clear to me.

Thanks for working on this.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-16  9:31                               ` Richard Stallman
@ 2005-02-16 10:37                                 ` David Kastrup
  2005-02-16 15:06                                   ` Luc Teirlinck
  0 siblings, 1 reply; 40+ messages in thread
From: David Kastrup @ 2005-02-16 10:37 UTC (permalink / raw)
  Cc: lennart.borgman.073, eliz, Luc Teirlinck, emacs-devel

Richard Stallman <rms@gnu.org> writes:

>     What about the following?
>
>     (defcustom auto-revert-stop-on-user-input t
>       "When non-nil, user input temporarily interrupts Auto-Revert Mode.
>     More precisely, Auto-Revert Mode checks for user input after
>     handling each buffer and does not process any further
>     buffers (until the next run of the timer) if user input is
>     available.  When nil, Auto-Revert Mode checks files and reverts
>     buffers, with quitting disabled, without paying attention to user
>     input.  Thus, Emacs could appear to be hung for a while."
>
> It seems clear to me.

Well, Eli suggested "sluggish" instead of the negatively connotated
"hung" (which usually is used for a terminal error condition), but I
think that is misleading.  I'd suggest using something like "Thus,
Emacs might be non-responsive at times."  Something like that.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-16 10:37                                 ` David Kastrup
@ 2005-02-16 15:06                                   ` Luc Teirlinck
  2005-02-16 15:21                                     ` David Kastrup
  0 siblings, 1 reply; 40+ messages in thread
From: Luc Teirlinck @ 2005-02-16 15:06 UTC (permalink / raw)
  Cc: lennart.borgman.073, eliz, rms, emacs-devel

David Kastrup wrote:

   Well, Eli suggested "sluggish" instead of the negatively connotated
   "hung" (which usually is used for a terminal error condition), but I
   think that is misleading.  I'd suggest using something like "Thus,
   Emacs might be non-responsive at times."  Something like that.

I used:

Thus, it might take a while before Emacs responds to your input.

On the other hand. I kept the "More precisely" (in the second
sentence) which Eli suggested removing, because without it things did
just not seem to flow right.  Because the first sentence of a
docstring stands out on its own, it seemed no longer clear that we
were talking about the case where the option was nil, and the sentence
_is_ repeating what was already said in the first sentence, just in
more (I believe necessary) detail.

Maybe I installed somewhat too early, but, of course, changes can
still be made if there are objections.

  "When non-nil, user input temporarily interrupts Auto-Revert Mode.
More precisely, Auto-Revert Mode checks for user input after
handling each buffer and does not process any further buffers
\(until the next run of the timer) if user input is available.
When nil, Auto-Revert Mode checks files and reverts buffers,
with quitting disabled, without paying attention to user input.
Thus, it might take a while before Emacs responds to your input."

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-16 15:06                                   ` Luc Teirlinck
@ 2005-02-16 15:21                                     ` David Kastrup
  2005-02-17  1:08                                       ` Luc Teirlinck
  0 siblings, 1 reply; 40+ messages in thread
From: David Kastrup @ 2005-02-16 15:21 UTC (permalink / raw)
  Cc: lennart.borgman.073, eliz, rms, emacs-devel

Luc Teirlinck <teirllm@dms.auburn.edu> writes:

> David Kastrup wrote:
>
>    Well, Eli suggested "sluggish" instead of the negatively
>    connotated "hung" (which usually is used for a terminal error
>    condition), but I think that is misleading.  I'd suggest using
>    something like "Thus, Emacs might be non-responsive at times."
>    Something like that.
>
> I used:
>
> Thus, it might take a while before Emacs responds to your input.

Well, I don't like that better, but that's a matter of taste, and the
one doing the work should certainly enjoy the benefits of it.

> On the other hand. I kept the "More precisely" (in the second
> sentence) which Eli suggested removing, because without it things
> did just not seem to flow right.  Because the first sentence of a
> docstring stands out on its own, it seemed no longer clear that we
> were talking about the case where the option was nil, and the
> sentence _is_ repeating what was already said in the first sentence,
> just in more (I believe necessary) detail.

But "more precisely" would imply that the first sentence was imprecise
in some manner.  I'd rather recommend "In this case, Auto-Revert
Mode..."  or "With this setting, Auto-Revert Mode...".

> Maybe I installed somewhat too early,

Oh nonsense.  If everybody waited for unanimous applause before
installing a reworded, obviously mostly improved doc string, we'd not
get Emacs 21.4 out in 2004 anymore.  Uh, I mean, uhm...

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-16 15:21                                     ` David Kastrup
@ 2005-02-17  1:08                                       ` Luc Teirlinck
  0 siblings, 0 replies; 40+ messages in thread
From: Luc Teirlinck @ 2005-02-17  1:08 UTC (permalink / raw)
  Cc: lennart.borgman.073, eliz, rms, emacs-devel

I have now installed the following:

(defcustom auto-revert-stop-on-user-input t
  "When non-nil, user input temporarily interrupts Auto-Revert Mode.
With this setting, Auto-Revert Mode checks for user input after
handling each buffer and does not process any further buffers
\(until the next run of the timer) if user input is available.
When nil, Auto-Revert Mode checks files and reverts buffers,
with quitting disabled, without paying attention to user input.
Thus, Emacs might be non-responsive at times."
  :group 'auto-revert
  :type 'boolean)

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: Popup when buffer file is changed on disk
  2005-02-14 20:18 Popup when buffer file is changed on disk moheb1333
@ 2006-01-01 16:10 ` Richard M. Stallman
  0 siblings, 0 replies; 40+ messages in thread
From: Richard M. Stallman @ 2006-01-01 16:10 UTC (permalink / raw)
  Cc: emacs-devel

I am answering old mail that got forgotten during the year.

    Following Lennart's idea, I added a flag to the buffer struct
    (leaveBufferAlone) which persists the state of whether the user chose to ignore
    that the buffer file was changed on disk or not. When working with an IDE, the
    popup provides a symmetric editing experience in that emacs and the IDE notify
    the user whenever the file is changed on disk and give him/her the chance to
    ignore or revert.

This could be a useful feature, but the implementation has two flaws:

1. It is done at the C level.

2. It only works on Windows.

Our goal is to replace proprietary operating systems, not to enhance
them; therefore, we don't want to have any Emacs features that only
work on Windows.

If you or someone implements such a feature that works on the GNU
system and is mostly implemented in Lisp, then we could install it
(after the coming release).

^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2006-01-01 16:10 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-14 20:18 Popup when buffer file is changed on disk moheb1333
2006-01-01 16:10 ` Richard M. Stallman
  -- strict thread matches above, loose matches on Subject: below --
2005-02-04  0:36 find-file-hook as illustration of Custom problems Luc Teirlinck
2005-02-05 17:38 ` Richard Stallman
2005-02-05 19:43   ` Lennart Borgman
2005-02-05 20:56     ` Popup when buffer file is changed on disk moheb missaghi
2005-02-05 22:57       ` 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

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).