[patch] modelines are ignored when a file is reloaded after W11

38 views
Skip to first unread message

Ken Takata

unread,
Jan 26, 2013, 10:20:01 PM1/26/13
to vim...@googlegroups.com
Hi,

I checked on 7.3.785 with the following steps:

1.
$ vim -u NONE -N
:autocmd BufRead *.c setlocal ts=4
:e os_win32.c (This is a source file of Vim.)

At this moment, 'ts' is 8 because of the modelines in os_win32.c.

2.
Edit os_win32.c by some another application, then do :checktime.
The following message (W11) will be shown:

W11: Warning: File "os_win32.c" has changed since editing started
See ":help W11" for more info.
[O]K, (L)oad File:

Select L, then 'ts' becomes 4 because of the autocmd. The modelines
seem to be ignored.

Following patch fixes this:

--- a/src/fileio.c
+++ b/src/fileio.c
@@ -7073,6 +7073,7 @@
{
/* Reload the buffer. */
buf_reload(buf, orig_mode);
+ do_modelines(0);
#ifdef FEAT_PERSISTENT_UNDO
if (buf->b_p_udf && buf->b_ffname != NULL)
{


Actually buf_reload() is also called from spell_add_word() in spell.c,
but I'm not sure that do_modelines() is needed in spell_add_word().

Thanks,
Ken Takata

Bram Moolenaar

unread,
Jan 27, 2013, 9:22:13 AM1/27/13
to Ken Takata, vim...@googlegroups.com
Thanks. I'll verify this is the best solution.

--
Witches prefer brooms: vacuum-cleaners need extension cords!

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages