summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/buffer.c13
-rw-r--r--src/ex_cmds.c2
-rw-r--r--src/ex_docmd.c2
-rw-r--r--src/fileio.c11
-rw-r--r--src/memline.c2
-rw-r--r--src/testdir/test_autocmd.vim19
-rw-r--r--src/version.c2
7 files changed, 40 insertions, 11 deletions
diff --git a/src/buffer.c b/src/buffer.c
index e77fc0497..b79e277a0 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -113,16 +113,19 @@ read_buffer(
* it can be changed there. */
if (!readonlymode && !bufempty())
changed();
- else if (retval != FAIL)
+ else if (retval == OK)
unchanged(curbuf, FALSE);
#ifdef FEAT_AUTOCMD
+ if (retval == OK)
+ {
# ifdef FEAT_EVAL
- apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, FALSE,
+ apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, FALSE,
curbuf, &retval);
# else
- apply_autocmds(EVENT_STDINREADPOST, NULL, NULL, FALSE, curbuf);
+ apply_autocmds(EVENT_STDINREADPOST, NULL, NULL, FALSE, curbuf);
# endif
+ }
#endif
}
return retval;
@@ -294,7 +297,7 @@ open_buffer(
#endif
)
changed();
- else if (retval != FAIL && !read_stdin && !read_fifo)
+ else if (retval == OK && !read_stdin && !read_fifo)
unchanged(curbuf, FALSE);
save_file_ff(curbuf); /* keep this fileformat */
@@ -328,7 +331,7 @@ open_buffer(
# endif
#endif
- if (retval != FAIL)
+ if (retval == OK)
{
#ifdef FEAT_AUTOCMD
/*
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 484a22c74..00cac9256 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -1313,7 +1313,7 @@ do_filter(
if (otmp != NULL)
{
if (readfile(otmp, NULL, line2, (linenr_T)0, (linenr_T)MAXLNUM,
- eap, READ_FILTER) == FAIL)
+ eap, READ_FILTER) != OK)
{
#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
if (!aborting())
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 134a48838..295e53960 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -8857,7 +8857,7 @@ ex_read(exarg_T *eap)
eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0);
}
- if (i == FAIL)
+ if (i != OK)
{
#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
if (!aborting())
diff --git a/src/fileio.c b/src/fileio.c
index bcb8fef8b..aeb53b593 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -210,7 +210,7 @@ filemess(
* READ_KEEP_UNDO don't clear undo info or read it from a file
* READ_FIFO read from fifo/socket instead of a file
*
- * return FAIL for failure, OK otherwise
+ * return FAIL for failure, NOTDONE for directory (failure), or OK
*/
int
readfile(
@@ -450,13 +450,18 @@ readfile(
# endif
)
{
+ int retval = FAIL;
+
if (S_ISDIR(perm))
+ {
filemess(curbuf, fname, (char_u *)_("is a directory"), 0);
+ retval = NOTDONE;
+ }
else
filemess(curbuf, fname, (char_u *)_("is not a file"), 0);
msg_end();
msg_scroll = msg_save;
- return FAIL;
+ return retval;
}
#endif
#if defined(MSWIN)
@@ -7136,7 +7141,7 @@ buf_reload(buf_T *buf, int orig_mode)
#endif
if (readfile(buf->b_ffname, buf->b_fname, (linenr_T)0,
(linenr_T)0,
- (linenr_T)MAXLNUM, &ea, flags) == FAIL)
+ (linenr_T)MAXLNUM, &ea, flags) != OK)
{
#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
if (!aborting())
diff --git a/src/memline.c b/src/memline.c
index e3a4bdbc6..244e69277 100644
--- a/src/memline.c
+++ b/src/memline.c
@@ -1519,7 +1519,7 @@ ml_recover(void)
line_count = pp->pb_pointer[idx].pe_line_count;
if (readfile(curbuf->b_ffname, NULL, lnum,
pp->pb_pointer[idx].pe_old_lnum - 1,
- line_count, NULL, 0) == FAIL)
+ line_count, NULL, 0) != OK)
cannot_open = TRUE;
else
lnum += line_count;
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index 6ebfee45e..566a07c6f 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -322,3 +322,22 @@ func Test_three_windows()
call delete('Xtestje2')
call delete('Xtestje3')
endfunc
+
+func Test_BufEnter()
+ au! BufEnter
+ au Bufenter * let val = val . '+'
+ let g:val = ''
+ split NewFile
+ call assert_equal('+', g:val)
+ bwipe!
+ call assert_equal('++', g:val)
+
+ " Also get BufEnter when editing a directory
+ call mkdir('Xdir')
+ split Xdir
+ call assert_equal('+++', g:val)
+ bwipe!
+
+ call delete('Xdir', 'd')
+ au! BufEnter
+endfunc
diff --git a/src/version.c b/src/version.c
index c7e47fa41..a0887dd6f 100644
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 177,
+/**/
176,
/**/
175,