0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.0.0716: not easy to start Vim cleanly

Problem:    Not easy to start Vim cleanly without changing the viminfo file.
            Not possible to know whether the -i command line flag was used.
Solution:   Add the --clean command line argument.  Add the 'viminfofile'
            option.  Add "-u DEFAULTS".
This commit is contained in:
Bram Moolenaar
2017-07-15 19:39:43 +02:00
parent a92522fbf3
commit c4da113ef9
13 changed files with 154 additions and 44 deletions

View File

@@ -433,7 +433,9 @@ vim_main2(void)
#ifndef NO_VIM_MAIN
/* Reset 'loadplugins' for "-u NONE" before "--cmd" arguments.
* Allows for setting 'loadplugins' there. */
if (params.use_vimrc != NULL && STRCMP(params.use_vimrc, "NONE") == 0)
if (params.use_vimrc != NULL
&& (STRCMP(params.use_vimrc, "NONE") == 0
|| STRCMP(params.use_vimrc, "DEFAULTS") == 0))
p_lpl = FALSE;
/* Execute --cmd arguments. */
@@ -1869,6 +1871,7 @@ command_line_scan(mparm_T *parmp)
case '-': /* "--" don't take any more option arguments */
/* "--help" give help message */
/* "--version" give version message */
/* "--clean" clean context */
/* "--literal" take files literally */
/* "--nofork" don't fork */
/* "--not-a-term" don't warn for not a term */
@@ -1886,6 +1889,11 @@ command_line_scan(mparm_T *parmp)
msg_didout = FALSE;
mch_exit(0);
}
else if (STRNICMP(argv[0] + argv_idx, "clean", 5) == 0)
{
parmp->use_vimrc = (char_u *)"DEFAULTS";
set_option_value((char_u *)"vif", 0L, (char_u *)"NONE", 0);
}
else if (STRNICMP(argv[0] + argv_idx, "literal", 7) == 0)
{
#ifdef EXPAND_FILENAMES
@@ -2318,7 +2326,7 @@ command_line_scan(mparm_T *parmp)
#endif
case 'i': /* "-i {viminfo}" use for viminfo */
use_viminfo = (char_u *)argv[0];
set_option_value((char_u *)"vif", 0L, (char_u *)argv[0], 0);
break;
case 's': /* "-s {scriptin}" read from script file */
@@ -2988,7 +2996,9 @@ source_startup_scripts(mparm_T *parmp)
*/
if (parmp->use_vimrc != NULL)
{
if (STRCMP(parmp->use_vimrc, "NONE") == 0
if (STRCMP(parmp->use_vimrc, "DEFAULTS") == 0)
do_source((char_u *)VIM_DEFAULTS_FILE, FALSE, DOSO_NONE);
else if (STRCMP(parmp->use_vimrc, "NONE") == 0
|| STRCMP(parmp->use_vimrc, "NORC") == 0)
{
#ifdef FEAT_GUI
@@ -3383,6 +3393,7 @@ usage(void)
#ifdef FEAT_VIMINFO
main_msg(_("-i <viminfo>\t\tUse <viminfo> instead of .viminfo"));
#endif
main_msg(_("--clean\t\t'nocompatible', Vim defaults, no plugins, no viminfo"));
main_msg(_("-h or --help\tPrint Help (this message) and exit"));
main_msg(_("--version\t\tPrint version information and exit"));