Discussion:
[PATCH] Add "Load/Ignore All" buttons to "File changed" dialog
björn
2008-10-18 18:35:40 UTC
Permalink
Hi all,

I have seen quite a few comments on how annoying the "File changed"
dialog can be when many files have been modified outside Vim.
Currently there is no way to simply say "Load All" files (short of
setting 'autoread' but maybe you don't always want this on), instead
there is one dialog for each modified file and clicking through more
than one of these is just too much.

The nicest solutions to this problem I can think of are:
1. Check how many files have been modified and put up a dialog saying
something like "Several files were modified outside Vim" and then give
the option of reloading/ignoring all, or to go in and choose what to
do with each file.
2. Have a checkbox in the current dialog saying "Apply to all files"
so if you tick the checkbox and then click "Load File" all files will
be reloaded automatically.

Both seem too difficult to implement: 1 doesn't fit with how the
source code works and would require a big change, 2 would be even more
problematic since there is no support for adding check boxes to
dialogs.

So, instead I simply added two more buttons to the current dialog: a
"Load &All" button and a "&Ignore All" button. This is a bit weird
when only one file has changed but at least now you don't have to see
this dialog more than once unless you choose to.

I realize Bram won't be reading this post for a while, but I thought
I'd put this patch out there anyway for the rest of you to look at.

Björn


*** src/fileio.c 2008-10-18 20:32:08.000000000 +0200
--- mysrc/fileio.c 2008-10-18 20:32:06.000000000 +0200
***************
*** 6232,6237 ****
--- 6232,6240 ----
}

static int already_warned = FALSE;
+ #if defined(FEAT_CON_DIALOG) || defined(FEAT_GUI_DIALOG)
+ static int default_reload_choice = 0;
+ #endif

/*
* Check if any not hidden buffer has been changed.
***************
*** 6274,6279 ****
--- 6277,6285 ----
++no_wait_return;
did_check_timestamps = TRUE;
already_warned = FALSE;
+ #if defined(FEAT_CON_DIALOG) || defined(FEAT_GUI_DIALOG)
+ default_reload_choice = 0;
+ #endif
for (buf = firstbuf; buf != NULL; )
{
/* Only check buffers in a window. */
***************
*** 6292,6297 ****
--- 6298,6306 ----
}
buf = buf->b_next;
}
+ #if defined(FEAT_CON_DIALOG) || defined(FEAT_GUI_DIALOG)
+ default_reload_choice = 0;
+ #endif
--no_wait_return;
need_check_timestamps = FALSE;
if (need_wait_return && didit == 2)
***************
*** 6551,6559 ****
STRCAT(tbuf, "\n");
STRCAT(tbuf, mesg2);
}
! if (do_dialog(VIM_WARNING, (char_u *)_("Warning"), tbuf,
! (char_u *)_("&OK\n&Load File"), 1, NULL) == 2)
! reload = TRUE;
}
else
#endif
--- 6560,6586 ----
STRCAT(tbuf, "\n");
STRCAT(tbuf, mesg2);
}
! if (default_reload_choice > 0)
! {
! if (default_reload_choice == 2)
! reload = TRUE;
! }
! else
! {
! switch (do_dialog(VIM_WARNING, (char_u *)_("Warning"), tbuf,
! (char_u *)_("&OK\n&Load File\nLoad &All\n&Ignore All"),
! 1, NULL))
! {
! case 3:
! default_reload_choice = 2;
! case 2:
! reload = TRUE;
! break;
! case 4:
! default_reload_choice = 1;
! break;
! }
! }
}
else
#endif

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Tony Mechelynck
2008-10-18 19:02:16 UTC
Permalink
Post by björn
Hi all,
I have seen quite a few comments on how annoying the "File changed"
dialog can be when many files have been modified outside Vim.
Currently there is no way to simply say "Load All" files (short of
setting 'autoread' but maybe you don't always want this on), instead
there is one dialog for each modified file and clicking through more
than one of these is just too much.
[...]

You can intercept the FileChangedShell event:

:au FileChangedShell * let v:fcs_choice = "reload"

However, if it happens to you often and for many files at a time, maybe
you should change your editing habits. I almost never get that dialog,
and when I do it's because I've let it happen by keeping open in Vim a
file which I knew would be changed outside of it. When it does happen,
loading the file is not always what I want to do: sometimes I prefer to
"Cancel" the dialog then ":quit!" the file in question (with bang).


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
212. Your Internet group window has more icons than your Accessories window.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Stephan Hegel
2008-10-19 03:51:23 UTC
Permalink
Hi,

Just one remark showing another use case where this dialog isn't wanted.
Post by Tony Mechelynck
:au FileChangedShell * let v:fcs_choice = "reload"
However, if it happens to you often and for many files at a time, maybe
you should change your editing habits.
The dialog pops up also when the access rights have been changed. And this
can happen when you work with particular version control systems and you
check the files or directories in or out. Its like a chmod a-w, a+w.

It's a quite common use case for me to have 10 or even more files open in
tabs as they belong to one software module. If I check them frequently in
and out using the command line, you can imagine what happens ...

Anyway, Tony, thanks for the hint with the FileChangedShell interception.

Rgds,
Stephan.



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Tony Mechelynck
2008-10-19 14:02:14 UTC
Permalink
Post by björn
I realize Bram won't be reading this post for a while, but I thought
I'd put this patch out there anyway for the rest of you to look at.
The patch doesn't apply because the = signs are encoded quoted-printable
(=3D), even though they are in the ASCII charset.
Markus
To translate the quoted-printable, create the patch file by
cut-and-paste from your mail client (the "message" display, not the
"view source" display, of course).


Best regards,
Tony.
--
Living in LA is like not having a date on Saturday night.
-- Candice Bergen


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Tony Mechelynck
2008-10-19 15:31:02 UTC
Permalink
Post by Tony Mechelynck
The patch doesn't apply because the = signs are encoded quoted-printable
(=3D), even though they are in the ASCII charset.
Markus
To translate the quoted-printable, create the patch file by
cut-and-paste from your mail client (the "message" display, not the
"view source" display, of course).
Do you know how to work with KMail? It mangles whitespace when copying from
the message window. What I can do is starting the editor window and copy from
there. And I don't copy& paste from the source window, I just save the mail
as mbox, of course. Inline patches shouldn't contain quoted-printable. Maybe
it wouldn't have been encoded without the umlaut in his name.
Markus
I agree they shouldn't, but the sender isn't always responsible: I've
seen mail headers added by my own ISP's mail routers, saying they had
converted the message from 8bit to quoted-printable or vice-versa. I
think the only way to make sure no conversions are done while in transit
is to send the patch as attachment.

I obtained the attached file by copying from SeaMonkey Mail and pasting
into gvim. I haven't tried to use it as input to the patch program but
it looks like a proper patch to me.


Best regards,
Tony.
--
War hath no fury like a non-combatant.
-- Charles Edward Montague

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Markus Heidelberg
2008-10-19 16:08:53 UTC
Permalink
Post by Tony Mechelynck
Post by Tony Mechelynck
The patch doesn't apply because the = signs are encoded quoted-printable
(=3D), even though they are in the ASCII charset.
Markus
To translate the quoted-printable, create the patch file by
cut-and-paste from your mail client (the "message" display, not the
"view source" display, of course).
Do you know how to work with KMail? It mangles whitespace when copying from
the message window. What I can do is starting the editor window and copy from
there. And I don't copy& paste from the source window, I just save the mail
as mbox, of course. Inline patches shouldn't contain quoted-printable. Maybe
it wouldn't have been encoded without the umlaut in his name.
Markus
I agree they shouldn't, but the sender isn't always responsible: I've
seen mail headers added by my own ISP's mail routers, saying they had
converted the message from 8bit to quoted-printable or vice-versa. I
think the only way to make sure no conversions are done while in transit
is to send the patch as attachment.
I obtained the attached file by copying from SeaMonkey Mail and pasting
into gvim. I haven't tried to use it as input to the patch program but
it looks like a proper patch to me.
Best regards,
Tony.
Oops, sorry, didn't work. Let's try again.
Aha, the BOM.

Markus


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Tony Mechelynck
2008-10-19 15:39:42 UTC
Permalink
Post by Tony Mechelynck
Post by Tony Mechelynck
The patch doesn't apply because the = signs are encoded quoted-printable
(=3D), even though they are in the ASCII charset.
Markus
To translate the quoted-printable, create the patch file by
cut-and-paste from your mail client (the "message" display, not the
"view source" display, of course).
Do you know how to work with KMail? It mangles whitespace when copying from
the message window. What I can do is starting the editor window and copy from
there. And I don't copy& paste from the source window, I just save the mail
as mbox, of course. Inline patches shouldn't contain quoted-printable. Maybe
it wouldn't have been encoded without the umlaut in his name.
Markus
I agree they shouldn't, but the sender isn't always responsible: I've
seen mail headers added by my own ISP's mail routers, saying they had
converted the message from 8bit to quoted-printable or vice-versa. I
think the only way to make sure no conversions are done while in transit
is to send the patch as attachment.
I obtained the attached file by copying from SeaMonkey Mail and pasting
into gvim. I haven't tried to use it as input to the patch program but
it looks like a proper patch to me.
Best regards,
Tony.
Oops, sorry, didn't work. Let's try again.

Best regards,
Tony.
--
The assertion that "all men are created equal" was of no practical use
in effecting our separation from Great Britain and it was placed in the
Declaration not for that, but for future use.
-- Abraham Lincoln

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Markus Heidelberg
2008-10-19 14:52:54 UTC
Permalink
Post by Tony Mechelynck
The patch doesn't apply because the = signs are encoded quoted-printable
(=3D), even though they are in the ASCII charset.
Markus
To translate the quoted-printable, create the patch file by
cut-and-paste from your mail client (the "message" display, not the
"view source" display, of course).
Do you know how to work with KMail? It mangles whitespace when copying from
the message window. What I can do is starting the editor window and copy from
there. And I don't copy & paste from the source window, I just save the mail
as mbox, of course. Inline patches shouldn't contain quoted-printable. Maybe
it wouldn't have been encoded without the umlaut in his name.

Markus


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Nico Weber
2008-10-19 16:20:25 UTC
Permalink
Post by Tony Mechelynck
The patch doesn't apply because the = signs are encoded quoted-
printable
(=3D), even though they are in the ASCII charset.
Markus
To translate the quoted-printable, create the patch file by
cut-and-paste from your mail client (the "message" display, not the
"view source" display, of course).
Do you know how to work with KMail? It mangles whitespace when
copying from
the message window. What I can do is starting the editor window and copy from
there. And I don't copy & paste from the source window, I just save the mail
as mbox, of course. Inline patches shouldn't contain quoted-
printable. Maybe
it wouldn't have been encoded without the umlaut in his name.
As the quoted-printed problem happens more often than it should, I
have the following in my .vimrc (all one line):

command QPd %!python -c 'import fileinput, quopri; print
quopri.decodestring("".join(list(fileinput.input())))'

It converts the current buffer from quoted-printable to normal text.

Nico

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Markus Heidelberg
2008-10-19 14:04:40 UTC
Permalink
The patch doesn't apply because the = signs are encoded quoted-printable
(=3D), even though they are in the ASCII charset.
I've attached an archive containing the patch to this post -- let me
know if there still are problems applying the patch.
This one applies with offset. But putting it in an archive wasn't necessary I
think, particularly the tar part.

Markus


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
björn
2008-10-19 13:41:36 UTC
Permalink
The patch doesn't apply because the = signs are encoded quoted-printable
(=3D), even though they are in the ASCII charset.
I've attached an archive containing the patch to this post -- let me
know if there still are problems applying the patch.

Björn

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Markus Heidelberg
2008-10-19 13:05:35 UTC
Permalink
Post by björn
I realize Bram won't be reading this post for a while, but I thought
I'd put this patch out there anyway for the rest of you to look at.
The patch doesn't apply because the = signs are encoded quoted-printable
(=3D), even though they are in the ASCII charset.

Markus


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Continue reading on narkive:
Loading...