1
0
forked from aniani/vim

Disallow setting 'enc' in a modeline. (Patrick Texier)

This commit is contained in:
Bram Moolenaar
2010-07-14 21:12:05 +02:00
parent 23c347c66b
commit 865242e121
3 changed files with 21 additions and 11 deletions

View File

@@ -2436,6 +2436,9 @@ A jump table for the options with a short description can be found at |Q_op|.
It should normally be kept at its default value, or set when Vim It should normally be kept at its default value, or set when Vim
starts up. See |multibyte|. To reload the menus see |:menutrans|. starts up. See |multibyte|. To reload the menus see |:menutrans|.
This option cannot be set from a |modeline|. It would most likely
corrupt the text.
NOTE: For GTK+ 2 it is highly recommended to set 'encoding' to NOTE: For GTK+ 2 it is highly recommended to set 'encoding' to
"utf-8". Although care has been taken to allow different values of "utf-8". Although care has been taken to allow different values of
'encoding', "utf-8" is the natural choice for the environment and 'encoding', "utf-8" is the natural choice for the environment and
@@ -2619,6 +2622,7 @@ A jump table for the options with a short description can be found at |Q_op|.
feature} feature}
{not in Vi} {not in Vi}
Sets the character encoding for the file of this buffer. Sets the character encoding for the file of this buffer.
When 'fileencoding' is different from 'encoding', conversion will be When 'fileencoding' is different from 'encoding', conversion will be
done when writing the file. For reading see below. done when writing the file. For reading see below.
When 'fileencoding' is empty, the same value as 'encoding' will be When 'fileencoding' is empty, the same value as 'encoding' will be
@@ -2631,24 +2635,32 @@ A jump table for the options with a short description can be found at |Q_op|.
is most likely done in a way that the reverse conversion is most likely done in a way that the reverse conversion
results in the same text. When 'encoding' is not "utf-8" some results in the same text. When 'encoding' is not "utf-8" some
characters may be lost! characters may be lost!
See 'encoding' for the possible values. Additionally, values may be See 'encoding' for the possible values. Additionally, values may be
specified that can be handled by the converter, see specified that can be handled by the converter, see
|mbyte-conversion|. |mbyte-conversion|.
When reading a file 'fileencoding' will be set from 'fileencodings'. When reading a file 'fileencoding' will be set from 'fileencodings'.
To read a file in a certain encoding it won't work by setting To read a file in a certain encoding it won't work by setting
'fileencoding', use the |++enc| argument. One exception: when 'fileencoding', use the |++enc| argument. One exception: when
'fileencodings' is empty the value of 'fileencoding' is used. 'fileencodings' is empty the value of 'fileencoding' is used.
For a new file the global value of 'fileencoding' is used. For a new file the global value of 'fileencoding' is used.
Prepending "8bit-" and "2byte-" has no meaning here, they are ignored. Prepending "8bit-" and "2byte-" has no meaning here, they are ignored.
When the option is set, the value is converted to lowercase. Thus When the option is set, the value is converted to lowercase. Thus
you can set it with uppercase values too. '_' characters are you can set it with uppercase values too. '_' characters are
replaced with '-'. If a name is recognized from the list for replaced with '-'. If a name is recognized from the list for
'encoding', it is replaced by the standard name. For example 'encoding', it is replaced by the standard name. For example
"ISO8859-2" becomes "iso-8859-2". "ISO8859-2" becomes "iso-8859-2".
When this option is set, after starting to edit a file, the 'modified' When this option is set, after starting to edit a file, the 'modified'
option is set, because the file would be different when written. option is set, because the file would be different when written.
If you do this in a modeline, you might want to set 'nomodified' to
avoid this. Keep in mind that changing 'fenc' from a modeline happens
AFTER the text has been read, thus it applies to when the file will be
written. If you do set 'fenc' in a modeline, you might want to set
'nomodified' to avoid not being able to ":q".
This option can not be changed when 'modifiable' is off. This option can not be changed when 'modifiable' is off.
*'fe'* *'fe'*

View File

@@ -560,11 +560,6 @@ character typed. (Tyler Spivey, 2008 Sep 3) Only redraw cmdline for
'arabicshape' when there is a character on the command line for which 'arabicshape' when there is a character on the command line for which
(ARABIC_CHAR(u8c)) is TRUE. (ARABIC_CHAR(u8c)) is TRUE.
Replace ccomplete.vim by cppcomplete.vim from www.vim.org? script 1520
by Vissale Neang. (Martin Stubenschrott)
Asked Vissale to make the scripts more friendly for the Vim distribution.
New version received 2008 Jan 6.
Cheng Fang made javacomplete. (2007 Aug 11) Cheng Fang made javacomplete. (2007 Aug 11)
Asked about latest version: 0.77.1 is on www.vim.org. Asked about latest version: 0.77.1 is on www.vim.org.
@@ -1102,6 +1097,10 @@ Patches to possibly include:
feature. (Matt Wozniski, 2009 Apr 15) feature. (Matt Wozniski, 2009 Apr 15)
Patch go make gui highlight settings work in Vim without +gui feature. Patch go make gui highlight settings work in Vim without +gui feature.
(Matt Wozniski, 2009 Mar 27) (Matt Wozniski, 2009 Mar 27)
- Replace ccomplete.vim by cppcomplete.vim from www.vim.org? script 1520 by
Vissale Neang. (Martin Stubenschrott)
Asked Vissale to make the scripts more friendly for the Vim distribution.
New version received 2008 Jan 6.
- Patch for supporting #rrggbb in color terminals. (Matt Wozniski) - Patch for supporting #rrggbb in color terminals. (Matt Wozniski)
6 In the quickfix window statusline add the command used to get the list of 6 In the quickfix window statusline add the command used to get the list of
errors, e.g. ":make foo", ":grep something *.c". errors, e.g. ":make foo", ":grep something *.c".
@@ -1112,8 +1111,6 @@ Patches to possibly include:
Fix for invalid memory access. (Lech Lorens, 2009 Apr 17) Fix for invalid memory access. (Lech Lorens, 2009 Apr 17)
- Another patch for Javascript indenting. (Hari Kumar, 2010 Jul 11) - Another patch for Javascript indenting. (Hari Kumar, 2010 Jul 11)
Needs a few tests. Needs a few tests.
- Disable setting 'encoding' from a modeline? It usually causes problems,
can't do any good. (Patch from Patrick Texier, 2008 Dec 9)
- Redraw problem when appending digraph causes line to wrap. (James Vega, 2007 - Redraw problem when appending digraph causes line to wrap. (James Vega, 2007
Sep 18) Patch by Ian Kelling, 2008 Aug 8. Sep 18) Patch by Ian Kelling, 2008 Aug 8.
- Patch for colorscheme submenu. (Juergen Kraemer, 2008 Aug 20) - Patch for colorscheme submenu. (Juergen Kraemer, 2008 Aug 20)

View File

@@ -451,6 +451,7 @@ struct vimoption
#define P_INSECURE 0x400000L/* option was set from a modeline */ #define P_INSECURE 0x400000L/* option was set from a modeline */
#define P_PRI_MKRC 0x800000L/* priority for :mkvimrc (setting option has #define P_PRI_MKRC 0x800000L/* priority for :mkvimrc (setting option has
side effects) */ side effects) */
#define P_NO_ML 0x1000000L/* not allowed in modeline */
#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255" #define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
@@ -1015,7 +1016,7 @@ static struct vimoption
{"edcompatible","ed", P_BOOL|P_VI_DEF, {"edcompatible","ed", P_BOOL|P_VI_DEF,
(char_u *)&p_ed, PV_NONE, (char_u *)&p_ed, PV_NONE,
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
{"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR, {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
#ifdef FEAT_MBYTE #ifdef FEAT_MBYTE
(char_u *)&p_enc, PV_NONE, (char_u *)&p_enc, PV_NONE,
{(char_u *)ENC_DFLT, (char_u *)0L} {(char_u *)ENC_DFLT, (char_u *)0L}
@@ -4236,7 +4237,7 @@ do_set(arg, opt_flags)
/* Disallow changing some options from modelines. */ /* Disallow changing some options from modelines. */
if (opt_flags & OPT_MODELINE) if (opt_flags & OPT_MODELINE)
{ {
if (flags & P_SECURE) if (flags & (P_SECURE | P_NO_ML))
{ {
errmsg = (char_u *)_("E520: Not allowed in a modeline"); errmsg = (char_u *)_("E520: Not allowed in a modeline");
goto skip; goto skip;