'inccommand': buftype=nofile, restore cursor/view

- Use a standard scratch buffer instead of a new 'buftype', functions
  like curbufIsChanged() already have special handling for scratch bufs.
- Cleanup some stuff from the previous merge.
- Add support for :smagic, :snomagic. Closes #5578
This commit is contained in:
Justin M. Keyes
2016-11-09 12:08:49 +01:00
parent 0213e99aaf
commit 2e1217da46
9 changed files with 73 additions and 42 deletions

View File

@@ -5273,14 +5273,20 @@ wipe_buffer (
}
}
/// Creates or switches to a special-purpose buffer.
/// Creates or switches to a scratch buffer. :h special-buffers
/// Scratch buffer is:
/// - buftype=nofile bufhidden=hide noswapfile
/// - Always considered 'nomodified'
///
/// @param bufnr Buffer to switch to, or 0 to create a new buffer.
void buf_open_special(handle_T bufnr, char *bufname, char *buftype)
///
/// @see curbufIsChanged()
void buf_open_scratch(handle_T bufnr, char *bufname)
{
(void)do_ecmd((int)bufnr, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, NULL);
(void)setfname(curbuf, (char_u *)bufname, NULL, true);
set_option_value((char_u *)"bt", 0L, (char_u *)buftype, OPT_LOCAL);
set_option_value((char_u *)"bh", 0L, (char_u *)"hide", OPT_LOCAL);
set_option_value((char_u *)"bt", 0L, (char_u *)"nofile", OPT_LOCAL);
set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
RESET_BINDING(curwin);
}