aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2015-07-06 02:16:05 +0300
committerZyX <kp-pav@yandex.ru>2015-10-08 22:00:06 +0300
commit9cf9c4a5860212cc0f9b71d349849811fdaf61a1 (patch)
tree82335adcdca0627d7c615ee198a19ec63170a959 /src
parent749cae866278469d11e6ec467dd0e98ab6233439 (diff)
downloadrneovim-9cf9c4a5860212cc0f9b71d349849811fdaf61a1.tar.gz
rneovim-9cf9c4a5860212cc0f9b71d349849811fdaf61a1.tar.bz2
rneovim-9cf9c4a5860212cc0f9b71d349849811fdaf61a1.zip
Replace references to viminfo in various places
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_docmd.c10
-rw-r--r--src/nvim/fileio.c2
-rw-r--r--src/nvim/main.c6
-rw-r--r--src/nvim/ops.c2
-rw-r--r--src/nvim/option.c14
-rw-r--r--src/nvim/option_defs.h2
-rw-r--r--src/nvim/options.lua2
-rw-r--r--src/nvim/shada.c44
8 files changed, 44 insertions, 38 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index c45e641706..3e0a2c1076 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -9144,18 +9144,18 @@ int put_line(FILE *fd, char *s)
*/
static void ex_viminfo(exarg_T *eap)
{
- char_u *save_viminfo;
+ char_u *save_shada;
- save_viminfo = p_viminfo;
- if (*p_viminfo == NUL)
- p_viminfo = (char_u *)"'100";
+ save_shada = p_shada;
+ if (*p_shada == NUL)
+ p_shada = (char_u *)"'100";
if (eap->cmdidx == CMD_rviminfo) {
if (shada_read_everything((char *) eap->arg, eap->forceit) == FAIL)
EMSG(_("E195: Cannot open ShaDa file for reading"));
} else {
shada_write_file((char *) eap->arg, eap->forceit);
}
- p_viminfo = save_viminfo;
+ p_shada = save_shada;
}
/*
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index e4b59b7316..38442e3ab3 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -2172,7 +2172,7 @@ readfile_charconvert (
*/
static void check_marks_read(void)
{
- if (!curbuf->b_marks_read && get_viminfo_parameter('\'') > 0
+ if (!curbuf->b_marks_read && get_shada_parameter('\'') > 0
&& curbuf->b_ffname != NULL) {
shada_read_marks();
}
diff --git a/src/nvim/main.c b/src/nvim/main.c
index ae89d341be..bc95980afe 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -382,7 +382,7 @@ int main(int argc, char **argv)
* Read in registers, history etc, from the ShaDa file.
* This is where v:oldfiles gets filled.
*/
- if (*p_viminfo != NUL) {
+ if (*p_shada != NUL) {
(void) shada_read_file(NULL, (kShaDaWantInfo
| kShaDaGetOldfiles
| kShaDaWantMarks));
@@ -807,8 +807,8 @@ void getout(int exitval)
apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf);
}
- if (p_viminfo && *p_viminfo != NUL) {
- // Write out the registers, history, marks etc, to the viminfo file
+ if (p_shada && *p_shada != NUL) {
+ // Write out the registers, history, marks etc, to the ShaDa file
shada_write_file(NULL, false);
}
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 55c7aa3364..52064fae06 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -5238,7 +5238,7 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet)
reg->additional_data = NULL;
reg->timestamp = 0;
// Timestamp is not saved for clipboard registers because clipboard registers
- // are not saved in the viminfo.
+ // are not saved in the ShaDa file.
int i = 0;
for (listitem_T *li = lines->lv_first; li != NULL; li = li->li_next) {
diff --git a/src/nvim/option.c b/src/nvim/option.c
index c47616620c..87bae0179c 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -1743,11 +1743,11 @@ set_options_bin (
* If the parameter is not specified in the string or there is no following
* number, return -1.
*/
-int get_viminfo_parameter(int type)
+int get_shada_parameter(int type)
{
char_u *p;
- p = find_viminfo_parameter(type);
+ p = find_shada_parameter(type);
if (p != NULL && ascii_isdigit(*p))
return atoi((char *)p);
return -1;
@@ -1758,11 +1758,11 @@ int get_viminfo_parameter(int type)
* '/') in the 'viminfo' option and return a pointer to the string after it.
* Return NULL if the parameter is not specified in the string.
*/
-char_u *find_viminfo_parameter(int type)
+char_u *find_shada_parameter(int type)
{
char_u *p;
- for (p = p_viminfo; *p; ++p) {
+ for (p = p_shada; *p; ++p) {
if (*p == type)
return p + 1;
if (*p == 'n') /* 'n' is always the last one */
@@ -2443,8 +2443,8 @@ did_set_string_option (
errmsg = e_invarg;
}
/* 'viminfo' */
- else if (varp == &p_viminfo) {
- for (s = p_viminfo; *s; ) {
+ else if (varp == &p_shada) {
+ for (s = p_shada; *s; ) {
/* Check it's a valid character */
if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL) {
errmsg = illegal_char(errbuf, *s);
@@ -2486,7 +2486,7 @@ did_set_string_option (
break;
}
}
- if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
+ if (*p_shada && errmsg == NULL && get_shada_parameter('\'') < 0)
errmsg = (char_u *)N_("E528: Must specify a ' value");
}
/* 'showbreak' */
diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h
index 5340f4bdd5..a4cb390523 100644
--- a/src/nvim/option_defs.h
+++ b/src/nvim/option_defs.h
@@ -558,7 +558,7 @@ EXTERN long p_ur; /* 'undoreload' */
EXTERN long p_uc; /* 'updatecount' */
EXTERN long p_ut; /* 'updatetime' */
EXTERN char_u *p_fcs; /* 'fillchar' */
-EXTERN char_u *p_viminfo; /* 'viminfo' */
+EXTERN char_u *p_shada; /* 'viminfo' */
EXTERN char_u *p_vdir; /* 'viewdir' */
EXTERN char_u *p_vop; /* 'viewoptions' */
EXTERN unsigned vop_flags; /* uses SSOP_ flags */
diff --git a/src/nvim/options.lua b/src/nvim/options.lua
index ca3882b8a0..e66c46e08a 100644
--- a/src/nvim/options.lua
+++ b/src/nvim/options.lua
@@ -2584,7 +2584,7 @@ return {
type='string', list='comma', scope={'global'},
deny_duplicates=true,
secure=true,
- varname='p_viminfo',
+ varname='p_shada',
defaults={if_true={vi="", vim="!,'100,<50,s10,h"}}
},
{
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index 8a383b08a6..c853b00bac 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -63,8 +63,8 @@ KHASH_MAP_INIT_STR(fnamebufs, buf_T *)
#define copy_option_part(src, dest, ...) \
((char *) copy_option_part((char_u **) src, (char_u *) dest, __VA_ARGS__))
-#define find_viminfo_parameter(...) \
- ((const char *) find_viminfo_parameter(__VA_ARGS__))
+#define find_shada_parameter(...) \
+ ((const char *) find_shada_parameter(__VA_ARGS__))
#define emsg2(a, b) emsg2((char_u *) a, (char_u *) b)
#define emsg3(a, b, c) emsg3((char_u *) a, (char_u *) b, (char_u *) c)
#define emsgu(a, ...) emsgu((char_u *) a, __VA_ARGS__)
@@ -167,7 +167,7 @@ enum SRNIFlags {
kSDReadBufferList = (1 << kSDItemBufferList), ///< Determines whether buffer
///< list should be read
///< (disabled by removing
- ///< % entry from viminfo).
+ ///< % entry from &viminfo).
kSDReadUnknown = (1 << (SHADA_LAST_ENTRY + 1)), ///< Determines whether
///< unknown items should be
///< read (usually disabled).
@@ -200,6 +200,7 @@ typedef struct {
int64_t offset;
bool is_last_used;
bool is_substitute_pattern;
+ // TODO(ZyX-I): Also store v:hlsearch, see :h shada-h
char *pat;
Dictionary *additional_data;
} search_pattern;
@@ -524,7 +525,7 @@ int shada_read_file(const char *const file, const int flags)
if (p_verbose > 0) {
verbose_enter();
- smsg(_("Reading viminfo file \"%s\"%s%s%s"),
+ smsg(_("Reading ShaDa file \"%s\"%s%s%s"),
fname,
(flags & kShaDaWantInfo) ? _(" info") : "",
(flags & kShaDaWantMarks) ? _(" marks") : "",
@@ -672,21 +673,22 @@ static inline bool marks_equal(const pos_T a, const pos_T b)
static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
FUNC_ATTR_NONNULL_ALL
{
+ // TODO(ZyX-I): Also load v:oldfiles.
unsigned srni_flags = 0;
if (flags & kShaDaWantInfo) {
srni_flags |= kSDReadUndisableableData | kSDReadRegisters;
if (p_hi) {
srni_flags |= kSDReadHistory;
}
- if (find_viminfo_parameter('!') != NULL) {
+ if (find_shada_parameter('!') != NULL) {
srni_flags |= kSDReadVariables;
}
- if (find_viminfo_parameter('%') != NULL && ARGCOUNT == 0) {
+ if (find_shada_parameter('%') != NULL && ARGCOUNT == 0) {
srni_flags |= kSDReadBufferList;
}
}
if (flags & kShaDaWantMarks) {
- if (get_viminfo_parameter('\'') > 0) {
+ if (get_shada_parameter('\'') > 0) {
srni_flags |= kSDReadLocalMarks;
}
}
@@ -1039,7 +1041,7 @@ static char *shada_filename(const char *file)
if (file == NULL || *file == NUL) {
if (used_shada_file != NULL) {
file = used_shada_file;
- } else if ((file = find_viminfo_parameter('n')) == NULL || *file == NUL) {
+ } else if ((file = find_shada_parameter('n')) == NULL || *file == NUL) {
#ifdef SHADA_FILE2
// don't use $HOME when not defined (turned into "c:/"!).
if (os_getenv((char_u *)"HOME") == NULL) {
@@ -1364,7 +1366,7 @@ static void shada_write(ShaDaWriteDef *const sd_writer,
FUNC_ATTR_NONNULL_ARG(1)
{
khash_t(bufset) *const removable_bufs = kh_init(bufset);
- int max_kbyte_i = get_viminfo_parameter('s');
+ int max_kbyte_i = get_shada_parameter('s');
if (max_kbyte_i < 0) {
max_kbyte_i = 10;
}
@@ -1409,7 +1411,7 @@ static void shada_write(ShaDaWriteDef *const sd_writer,
}, 0);
// 2. Buffer list
- if (find_viminfo_parameter('%') != NULL) {
+ if (find_shada_parameter('%') != NULL) {
size_t buf_count = 0;
FOR_ALL_BUFFERS(buf) {
if (buf->b_ffname != NULL && !SHADA_REMOVABLE(buf)) {
@@ -1498,7 +1500,7 @@ static void shada_write(ShaDaWriteDef *const sd_writer,
// 4. History
HistoryMergerState hms[HIST_COUNT];
for (uint8_t i = 0; i < HIST_COUNT; i++) {
- long num_saved = get_viminfo_parameter(hist_type2char(i));
+ long num_saved = get_shada_parameter(hist_type2char(i));
if (num_saved == -1) {
num_saved = p_hi;
}
@@ -1599,7 +1601,7 @@ static void shada_write(ShaDaWriteDef *const sd_writer,
}
// 7. Global marks
- if (get_viminfo_parameter('f') != 0) {
+ if (get_shada_parameter('f') != 0) {
ShadaEntry *const global_marks = list_global_marks(removable_bufs);
for (ShadaEntry *mark = global_marks; mark->type != kSDItemMissing;
mark++) {
@@ -1636,12 +1638,12 @@ static void shada_write(ShaDaWriteDef *const sd_writer,
}
}
// FIXME: Copy previous marks, up to num_marked_files
- // size_t num_marked_files = get_viminfo_parameter('\'');
+ // size_t num_marked_files = get_shada_parameter('\'');
// 9. Registers
- int max_num_lines_i = get_viminfo_parameter('<');
+ int max_num_lines_i = get_shada_parameter('<');
if (max_num_lines_i < 0) {
- max_num_lines_i = get_viminfo_parameter('"');
+ max_num_lines_i = get_shada_parameter('"');
}
if (max_num_lines_i != 0) {
const size_t max_num_lines = (max_num_lines_i < 0
@@ -1673,7 +1675,7 @@ static void shada_write(ShaDaWriteDef *const sd_writer,
}
// 10. Variables
- if (find_viminfo_parameter('!') != NULL) {
+ if (find_shada_parameter('!') != NULL) {
const void *var_iter = NULL;
const Timestamp cur_timestamp = os_time();
do {
@@ -1730,6 +1732,7 @@ int shada_write_file(const char *const file, bool nomerge)
intptr_t fd;
if (!nomerge) {
+ // TODO(ZyX-I): Fail on read error.
if (open_shada_file_for_reading(fname, &sd_reader) != OK) {
nomerge = true;
goto shada_write_file_nomerge;
@@ -1741,6 +1744,7 @@ int shada_write_file(const char *const file, bool nomerge)
}
shada_write_file_open:
+ // TODO(ZyX-I): Preserve existing permissions
fd = (intptr_t) open_file(tempname, O_CREAT|O_WRONLY|O_NOFOLLOW|O_EXCL,
0600);
if (fd < 0) {
@@ -1754,6 +1758,8 @@ shada_write_file_open:
if (*wp == 'z') {
// Tried names from .tmp.a to .tmp.z, all failed. Something must be
// wrong then.
+ EMSG2(_("E138: All %s.tmp.X files exist, cannot write ShaDa file!"),
+ fname);
xfree(fname);
xfree(tempname);
return FAIL;
@@ -1772,7 +1778,7 @@ shada_write_file_nomerge:
if (p_verbose > 0) {
verbose_enter();
- smsg(_("Writing viminfo file \"%s\""), fname);
+ smsg(_("Writing ShaDa file \"%s\""), fname);
verbose_leave();
}
@@ -1793,7 +1799,7 @@ shada_write_file_nomerge:
if (!nomerge) {
close_file((int)(intptr_t) sd_reader.cookie);
if (vim_rename(tempname, fname) == -1) {
- EMSG3(_("E886: Can't rename viminfo file from %s to %s!"),
+ EMSG3(_("E886: Can't rename ShaDa file from %s to %s!"),
tempname, fname);
} else {
os_remove(tempname);
@@ -3021,7 +3027,7 @@ bool shada_removable(const char *name)
size_t n;
char *new_name = home_replace_save(NULL, name);
- for (p = (char *) p_viminfo; *p; ) {
+ for (p = (char *) p_shada; *p; ) {
(void) copy_option_part(&p, part, 51, ", ");
if (part[0] == 'r') {
n = STRLEN(part + 1);