summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-03-01 21:57:32 +0100
committerBram Moolenaar <Bram@vim.org>2018-03-01 21:57:32 +0100
commit072687032683b1994d25a114893d9a6f8bc36612 (patch)
tree92733e191032910aa84c907ee34d537a12250654
parent5f73ef8d20070cd45c9aea4dc33c2e0657f5515c (diff)
patch 8.0.1554: custom plugins loaded with --cleanv8.0.1554
Problem: Custom plugins loaded with --clean. Solution: Do not include the home directory in 'runtimepath'.
-rw-r--r--runtime/doc/starting.txt1
-rw-r--r--src/main.c18
-rw-r--r--src/option.c21
-rw-r--r--src/os_amiga.h3
-rw-r--r--src/os_dos.h1
-rw-r--r--src/os_mac.h3
-rw-r--r--src/os_unix.h3
-rw-r--r--src/proto/option.pro2
-rw-r--r--src/structs.h1
-rw-r--r--src/version.c2
10 files changed, 48 insertions, 7 deletions
diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt
index 48af7f2083..2b3418b3a5 100644
--- a/runtime/doc/starting.txt
+++ b/runtime/doc/starting.txt
@@ -516,6 +516,7 @@ a slash. Thus "-R" means recovery and "-/R" readonly.
- the |defaults.vim| script is loaded, which implies
'nocompatible': use Vim defaults
- no viminfo file is read or written
+ - the home directory is excluded from 'runtimepath'
*-x*
-x Use encryption to read/write files. Will prompt for a key,
which is then stored in the 'key' option. All writes will
diff --git a/src/main.c b/src/main.c
index 78a30182e1..cf937a3205 100644
--- a/src/main.c
+++ b/src/main.c
@@ -158,18 +158,25 @@ main
#ifdef STARTUPTIME
/* Need to find "--startuptime" before actually parsing arguments. */
- for (i = 1; i < argc; ++i)
- {
- if (STRICMP(argv[i], "--startuptime") == 0 && i + 1 < argc)
+ for (i = 1; i < argc - 1; ++i)
+ if (STRICMP(argv[i], "--startuptime") == 0)
{
time_fd = mch_fopen(argv[i + 1], "a");
TIME_MSG("--- VIM STARTING ---");
break;
}
- }
#endif
starttime = time(NULL);
+#ifdef CLEAN_RUNTIMEPATH
+ /* Need to find "--clean" before actually parsing arguments. */
+ for (i = 1; i < argc; ++i)
+ if (STRICMP(argv[i], "--clean") == 0)
+ {
+ params.clean = TRUE;
+ break;
+ }
+#endif
common_init(&params);
#ifdef FEAT_CLIENTSERVER
@@ -1024,7 +1031,7 @@ common_init(mparm_T *paramp)
* First find out the home directory, needed to expand "~" in options.
*/
init_homedir(); /* find real value of $HOME */
- set_init_1();
+ set_init_1(paramp->clean);
TIME_MSG("inits 1");
#ifdef FEAT_EVAL
@@ -1903,6 +1910,7 @@ command_line_scan(mparm_T *parmp)
else if (STRNICMP(argv[0] + argv_idx, "clean", 5) == 0)
{
parmp->use_vimrc = (char_u *)"DEFAULTS";
+ parmp->clean = TRUE;
set_option_value((char_u *)"vif", 0L, (char_u *)"NONE", 0);
}
else if (STRNICMP(argv[0] + argv_idx, "literal", 7) == 0)
diff --git a/src/option.c b/src/option.c
index 9662039510..1b51447091 100644
--- a/src/option.c
+++ b/src/option.c
@@ -3345,9 +3345,10 @@ static int briopt_check(win_T *wp);
* Initialize the options, first part.
*
* Called only once from main(), just after creating the first buffer.
+ * If "clean_arg" is TRUE Vim was started with --clean.
*/
void
-set_init_1(void)
+set_init_1(int clean_arg)
{
char_u *p;
int opt_idx;
@@ -3554,6 +3555,24 @@ set_init_1(void)
*/
set_options_default(0);
+#ifdef CLEAN_RUNTIMEPATH
+ if (clean_arg)
+ {
+ opt_idx = findoption((char_u *)"runtimepath");
+ if (opt_idx >= 0)
+ {
+ options[opt_idx].def_val[VI_DEFAULT] = (char_u *)CLEAN_RUNTIMEPATH;
+ p_rtp = (char_u *)CLEAN_RUNTIMEPATH;
+ }
+ opt_idx = findoption((char_u *)"packpath");
+ if (opt_idx >= 0)
+ {
+ options[opt_idx].def_val[VI_DEFAULT] = (char_u *)CLEAN_RUNTIMEPATH;
+ p_pp = (char_u *)CLEAN_RUNTIMEPATH;
+ }
+ }
+#endif
+
#ifdef FEAT_GUI
if (found_reverse_arg)
set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
diff --git a/src/os_amiga.h b/src/os_amiga.h
index 5154e28c5c..336cbdbaf3 100644
--- a/src/os_amiga.h
+++ b/src/os_amiga.h
@@ -43,6 +43,9 @@
#ifndef DFLT_RUNTIMEPATH
# define DFLT_RUNTIMEPATH "home:vimfiles,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,home:vimfiles/after"
#endif
+#ifndef CLEAN_RUNTIMEPATH
+# define CLEAN_RUNTIMEPATH "$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after"
+#endif
#ifndef BASENAMELEN
# define BASENAMELEN 26 /* Amiga */
diff --git a/src/os_dos.h b/src/os_dos.h
index 0edc3e0db6..bb8b30848d 100644
--- a/src/os_dos.h
+++ b/src/os_dos.h
@@ -125,6 +125,7 @@
#define DFLT_ERRORFILE "errors.err"
#define DFLT_RUNTIMEPATH "$HOME/vimfiles,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/vimfiles/after"
+#define CLEAN_RUNTIMEPATH "$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after"
#define CASE_INSENSITIVE_FILENAME /* ignore case when comparing file names */
#define SPACE_IN_FILENAME
diff --git a/src/os_mac.h b/src/os_mac.h
index 9fc2f92899..f1c7cb719b 100644
--- a/src/os_mac.h
+++ b/src/os_mac.h
@@ -215,6 +215,9 @@
#ifndef DFLT_RUNTIMEPATH
# define DFLT_RUNTIMEPATH "~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after"
#endif
+#ifndef CLEAN_RUNTIMEPATH
+# define CLEAN_RUNTIMEPATH "$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after"
+#endif
/*
* Macintosh has plenty of memory, use large buffers
diff --git a/src/os_unix.h b/src/os_unix.h
index 695affaea9..4146529241 100644
--- a/src/os_unix.h
+++ b/src/os_unix.h
@@ -366,11 +366,14 @@ typedef struct dsc$descriptor DESC;
#ifdef VMS
# define DFLT_RUNTIMEPATH "sys$login:vimfiles,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,sys$login:vimfiles/after"
+# define CLEAN_RUNTIMEPATH "$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after"
#else
# ifdef RUNTIME_GLOBAL
# define DFLT_RUNTIMEPATH "~/.vim," RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL "/after,~/.vim/after"
+# define CLEAN_RUNTIMEPATH RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL "/after"
# else
# define DFLT_RUNTIMEPATH "~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after"
+# define CLEAN_RUNTIMEPATH "$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after"
# endif
#endif
diff --git a/src/proto/option.pro b/src/proto/option.pro
index 59dcd42724..60a45e6d81 100644
--- a/src/proto/option.pro
+++ b/src/proto/option.pro
@@ -1,5 +1,5 @@
/* option.c */
-void set_init_1(void);
+void set_init_1(int clean_arg);
void set_string_default(char *name, char_u *val);
void set_number_default(char *name, long val);
void free_all_options(void);
diff --git a/src/structs.h b/src/structs.h
index 4f6a196574..fe8c03609b 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -3333,6 +3333,7 @@ typedef struct
int evim_mode; /* started as "evim" */
char_u *use_vimrc; /* vimrc from -u argument */
+ int clean; /* --clean argument */
int n_commands; /* no. of commands from + or -c */
char_u *commands[MAX_ARG_CMDS]; /* commands from + or -c arg. */
diff --git a/src/version.c b/src/version.c
index 5f6646432c..e890d11056 100644
--- a/src/version.c
+++ b/src/version.c
@@ -779,6 +779,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1554,
+/**/
1553,
/**/
1552,