aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-04-15 07:11:10 +0200
committerGitHub <noreply@github.com>2019-04-15 07:11:10 +0200
commit987619ddd73e792dc04b1a408b92cef2abb52bef (patch)
tree5e460541dbe23d075d729033a22f56977f19768c /src/nvim/buffer.c
parentd81b510ecf1890828caa653ebb2fa053131f3265 (diff)
parent7b219c638d43c12a42d75832fd09d7b2e86090bf (diff)
downloadrneovim-987619ddd73e792dc04b1a408b92cef2abb52bef.tar.gz
rneovim-987619ddd73e792dc04b1a408b92cef2abb52bef.tar.bz2
rneovim-987619ddd73e792dc04b1a408b92cef2abb52bef.zip
Merge pull request #9902 from janlazo/vim-8.0.0761
vim-patch:8.0.{761,776,1093,1112}
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r--src/nvim/buffer.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index b9c4c4d544..d628c517bb 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -5142,6 +5142,55 @@ bool bt_help(const buf_T *const buf)
return buf != NULL && buf->b_help;
}
+// Return true if "buf" is the quickfix buffer.
+bool bt_quickfix(const buf_T *const buf)
+{
+ return buf != NULL && buf->b_p_bt[0] == 'q';
+}
+
+// Return true if "buf" is a terminal buffer.
+bool bt_terminal(const buf_T *const buf)
+{
+ return buf != NULL && buf->b_p_bt[0] == 't';
+}
+
+// Return true if "buf" is a "nofile", "acwrite" or "terminal" buffer.
+// This means the buffer name is not a file name.
+bool bt_nofile(const buf_T *const buf)
+{
+ return buf != NULL && ((buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f')
+ || buf->b_p_bt[0] == 'a' || buf->terminal);
+}
+
+// Return true if "buf" is a "nowrite", "nofile" or "terminal" buffer.
+bool bt_dontwrite(const buf_T *const buf)
+{
+ return buf != NULL && (buf->b_p_bt[0] == 'n' || buf->terminal);
+}
+
+bool bt_dontwrite_msg(const buf_T *const buf)
+{
+ if (bt_dontwrite(buf)) {
+ EMSG(_("E382: Cannot write, 'buftype' option is set"));
+ return true;
+ }
+ return false;
+}
+
+// Return true if the buffer should be hidden, according to 'hidden', ":hide"
+// and 'bufhidden'.
+bool buf_hide(const buf_T *const buf)
+{
+ // 'bufhidden' overrules 'hidden' and ":hide", check it first
+ switch (buf->b_p_bh[0]) {
+ case 'u': // "unload"
+ case 'w': // "wipe"
+ case 'd': return false; // "delete"
+ case 'h': return true; // "hide"
+ }
+ return p_hid || cmdmod.hide;
+}
+
/*
* Return special buffer name.
* Returns NULL when the buffer has a normal file name.