Skip to content

Commit 0726870

Browse files
committed
patch 8.0.1554: custom plugins loaded with --clean
Problem: Custom plugins loaded with --clean. Solution: Do not include the home directory in 'runtimepath'.
1 parent 5f73ef8 commit 0726870

File tree

10 files changed

+48
-7
lines changed

10 files changed

+48
-7
lines changed

Diff for: runtime/doc/starting.txt

+1
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ a slash. Thus "-R" means recovery and "-/R" readonly.
516516
- the |defaults.vim| script is loaded, which implies
517517
'nocompatible': use Vim defaults
518518
- no viminfo file is read or written
519+
- the home directory is excluded from 'runtimepath'
519520
*-x*
520521
-x Use encryption to read/write files. Will prompt for a key,
521522
which is then stored in the 'key' option. All writes will

Diff for: src/main.c

+13-5
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,25 @@ main
158158

159159
#ifdef STARTUPTIME
160160
/* Need to find "--startuptime" before actually parsing arguments. */
161-
for (i = 1; i < argc; ++i)
162-
{
163-
if (STRICMP(argv[i], "--startuptime") == 0 && i + 1 < argc)
161+
for (i = 1; i < argc - 1; ++i)
162+
if (STRICMP(argv[i], "--startuptime") == 0)
164163
{
165164
time_fd = mch_fopen(argv[i + 1], "a");
166165
TIME_MSG("--- VIM STARTING ---");
167166
break;
168167
}
169-
}
170168
#endif
171169
starttime = time(NULL);
172170

171+
#ifdef CLEAN_RUNTIMEPATH
172+
/* Need to find "--clean" before actually parsing arguments. */
173+
for (i = 1; i < argc; ++i)
174+
if (STRICMP(argv[i], "--clean") == 0)
175+
{
176+
params.clean = TRUE;
177+
break;
178+
}
179+
#endif
173180
common_init(&params);
174181

175182
#ifdef FEAT_CLIENTSERVER
@@ -1024,7 +1031,7 @@ common_init(mparm_T *paramp)
10241031
* First find out the home directory, needed to expand "~" in options.
10251032
*/
10261033
init_homedir(); /* find real value of $HOME */
1027-
set_init_1();
1034+
set_init_1(paramp->clean);
10281035
TIME_MSG("inits 1");
10291036

10301037
#ifdef FEAT_EVAL
@@ -1903,6 +1910,7 @@ command_line_scan(mparm_T *parmp)
19031910
else if (STRNICMP(argv[0] + argv_idx, "clean", 5) == 0)
19041911
{
19051912
parmp->use_vimrc = (char_u *)"DEFAULTS";
1913+
parmp->clean = TRUE;
19061914
set_option_value((char_u *)"vif", 0L, (char_u *)"NONE", 0);
19071915
}
19081916
else if (STRNICMP(argv[0] + argv_idx, "literal", 7) == 0)

Diff for: src/option.c

+20-1
Original file line numberDiff line numberDiff line change
@@ -3345,9 +3345,10 @@ static int briopt_check(win_T *wp);
33453345
* Initialize the options, first part.
33463346
*
33473347
* Called only once from main(), just after creating the first buffer.
3348+
* If "clean_arg" is TRUE Vim was started with --clean.
33483349
*/
33493350
void
3350-
set_init_1(void)
3351+
set_init_1(int clean_arg)
33513352
{
33523353
char_u *p;
33533354
int opt_idx;
@@ -3554,6 +3555,24 @@ set_init_1(void)
35543555
*/
35553556
set_options_default(0);
35563557

3558+
#ifdef CLEAN_RUNTIMEPATH
3559+
if (clean_arg)
3560+
{
3561+
opt_idx = findoption((char_u *)"runtimepath");
3562+
if (opt_idx >= 0)
3563+
{
3564+
options[opt_idx].def_val[VI_DEFAULT] = (char_u *)CLEAN_RUNTIMEPATH;
3565+
p_rtp = (char_u *)CLEAN_RUNTIMEPATH;
3566+
}
3567+
opt_idx = findoption((char_u *)"packpath");
3568+
if (opt_idx >= 0)
3569+
{
3570+
options[opt_idx].def_val[VI_DEFAULT] = (char_u *)CLEAN_RUNTIMEPATH;
3571+
p_pp = (char_u *)CLEAN_RUNTIMEPATH;
3572+
}
3573+
}
3574+
#endif
3575+
35573576
#ifdef FEAT_GUI
35583577
if (found_reverse_arg)
35593578
set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);

Diff for: src/os_amiga.h

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
#ifndef DFLT_RUNTIMEPATH
4444
# define DFLT_RUNTIMEPATH "home:vimfiles,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,home:vimfiles/after"
4545
#endif
46+
#ifndef CLEAN_RUNTIMEPATH
47+
# define CLEAN_RUNTIMEPATH "$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after"
48+
#endif
4649

4750
#ifndef BASENAMELEN
4851
# define BASENAMELEN 26 /* Amiga */

Diff for: src/os_dos.h

+1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125

126126
#define DFLT_ERRORFILE "errors.err"
127127
#define DFLT_RUNTIMEPATH "$HOME/vimfiles,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/vimfiles/after"
128+
#define CLEAN_RUNTIMEPATH "$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after"
128129

129130
#define CASE_INSENSITIVE_FILENAME /* ignore case when comparing file names */
130131
#define SPACE_IN_FILENAME

Diff for: src/os_mac.h

+3
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@
215215
#ifndef DFLT_RUNTIMEPATH
216216
# define DFLT_RUNTIMEPATH "~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after"
217217
#endif
218+
#ifndef CLEAN_RUNTIMEPATH
219+
# define CLEAN_RUNTIMEPATH "$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after"
220+
#endif
218221

219222
/*
220223
* Macintosh has plenty of memory, use large buffers

Diff for: src/os_unix.h

+3
Original file line numberDiff line numberDiff line change
@@ -366,11 +366,14 @@ typedef struct dsc$descriptor DESC;
366366

367367
#ifdef VMS
368368
# define DFLT_RUNTIMEPATH "sys$login:vimfiles,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,sys$login:vimfiles/after"
369+
# define CLEAN_RUNTIMEPATH "$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after"
369370
#else
370371
# ifdef RUNTIME_GLOBAL
371372
# define DFLT_RUNTIMEPATH "~/.vim," RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL "/after,~/.vim/after"
373+
# define CLEAN_RUNTIMEPATH RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL "/after"
372374
# else
373375
# define DFLT_RUNTIMEPATH "~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after"
376+
# define CLEAN_RUNTIMEPATH "$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after"
374377
# endif
375378
#endif
376379

Diff for: src/proto/option.pro

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* option.c */
2-
void set_init_1(void);
2+
void set_init_1(int clean_arg);
33
void set_string_default(char *name, char_u *val);
44
void set_number_default(char *name, long val);
55
void free_all_options(void);

Diff for: src/structs.h

+1
Original file line numberDiff line numberDiff line change
@@ -3333,6 +3333,7 @@ typedef struct
33333333

33343334
int evim_mode; /* started as "evim" */
33353335
char_u *use_vimrc; /* vimrc from -u argument */
3336+
int clean; /* --clean argument */
33363337

33373338
int n_commands; /* no. of commands from + or -c */
33383339
char_u *commands[MAX_ARG_CMDS]; /* commands from + or -c arg. */

Diff for: src/version.c

+2
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,8 @@ static char *(features[]) =
778778

779779
static int included_patches[] =
780780
{ /* Add new patch number below this line */
781+
/**/
782+
1554,
781783
/**/
782784
1553,
783785
/**/

0 commit comments

Comments
 (0)