mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
updated for version 7.4a.041
Problem: When using ":new ++ff=unix" and "dos" is first in 'fileformats' then 'ff' is set to "dos" instead of "unix". (Ingo Karkat) Solution: Create set_file_options() and invoke it from do_ecmd().
This commit is contained in:
parent
e24a9c0b59
commit
ad875fb7ff
@ -3448,9 +3448,13 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags, oldwin)
|
|||||||
curwin->w_buffer = buf;
|
curwin->w_buffer = buf;
|
||||||
curbuf = buf;
|
curbuf = buf;
|
||||||
++curbuf->b_nwindows;
|
++curbuf->b_nwindows;
|
||||||
/* set 'fileformat' */
|
|
||||||
if (*p_ffs && !oldbuf)
|
/* Set 'fileformat', 'binary' and 'fenc' when forced. */
|
||||||
set_fileformat(default_fileformat(), OPT_LOCAL);
|
if (!oldbuf && eap != NULL)
|
||||||
|
{
|
||||||
|
set_file_options(TRUE, eap);
|
||||||
|
set_forced_fenc(eap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* May get the window options from the last time this buffer
|
/* May get the window options from the last time this buffer
|
||||||
|
78
src/fileio.c
78
src/fileio.c
@ -474,23 +474,8 @@ readfile(fname, sfname, from, lines_to_skip, lines_to_read, eap, flags)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* set default 'fileformat' */
|
/* Set default or forced 'fileformat' and 'binary'. */
|
||||||
if (set_options)
|
set_file_options(set_options, eap);
|
||||||
{
|
|
||||||
if (eap != NULL && eap->force_ff != 0)
|
|
||||||
set_fileformat(get_fileformat_force(curbuf, eap), OPT_LOCAL);
|
|
||||||
else if (*p_ffs != NUL)
|
|
||||||
set_fileformat(default_fileformat(), OPT_LOCAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set or reset 'binary' */
|
|
||||||
if (eap != NULL && eap->force_bin != 0)
|
|
||||||
{
|
|
||||||
int oldval = curbuf->b_p_bin;
|
|
||||||
|
|
||||||
curbuf->b_p_bin = (eap->force_bin == FORCE_BIN);
|
|
||||||
set_options_bin(oldval, curbuf->b_p_bin, OPT_LOCAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When opening a new file we take the readonly flag from the file.
|
* When opening a new file we take the readonly flag from the file.
|
||||||
@ -647,15 +632,9 @@ readfile(fname, sfname, from, lines_to_skip, lines_to_read, eap, flags)
|
|||||||
check_marks_read();
|
check_marks_read();
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
if (eap != NULL && eap->force_enc != 0)
|
/* Set forced 'fileencoding'. */
|
||||||
{
|
if (eap != NULL)
|
||||||
/* set forced 'fileencoding' */
|
set_forced_fenc(eap);
|
||||||
fenc = enc_canonize(eap->cmd + eap->force_enc);
|
|
||||||
if (fenc != NULL)
|
|
||||||
set_string_option_direct((char_u *)"fenc", -1,
|
|
||||||
fenc, OPT_FREE|OPT_LOCAL, 0);
|
|
||||||
vim_free(fenc);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEAT_AUTOCMD
|
#ifdef FEAT_AUTOCMD
|
||||||
apply_autocmds_exarg(EVENT_BUFNEWFILE, sfname, sfname,
|
apply_autocmds_exarg(EVENT_BUFNEWFILE, sfname, sfname,
|
||||||
@ -2738,7 +2717,52 @@ prep_exarg(eap, buf)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FEAT_MBYTE
|
/*
|
||||||
|
* Set default or forced 'fileformat' and 'binary'.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
set_file_options(set_options, eap)
|
||||||
|
int set_options;
|
||||||
|
exarg_T *eap;
|
||||||
|
{
|
||||||
|
/* set default 'fileformat' */
|
||||||
|
if (set_options)
|
||||||
|
{
|
||||||
|
if (eap != NULL && eap->force_ff != 0)
|
||||||
|
set_fileformat(get_fileformat_force(curbuf, eap), OPT_LOCAL);
|
||||||
|
else if (*p_ffs != NUL)
|
||||||
|
set_fileformat(default_fileformat(), OPT_LOCAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set or reset 'binary' */
|
||||||
|
if (eap != NULL && eap->force_bin != 0)
|
||||||
|
{
|
||||||
|
int oldval = curbuf->b_p_bin;
|
||||||
|
|
||||||
|
curbuf->b_p_bin = (eap->force_bin == FORCE_BIN);
|
||||||
|
set_options_bin(oldval, curbuf->b_p_bin, OPT_LOCAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(FEAT_MBYTE) || defined(PROTO)
|
||||||
|
/*
|
||||||
|
* Set forced 'fileencoding'.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
set_forced_fenc(eap)
|
||||||
|
exarg_T *eap;
|
||||||
|
{
|
||||||
|
if (eap->force_enc != 0)
|
||||||
|
{
|
||||||
|
char_u *fenc = enc_canonize(eap->cmd + eap->force_enc);
|
||||||
|
|
||||||
|
if (fenc != NULL)
|
||||||
|
set_string_option_direct((char_u *)"fenc", -1,
|
||||||
|
fenc, OPT_FREE|OPT_LOCAL, 0);
|
||||||
|
vim_free(fenc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find next fileencoding to use from 'fileencodings'.
|
* Find next fileencoding to use from 'fileencodings'.
|
||||||
* "pp" points to fenc_next. It's advanced to the next item.
|
* "pp" points to fenc_next. It's advanced to the next item.
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
void filemess __ARGS((buf_T *buf, char_u *name, char_u *s, int attr));
|
void filemess __ARGS((buf_T *buf, char_u *name, char_u *s, int attr));
|
||||||
int readfile __ARGS((char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_skip, linenr_T lines_to_read, exarg_T *eap, int flags));
|
int readfile __ARGS((char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_skip, linenr_T lines_to_read, exarg_T *eap, int flags));
|
||||||
int prep_exarg __ARGS((exarg_T *eap, buf_T *buf));
|
int prep_exarg __ARGS((exarg_T *eap, buf_T *buf));
|
||||||
|
void set_file_options __ARGS((int set_options, exarg_T *eap));
|
||||||
|
void set_forced_fenc __ARGS((exarg_T *eap));
|
||||||
int prepare_crypt_read __ARGS((FILE *fp));
|
int prepare_crypt_read __ARGS((FILE *fp));
|
||||||
char_u *prepare_crypt_write __ARGS((buf_T *buf, int *lenp));
|
char_u *prepare_crypt_write __ARGS((buf_T *buf, int *lenp));
|
||||||
int check_file_readonly __ARGS((char_u *fname, int perm));
|
int check_file_readonly __ARGS((char_u *fname, int perm));
|
||||||
|
@ -3,6 +3,7 @@ vim: set ft=vim :
|
|||||||
|
|
||||||
STARTTEST
|
STARTTEST
|
||||||
:so small.vim
|
:so small.vim
|
||||||
|
:so mbyte.vim
|
||||||
:"
|
:"
|
||||||
:" Test for getbufvar()
|
:" Test for getbufvar()
|
||||||
:" Use strings to test for memory leaks.
|
:" Use strings to test for memory leaks.
|
||||||
@ -22,6 +23,17 @@ STARTTEST
|
|||||||
:$put =string(getbufvar(1, '&autoindent'))
|
:$put =string(getbufvar(1, '&autoindent'))
|
||||||
:$put =string(getbufvar(1, '&autoindent', 1))
|
:$put =string(getbufvar(1, '&autoindent', 1))
|
||||||
:"
|
:"
|
||||||
|
:" Open new window with forced option values
|
||||||
|
:set fileformats=unix,dos
|
||||||
|
:new ++ff=dos ++bin ++enc=iso-8859-2
|
||||||
|
:let otherff = getbufvar(bufnr('%'), '&fileformat')
|
||||||
|
:let otherbin = getbufvar(bufnr('%'), '&bin')
|
||||||
|
:let otherfenc = getbufvar(bufnr('%'), '&fenc')
|
||||||
|
:close
|
||||||
|
:$put =otherff
|
||||||
|
:$put =string(otherbin)
|
||||||
|
:$put =otherfenc
|
||||||
|
:unlet otherff otherbin otherfenc
|
||||||
:" test for getwinvar()
|
:" test for getwinvar()
|
||||||
:let w:var_str = "Dance"
|
:let w:var_str = "Dance"
|
||||||
:let def_str = "Chance"
|
:let def_str = "Chance"
|
||||||
|
@ -10,6 +10,9 @@ start:
|
|||||||
'5678'
|
'5678'
|
||||||
0
|
0
|
||||||
0
|
0
|
||||||
|
dos
|
||||||
|
1
|
||||||
|
iso-8859-2
|
||||||
'Dance'
|
'Dance'
|
||||||
'Dance'
|
'Dance'
|
||||||
{'var_str': 'Dance'}
|
{'var_str': 'Dance'}
|
||||||
|
@ -727,6 +727,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
41,
|
||||||
/**/
|
/**/
|
||||||
40,
|
40,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user