diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2015-03-05 18:07:15 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2015-03-25 18:57:35 -0300 |
commit | b16c5bf5e6e2b7fd5f592ccec4f17bbf937e6d9b (patch) | |
tree | 1320080d0b40e1a360fba45f63d8f2a23ee16ced /src | |
parent | 8b6b06c2e08ae3bfd5aaa5b920a521a03b42a2b3 (diff) | |
download | rneovim-b16c5bf5e6e2b7fd5f592ccec4f17bbf937e6d9b.tar.gz rneovim-b16c5bf5e6e2b7fd5f592ccec4f17bbf937e6d9b.tar.bz2 rneovim-b16c5bf5e6e2b7fd5f592ccec4f17bbf937e6d9b.zip |
buffer: Move b_p_ma(modifiable) checks into the MODIFIABLE macro
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/buffer.c | 6 | ||||
-rw-r--r-- | src/nvim/buffer_defs.h | 2 | ||||
-rw-r--r-- | src/nvim/diff.c | 5 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 2 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 2 | ||||
-rw-r--r-- | src/nvim/fold.c | 2 | ||||
-rw-r--r-- | src/nvim/normal.c | 10 | ||||
-rw-r--r-- | src/nvim/ops.c | 4 | ||||
-rw-r--r-- | src/nvim/option.c | 4 | ||||
-rw-r--r-- | src/nvim/undo.c | 2 |
10 files changed, 21 insertions, 18 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 5ece645b0d..03adba97cd 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -2145,7 +2145,7 @@ void buflist_list(exarg_T *eap) (curwin->w_alt_fnum == buf->b_fnum ? '#' : ' '), buf->b_ml.ml_mfp == NULL ? ' ' : (buf->b_nwindows == 0 ? 'h' : 'a'), - !buf->b_p_ma ? '-' : (buf->b_p_ro ? '=' : ' '), + !MODIFIABLE(buf) ? '-' : (buf->b_p_ro ? '=' : ' '), (buf->b_flags & BF_READERR) ? 'x' : (bufIsChanged(buf) ? '+' : ' '), NameBuff); @@ -2623,7 +2623,7 @@ void maketitle(void) switch (bufIsChanged(curbuf) + (curbuf->b_p_ro * 2) - + (!curbuf->b_p_ma * 4)) { + + (!MODIFIABLE(curbuf) * 4)) { case 1: STRCAT(buf, " +"); break; case 2: STRCAT(buf, " ="); break; case 3: STRCAT(buf, " =+"); break; @@ -3250,7 +3250,7 @@ build_stl_str_hl ( itemisflag = TRUE; switch ((opt == STL_MODIFIED_ALT) + bufIsChanged(wp->w_buffer) * 2 - + (!wp->w_buffer->b_p_ma) * 4) { + + (!MODIFIABLE(wp->w_buffer)) * 4) { case 2: str = (char_u *)"[+]"; break; case 3: str = (char_u *)",+"; break; case 4: str = (char_u *)"[-]"; break; diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index d9684db3bc..3b8b171bd4 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -27,6 +27,8 @@ // for String #include "nvim/api/private/defs.h" +#define MODIFIABLE(buf) (buf->b_p_ma) + /* * Flags for w_valid. * These are set when something in a window structure becomes invalid, except diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 63b0eaf4f6..e50b096270 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -2078,7 +2078,7 @@ void ex_diffgetput(exarg_T *eap) if ((curtab->tp_diffbuf[idx_other] != curbuf) && (curtab->tp_diffbuf[idx_other] != NULL)) { if ((eap->cmdidx != CMD_diffput) - || curtab->tp_diffbuf[idx_other]->b_p_ma) { + || MODIFIABLE(curtab->tp_diffbuf[idx_other])) { break; } found_not_ma = TRUE; @@ -2098,7 +2098,8 @@ void ex_diffgetput(exarg_T *eap) for (i = idx_other + 1; i < DB_COUNT; ++i) { if ((curtab->tp_diffbuf[i] != curbuf) && (curtab->tp_diffbuf[i] != NULL) - && ((eap->cmdidx != CMD_diffput) || curtab->tp_diffbuf[i]->b_p_ma)) { + && ((eap->cmdidx != CMD_diffput) + || MODIFIABLE(curtab->tp_diffbuf[i]))) { EMSG(_("E101: More than two buffers in diff mode, don't know " "which one to use")); return; diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 2c674e06e6..d85664d1ba 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -3656,7 +3656,7 @@ void do_sub(exarg_T *eap) if (eap->skip) /* not executing commands, only parsing */ return; - if (!do_count && !curbuf->b_p_ma) { + if (!do_count && !MODIFIABLE(curbuf)) { /* Substitution is not allowed in non-'modifiable' buffer */ EMSG(_(e_modifiable)); return; diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 63d94dabc0..de04a3ea32 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1510,7 +1510,7 @@ static char_u * do_one_cmd(char_u **cmdlinep, errormsg = (char_u *)_(e_sandbox); goto doend; } - if (!curbuf->b_p_ma && (ea.argt & MODIFY)) { + if (!MODIFIABLE(curbuf) && (ea.argt & MODIFY)) { /* Command not allowed in non-'modifiable' buffer */ errormsg = (char_u *)_(e_modifiable); goto doend; diff --git a/src/nvim/fold.c b/src/nvim/fold.c index a1fbdf7791..74444d4ab7 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -1563,7 +1563,7 @@ static void setSmallMaybe(garray_T *gap) */ static void foldCreateMarkers(linenr_T start, linenr_T end) { - if (!curbuf->b_p_ma) { + if (!MODIFIABLE(curbuf)) { EMSG(_(e_modifiable)); return; } diff --git a/src/nvim/normal.c b/src/nvim/normal.c index a708aca136..e26f5a3d77 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1465,7 +1465,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) /* Force a redraw when operating on an empty Visual region, when * 'modifiable is off or creating a fold. */ - if (oap->is_VIsual && (oap->empty || !curbuf->b_p_ma + if (oap->is_VIsual && (oap->empty || !MODIFIABLE(curbuf) || oap->op_type == OP_FOLD )) redraw_curbuf_later(INVERTED); @@ -5513,9 +5513,9 @@ static void nv_Replace(cmdarg_T *cap) VIsual_mode = 'V'; nv_operator(cap); } else if (!checkclearopq(cap->oap)) { - if (!curbuf->b_p_ma) + if (!MODIFIABLE(curbuf)) { EMSG(_(e_modifiable)); - else { + } else { if (virtual_active()) coladvance(getviscol()); invoke_edit(cap, false, cap->arg ? 'V' : 'R', false); @@ -5533,9 +5533,9 @@ static void nv_vreplace(cmdarg_T *cap) cap->nchar = cap->extra_char; nv_replace(cap); /* Do same as "r" in Visual mode for now */ } else if (!checkclearopq(cap->oap)) { - if (!curbuf->b_p_ma) + if (!MODIFIABLE(curbuf)) { EMSG(_(e_modifiable)); - else { + } else { if (cap->extra_char == Ctrl_V) /* get another character */ cap->extra_char = get_literal(); stuffcharReadbuff(cap->extra_char); diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 7f2df8199c..50710cd78a 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -583,7 +583,7 @@ void op_reindent(oparg_T *oap, Indenter how) linenr_T start_lnum = curwin->w_cursor.lnum; /* Don't even try when 'modifiable' is off. */ - if (!curbuf->b_p_ma) { + if (!MODIFIABLE(curbuf)) { EMSG(_(e_modifiable)); return; } @@ -1329,7 +1329,7 @@ int op_delete(oparg_T *oap) if (oap->empty) return u_save_cursor(); - if (!curbuf->b_p_ma) { + if (!MODIFIABLE(curbuf)) { EMSG(_(e_modifiable)); return FAIL; } diff --git a/src/nvim/option.c b/src/nvim/option.c index 016a50fb62..19202030c6 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3748,7 +3748,7 @@ did_set_string_option ( /* 'encoding' and 'fileencoding' */ else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc) { if (gvarp == &p_fenc) { - if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL) + if (!MODIFIABLE(curbuf) && opt_flags != OPT_GLOBAL) errmsg = e_modifiable; else if (vim_strchr(*varp, ',') != NULL) /* No comma allowed in 'fileencoding'; catches confusing it @@ -3819,7 +3819,7 @@ did_set_string_option ( } /* 'fileformat' */ else if (gvarp == &p_ff) { - if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL)) + if (!MODIFIABLE(curbuf) && !(opt_flags & OPT_GLOBAL)) errmsg = e_modifiable; else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK) errmsg = e_invarg; diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 06dc325fea..e67c5f2aba 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -289,7 +289,7 @@ int u_savedel(linenr_T lnum, long nlines) int undo_allowed(void) { /* Don't allow changes when 'modifiable' is off. */ - if (!curbuf->b_p_ma) { + if (!MODIFIABLE(curbuf)) { EMSG(_(e_modifiable)); return FALSE; } |