diff options
Diffstat (limited to 'src/buffer.c')
-rw-r--r-- | src/buffer.c | 915 |
1 files changed, 457 insertions, 458 deletions
diff --git a/src/buffer.c b/src/buffer.c index 3b50c89379..4868428f52 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -78,9 +78,9 @@ get_highest_fnum(void) */ static int read_buffer( - int read_stdin, /* read file from stdin, otherwise fifo */ - exarg_T *eap, /* for forced 'ff' and 'fenc' or NULL */ - int flags) /* extra flags for readfile() */ + int read_stdin, // read file from stdin, otherwise fifo + exarg_T *eap, // for forced 'ff' and 'fenc' or NULL + int flags) // extra flags for readfile() { int retval = OK; linenr_T line_count; @@ -98,24 +98,24 @@ read_buffer( flags | READ_BUFFER); if (retval == OK) { - /* Delete the binary lines. */ + // Delete the binary lines. while (--line_count >= 0) ml_delete((linenr_T)1, FALSE); } else { - /* Delete the converted lines. */ + // Delete the converted lines. while (curbuf->b_ml.ml_line_count > line_count) ml_delete(line_count, FALSE); } - /* Put the cursor on the first line. */ + // Put the cursor on the first line. curwin->w_cursor.lnum = 1; curwin->w_cursor.col = 0; if (read_stdin) { - /* Set or reset 'modified' before executing autocommands, so that - * it can be changed there. */ + // Set or reset 'modified' before executing autocommands, so that + // it can be changed there. if (!readonlymode && !BUFEMPTY()) changed(); else if (retval == OK) @@ -158,9 +158,9 @@ buffer_ensure_loaded(buf_T *buf) */ int open_buffer( - int read_stdin, /* read file from stdin */ - exarg_T *eap, /* for forced 'ff' and 'fenc' or NULL */ - int flags) /* extra flags for readfile() */ + int read_stdin, // read file from stdin + exarg_T *eap, // for forced 'ff' and 'fenc' or NULL + int flags) // extra flags for readfile() { int retval = OK; bufref_T old_curbuf; @@ -211,12 +211,12 @@ open_buffer( return FAIL; } - /* The autocommands in readfile() may change the buffer, but only AFTER - * reading the file. */ + // The autocommands in readfile() may change the buffer, but only AFTER + // reading the file. set_bufref(&old_curbuf, curbuf); modified_was_set = FALSE; - /* mark cursor position as being invalid */ + // mark cursor position as being invalid curwin->w_valid = 0; if (curbuf->b_ffname != NULL @@ -264,7 +264,7 @@ open_buffer( #ifdef FEAT_NETBEANS_INTG netbeansFireChanges = oldFire; #endif - /* Help buffer is filtered. */ + // Help buffer is filtered. if (bt_help(curbuf)) fix_help_buffer(); } @@ -287,7 +287,7 @@ open_buffer( retval = read_buffer(TRUE, eap, flags); } - /* if first time loading this buffer, init b_chartab[] */ + // if first time loading this buffer, init b_chartab[] if (curbuf->b_flags & BF_NEVERLOADED) { (void)buf_init_chartab(curbuf, FALSE); @@ -301,11 +301,11 @@ open_buffer( * Apply the automatic commands, before processing the modelines. * So the modelines have priority over autocommands. */ - /* When reading stdin, the buffer contents always needs writing, so set - * the changed flag. Unless in readonly mode: "ls | gview -". - * When interrupted and 'cpoptions' contains 'i' set changed flag. */ + // When reading stdin, the buffer contents always needs writing, so set + // the changed flag. Unless in readonly mode: "ls | gview -". + // When interrupted and 'cpoptions' contains 'i' set changed flag. if ((got_int && vim_strchr(p_cpo, CPO_INTMOD) != NULL) - || modified_was_set /* ":set modified" used in autocmd */ + || modified_was_set // ":set modified" used in autocmd #ifdef FEAT_EVAL || (aborting() && vim_strchr(p_cpo, CPO_INTMOD) != NULL) #endif @@ -313,14 +313,14 @@ open_buffer( changed(); else if (retval == OK && !read_stdin && !read_fifo) unchanged(curbuf, FALSE, TRUE); - save_file_ff(curbuf); /* keep this fileformat */ + save_file_ff(curbuf); // keep this fileformat - /* Set last_changedtick to avoid triggering a TextChanged autocommand right - * after it was added. */ + // Set last_changedtick to avoid triggering a TextChanged autocommand right + // after it was added. curbuf->b_last_changedtick = CHANGEDTICK(curbuf); curbuf->b_last_changedtick_pum = CHANGEDTICK(curbuf); - /* require "!" to overwrite the file, because it wasn't read completely */ + // require "!" to overwrite the file, because it wasn't read completely #ifdef FEAT_EVAL if (aborting()) #else @@ -329,12 +329,12 @@ open_buffer( curbuf->b_flags |= BF_READERR; #ifdef FEAT_FOLDING - /* Need to update automatic folding. Do this before the autocommands, - * they may use the fold info. */ + // Need to update automatic folding. Do this before the autocommands, + // they may use the fold info. foldUpdateAll(curwin); #endif - /* need to set w_topline, unless some autocommand already did that. */ + // need to set w_topline, unless some autocommand already did that. if (!(curwin->w_valid & VALID_TOPLINE)) { curwin->w_topline = 1; @@ -358,7 +358,7 @@ open_buffer( { aco_save_T aco; - /* Go to the buffer that was opened. */ + // Go to the buffer that was opened. aucmd_prepbuf(&aco, old_curbuf.br_buf); do_modelines(0); curbuf->b_flags &= ~(BF_CHECK_RO | BF_NEVERLOADED); @@ -370,7 +370,7 @@ open_buffer( apply_autocmds(EVENT_BUFWINENTER, NULL, NULL, FALSE, curbuf); #endif - /* restore curwin/curbuf and a few other things */ + // restore curwin/curbuf and a few other things aucmd_restbuf(&aco); } } @@ -413,8 +413,8 @@ buf_valid(buf_T *buf) { buf_T *bp; - /* Assume that we more often have a recent buffer, start with the last - * one. */ + // Assume that we more often have a recent buffer, start with the last + // one. for (bp = lastbuf; bp != NULL; bp = bp->b_prev) if (bp == buf) return TRUE; @@ -490,7 +490,7 @@ can_unload_buffer(buf_T *buf) */ void close_buffer( - win_T *win, /* if not NULL, set b_last_cursor */ + win_T *win, // if not NULL, set b_last_cursor buf_T *buf, int action, int abort_if_last) @@ -510,18 +510,18 @@ close_buffer( * The caller must take care of NOT deleting/freeing when 'bufhidden' is * "hide" (otherwise we could never free or delete a buffer). */ - if (buf->b_p_bh[0] == 'd') /* 'bufhidden' == "delete" */ + if (buf->b_p_bh[0] == 'd') // 'bufhidden' == "delete" { del_buf = TRUE; unload_buf = TRUE; } - else if (buf->b_p_bh[0] == 'w') /* 'bufhidden' == "wipe" */ + else if (buf->b_p_bh[0] == 'w') // 'bufhidden' == "wipe" { del_buf = TRUE; unload_buf = TRUE; wipe_buf = TRUE; } - else if (buf->b_p_bh[0] == 'u') /* 'bufhidden' == "unload" */ + else if (buf->b_p_bh[0] == 'u') // 'bufhidden' == "unload" unload_buf = TRUE; #ifdef FEAT_TERMINAL @@ -534,19 +534,19 @@ close_buffer( if (!can_unload_buffer(buf)) return; - /* Wiping out or unloading a terminal buffer kills the job. */ + // Wiping out or unloading a terminal buffer kills the job. free_terminal(buf); } else { - /* The job keeps running, hide the buffer. */ + // The job keeps running, hide the buffer. del_buf = FALSE; unload_buf = FALSE; } } else { - /* A terminal buffer is wiped out if the job has finished. */ + // A terminal buffer is wiped out if the job has finished. del_buf = TRUE; unload_buf = TRUE; wipe_buf = TRUE; @@ -554,18 +554,18 @@ close_buffer( } #endif - /* Disallow deleting the buffer when it is locked (already being closed or - * halfway a command that relies on it). Unloading is allowed. */ + // Disallow deleting the buffer when it is locked (already being closed or + // halfway a command that relies on it). Unloading is allowed. if ((del_buf || wipe_buf) && !can_unload_buffer(buf)) return; - /* check no autocommands closed the window */ + // check no autocommands closed the window if (win != NULL && win_valid_any_tab(win)) { - /* Set b_last_cursor when closing the last window for the buffer. - * Remember the last cursor position and window options of the buffer. - * This used to be only for the current window, but then options like - * 'foldmethod' may be lost with a ":only" command. */ + // Set b_last_cursor when closing the last window for the buffer. + // Remember the last cursor position and window options of the buffer. + // This used to be only for the current window, but then options like + // 'foldmethod' may be lost with a ":only" command. if (buf->b_nwindows == 1) set_last_cursor(win); buflist_setfpos(buf, win, @@ -575,7 +575,7 @@ close_buffer( set_bufref(&bufref, buf); - /* When the buffer is no longer in a window, trigger BufWinLeave */ + // When the buffer is no longer in a window, trigger BufWinLeave if (buf->b_nwindows == 1) { ++buf->b_locked; @@ -583,40 +583,40 @@ close_buffer( FALSE, buf) && !bufref_valid(&bufref)) { - /* Autocommands deleted the buffer. */ + // Autocommands deleted the buffer. aucmd_abort: emsg(_(e_auabort)); return; } --buf->b_locked; if (abort_if_last && one_window()) - /* Autocommands made this the only window. */ + // Autocommands made this the only window. goto aucmd_abort; - /* When the buffer becomes hidden, but is not unloaded, trigger - * BufHidden */ + // When the buffer becomes hidden, but is not unloaded, trigger + // BufHidden if (!unload_buf) { ++buf->b_locked; if (apply_autocmds(EVENT_BUFHIDDEN, buf->b_fname, buf->b_fname, FALSE, buf) && !bufref_valid(&bufref)) - /* Autocommands deleted the buffer. */ + // Autocommands deleted the buffer. goto aucmd_abort; --buf->b_locked; if (abort_if_last && one_window()) - /* Autocommands made this the only window. */ + // Autocommands made this the only window. goto aucmd_abort; } #ifdef FEAT_EVAL - if (aborting()) /* autocmds may abort script processing */ + if (aborting()) // autocmds may abort script processing return; #endif } - /* If the buffer was in curwin and the window has changed, go back to that - * window, if it still exists. This avoids that ":edit x" triggering a - * "tabnext" BufUnload autocmd leaves a window behind without a buffer. */ + // If the buffer was in curwin and the window has changed, go back to that + // window, if it still exists. This avoids that ":edit x" triggering a + // "tabnext" BufUnload autocmd leaves a window behind without a buffer. if (is_curwin && curwin != the_curwin && win_valid_any_tab(the_curwin)) { block_autocmds(); @@ -626,26 +626,26 @@ aucmd_abort: nwindows = buf->b_nwindows; - /* decrease the link count from windows (unless not in any window) */ + // decrease the link count from windows (unless not in any window) if (buf->b_nwindows > 0) --buf->b_nwindows; #ifdef FEAT_DIFF if (diffopt_hiddenoff() && !unload_buf && buf->b_nwindows == 0) - diff_buf_delete(buf); /* Clear 'diff' for hidden buffer. */ + diff_buf_delete(buf); // Clear 'diff' for hidden buffer. #endif - /* Return when a window is displaying the buffer or when it's not - * unloaded. */ + // Return when a window is displaying the buffer or when it's not + // unloaded. if (buf->b_nwindows > 0 || !unload_buf) return; - /* Always remove the buffer when there is no file name. */ + // Always remove the buffer when there is no file name. if (buf->b_ffname == NULL) del_buf = TRUE; - /* When closing the current buffer stop Visual mode before freeing - * anything. */ + // When closing the current buffer stop Visual mode before freeing + // anything. if (buf == curbuf && VIsual_active #if defined(EXITFREE) && !entered_free_all_mem @@ -657,18 +657,18 @@ aucmd_abort: * Free all things allocated for this buffer. * Also calls the "BufDelete" autocommands when del_buf is TRUE. */ - /* Remember if we are closing the current buffer. Restore the number of - * windows, so that autocommands in buf_freeall() don't get confused. */ + // Remember if we are closing the current buffer. Restore the number of + // windows, so that autocommands in buf_freeall() don't get confused. is_curbuf = (buf == curbuf); buf->b_nwindows = nwindows; buf_freeall(buf, (del_buf ? BFA_DEL : 0) + (wipe_buf ? BFA_WIPE : 0)); - /* Autocommands may have deleted the buffer. */ + // Autocommands may have deleted the buffer. if (!bufref_valid(&bufref)) return; #ifdef FEAT_EVAL - if (aborting()) /* autocmds may abort script processing */ + if (aborting()) // autocmds may abort script processing return; #endif @@ -683,10 +683,10 @@ aucmd_abort: return; if (win_valid_any_tab(win) && win->w_buffer == buf) - win->w_buffer = NULL; /* make sure we don't use the buffer now */ + win->w_buffer = NULL; // make sure we don't use the buffer now - /* Autocommands may have opened or closed windows for this buffer. - * Decrement the count for the close we do here. */ + // Autocommands may have opened or closed windows for this buffer. + // Decrement the count for the close we do here. if (buf->b_nwindows > 0) --buf->b_nwindows; @@ -722,14 +722,14 @@ aucmd_abort: { if (del_buf) { - /* Free all internal variables and reset option values, to make - * ":bdel" compatible with Vim 5.7. */ + // Free all internal variables and reset option values, to make + // ":bdel" compatible with Vim 5.7. free_buffer_stuff(buf, TRUE); - /* Make it look like a new buffer. */ + // Make it look like a new buffer. buf->b_flags = BF_CHECK_RO | BF_NEVERLOADED; - /* Init the options when loaded again. */ + // Init the options when loaded again. buf->b_p_initialized = FALSE; } buf_clear_file(buf); @@ -752,7 +752,7 @@ buf_clear_file(buf_T *buf) buf->b_p_bomb = FALSE; buf->b_start_bomb = FALSE; buf->b_ml.ml_mfp = NULL; - buf->b_ml.ml_flags = ML_EMPTY; /* empty buffer */ + buf->b_ml.ml_flags = ML_EMPTY; // empty buffer #ifdef FEAT_NETBEANS_INTG netbeans_deleted_all_lines(buf); #endif @@ -775,7 +775,7 @@ buf_freeall(buf_T *buf, int flags) win_T *the_curwin = curwin; tabpage_T *the_curtab = curtab; - /* Make sure the buffer isn't closed by autocommands. */ + // Make sure the buffer isn't closed by autocommands. ++buf->b_locked; set_bufref(&bufref, buf); if (buf->b_ml.ml_mfp != NULL) @@ -783,7 +783,7 @@ buf_freeall(buf_T *buf, int flags) if (apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname, FALSE, buf) && !bufref_valid(&bufref)) - /* autocommands deleted the buffer */ + // autocommands deleted the buffer return; } if ((flags & BFA_DEL) && buf->b_p_bl) @@ -791,7 +791,7 @@ buf_freeall(buf_T *buf, int flags) if (apply_autocmds(EVENT_BUFDELETE, buf->b_fname, buf->b_fname, FALSE, buf) && !bufref_valid(&bufref)) - /* autocommands deleted the buffer */ + // autocommands deleted the buffer return; } if (flags & BFA_WIPE) @@ -799,14 +799,14 @@ buf_freeall(buf_T *buf, int flags) if (apply_autocmds(EVENT_BUFWIPEOUT, buf->b_fname, buf->b_fname, FALSE, buf) && !bufref_valid(&bufref)) - /* autocommands deleted the buffer */ + // autocommands deleted the buffer return; } --buf->b_locked; - /* If the buffer was in curwin and the window has changed, go back to that - * window, if it still exists. This avoids that ":edit x" triggering a - * "tabnext" BufUnload autocmd leaves a window behind without a buffer. */ + // If the buffer was in curwin and the window has changed, go back to that + // window, if it still exists. This avoids that ":edit x" triggering a + // "tabnext" BufUnload autocmd leaves a window behind without a buffer. if (is_curwin && curwin != the_curwin && win_valid_any_tab(the_curwin)) { block_autocmds(); @@ -815,7 +815,7 @@ buf_freeall(buf_T *buf, int flags) } #ifdef FEAT_EVAL - if (aborting()) /* autocmds may abort script processing */ + if (aborting()) // autocmds may abort script processing return; #endif @@ -828,16 +828,16 @@ buf_freeall(buf_T *buf, int flags) if (buf == curbuf && !is_curbuf) return; #ifdef FEAT_DIFF - diff_buf_delete(buf); /* Can't use 'diff' for unloaded buffer. */ + diff_buf_delete(buf); // Can't use 'diff' for unloaded buffer. #endif #ifdef FEAT_SYN_HL - /* Remove any ownsyntax, unless exiting. */ + // Remove any ownsyntax, unless exiting. if (curwin != NULL && curwin->w_buffer == buf) reset_synblock(curwin); #endif #ifdef FEAT_FOLDING - /* No folds in an empty buffer. */ + // No folds in an empty buffer. { win_T *win; tabpage_T *tp; @@ -851,20 +851,20 @@ buf_freeall(buf_T *buf, int flags) #ifdef FEAT_TCL tcl_buffer_free(buf); #endif - ml_close(buf, TRUE); /* close and delete the memline/memfile */ - buf->b_ml.ml_line_count = 0; /* no lines in buffer */ + ml_close(buf, TRUE); // close and delete the memline/memfile + buf->b_ml.ml_line_count = 0; // no lines in buffer if ((flags & BFA_KEEP_UNDO) == 0) { - u_blockfree(buf); /* free the memory allocated for undo */ - u_clearall(buf); /* reset all undo information */ + u_blockfree(buf); // free the memory allocated for undo + u_clearall(buf); // reset all undo information } #ifdef FEAT_SYN_HL - syntax_clear(&buf->b_s); /* reset syntax info */ + syntax_clear(&buf->b_s); // reset syntax info #endif #ifdef FEAT_TEXT_PROP clear_buf_prop_types(buf); #endif - buf->b_flags &= ~BF_READERR; /* a read error is no longer relevant */ + buf->b_flags &= ~BF_READERR; // a read error is no longer relevant } /* @@ -877,7 +877,7 @@ free_buffer(buf_T *buf) ++buf_free_count; free_buffer_stuff(buf, TRUE); #ifdef FEAT_EVAL - /* b:changedtick uses an item in buf_T, remove it now */ + // b:changedtick uses an item in buf_T, remove it now dictitem_remove(buf->b_vars, (dictitem_T *)&buf->b_ct_di); unref_var_dict(buf->b_vars); remove_listeners(buf); @@ -918,8 +918,8 @@ free_buffer(buf_T *buf) if (autocmd_busy) { - /* Do not free the buffer structure while autocommands are executing, - * it's still needed. Free it when autocmd_busy is reset. */ + // Do not free the buffer structure while autocommands are executing, + // it's still needed. Free it when autocmd_busy is reset. buf->b_next = au_pending_free_buf; au_pending_free_buf = buf; } @@ -952,11 +952,11 @@ init_changedtick(buf_T *buf) static void free_buffer_stuff( buf_T *buf, - int free_options) /* free options as well */ + int free_options) // free options as well { if (free_options) { - clear_wininfo(buf); /* including window-local options */ + clear_wininfo(buf); // including window-local options free_buf_options(buf, TRUE); #ifdef FEAT_SPELL ga_clear(&buf->b_s.b_langp); @@ -966,7 +966,7 @@ free_buffer_stuff( { varnumber_T tick = CHANGEDTICK(buf); - vars_clear(&buf->b_vars->dv_hashtab); /* free all buffer variables */ + vars_clear(&buf->b_vars->dv_hashtab); // free all buffer variables hash_init(&buf->b_vars->dv_hashtab); init_changedtick(buf); CHANGEDTICK(buf) = tick; @@ -979,8 +979,8 @@ free_buffer_stuff( #ifdef FEAT_NETBEANS_INTG netbeans_file_killed(buf); #endif - map_clear_int(buf, MAP_ALL_MODES, TRUE, FALSE); /* clear local mappings */ - map_clear_int(buf, MAP_ALL_MODES, TRUE, TRUE); /* clear local abbrevs */ + map_clear_int(buf, MAP_ALL_MODES, TRUE, FALSE); // clear local mappings + map_clear_int(buf, MAP_ALL_MODES, TRUE, TRUE); // clear local abbrevs VIM_CLEAR(buf->b_start_fenc); } @@ -1029,19 +1029,19 @@ goto_buffer( #if defined(FEAT_EVAL) cleanup_T cs; - /* Reset the error/interrupt/exception state here so that - * aborting() returns FALSE when closing a window. */ + // Reset the error/interrupt/exception state here so that + // aborting() returns FALSE when closing a window. enter_cleanup(&cs); #endif - /* Quitting means closing the split window, nothing else. */ + // Quitting means closing the split window, nothing else. win_close(curwin, TRUE); swap_exists_action = SEA_NONE; swap_exists_did_quit = TRUE; #if defined(FEAT_EVAL) - /* Restore the error/interrupt/exception state if not discarded by a - * new aborting error, interrupt, or uncaught exception. */ + // Restore the error/interrupt/exception state if not discarded by a + // new aborting error, interrupt, or uncaught exception. leave_cleanup(&cs); #endif } @@ -1067,15 +1067,15 @@ handle_swap_exists(bufref_T *old_curbuf) if (swap_exists_action == SEA_QUIT) { #if defined(FEAT_EVAL) - /* Reset the error/interrupt/exception state here so that - * aborting() returns FALSE when closing a buffer. */ + // Reset the error/interrupt/exception state here so that + // aborting() returns FALSE when closing a buffer. enter_cleanup(&cs); #endif - /* User selected Quit at ATTENTION prompt. Go back to previous - * buffer. If that buffer is gone or the same as the current one, - * open a new, empty buffer. */ - swap_exists_action = SEA_NONE; /* don't want it again */ + // User selected Quit at ATTENTION prompt. Go back to previous + // buffer. If that buffer is gone or the same as the current one, + // open a new, empty buffer. + swap_exists_action = SEA_NONE; // don't want it again swap_exists_did_quit = TRUE; close_buffer(curwin, curbuf, DOBUF_UNLOAD, FALSE); if (old_curbuf == NULL || !bufref_valid(old_curbuf) @@ -1098,32 +1098,32 @@ handle_swap_exists(bufref_T *old_curbuf) check_colorcolumn(curwin); #endif } - /* If "old_curbuf" is NULL we are in big trouble here... */ + // If "old_curbuf" is NULL we are in big trouble here... #if defined(FEAT_EVAL) - /* Restore the error/interrupt/exception state if not discarded by a - * new aborting error, interrupt, or uncaught exception. */ + // Restore the error/interrupt/exception state if not discarded by a + // new aborting error, interrupt, or uncaught exception. leave_cleanup(&cs); #endif } else if (swap_exists_action == SEA_RECOVER) { #if defined(FEAT_EVAL) - /* Reset the error/interrupt/exception state here so that - * aborting() returns FALSE when closing a buffer. */ + // Reset the error/interrupt/exception state here so that + // aborting() returns FALSE when closing a buffer. enter_cleanup(&cs); #endif - /* User selected Recover at ATTENTION prompt. */ + // User selected Recover at ATTENTION prompt. msg_scroll = TRUE; ml_recover(FALSE); - msg_puts("\n"); /* don't overwrite the last message */ + msg_puts("\n"); // don't overwrite the last message cmdline_row = msg_row; do_modelines(0); #if defined(FEAT_EVAL) - /* Restore the error/interrupt/exception state if not discarded by a - * new aborting error, interrupt, or uncaught exception. */ + // Restore the error/interrupt/exception state if not discarded by a + // new aborting error, interrupt, or uncaught exception. leave_cleanup(&cs); #endif } @@ -1146,16 +1146,16 @@ handle_swap_exists(bufref_T *old_curbuf) char * do_bufdel( int command, - char_u *arg, /* pointer to extra arguments */ + char_u *arg, // pointer to extra arguments int addr_count, - int start_bnr, /* first buffer number in a range */ - int end_bnr, /* buffer nr or last buffer nr in a range */ + int start_bnr, // first buffer number in a range + int end_bnr, // buffer nr or last buffer nr in a range int forceit) { - int do_current = 0; /* delete current buffer? */ - int deleted = 0; /* number of buffers deleted */ - char *errormsg = NULL; /* return value */ - int bnr; /* buffer number */ + int do_current = 0; // delete current buffer? + int deleted = 0; // number of buffers deleted + char *errormsg = NULL; // return value + int bnr; // buffer number char_u *p; if (addr_count == 0) @@ -1166,11 +1166,11 @@ do_bufdel( { if (addr_count == 2) { - if (*arg) /* both range and argument is not allowed */ + if (*arg) // both range and argument is not allowed return _(e_trailing); bnr = start_bnr; } - else /* addr_count == 1 */ + else // addr_count == 1 bnr = end_bnr; for ( ;!got_int; ui_breakcheck()) @@ -1195,7 +1195,7 @@ do_bufdel( if (++bnr > end_bnr) break; } - else /* addr_count == 1 */ + else // addr_count == 1 { arg = skipwhite(arg); if (*arg == NUL) @@ -1206,7 +1206,7 @@ do_bufdel( bnr = buflist_findpat(arg, p, command == DOBUF_WIPE || command == DOBUF_WIPE_REUSE, FALSE, FALSE); - if (bnr < 0) /* failed */ + if (bnr < 0) // failed break; arg = p; } @@ -1268,7 +1268,7 @@ empty_curbuf( set_bufref(&bufref, buf); if (close_others) - /* Close any other windows on this buffer, then make it empty. */ + // Close any other windows on this buffer, then make it empty. close_windows(buf, TRUE); setpcmark(); @@ -1308,9 +1308,9 @@ empty_curbuf( do_buffer( int action, int start, - int dir, /* FORWARD or BACKWARD */ - int count, /* buffer number or number of buffers */ - int forceit) /* TRUE for :...! */ + int dir, // FORWARD or BACKWARD + int count, // buffer number or number of buffers + int forceit) // TRUE for :...! { buf_T *buf; buf_T *bp; @@ -1323,7 +1323,7 @@ do_buffer( case DOBUF_LAST: buf = lastbuf; break; default: buf = curbuf; break; } - if (start == DOBUF_MOD) /* find next modified buffer */ + if (start == DOBUF_MOD) // find next modified buffer { while (count-- > 0) { @@ -1341,7 +1341,7 @@ do_buffer( return FAIL; } } - else if (start == DOBUF_FIRST && count) /* find specified buffer number */ + else if (start == DOBUF_FIRST && count) // find specified buffer number { while (buf != NULL && buf->b_fnum != count) buf = buf->b_next; @@ -1351,8 +1351,8 @@ do_buffer( bp = NULL; while (count > 0 || (!unload && !buf->b_p_bl && bp != buf)) { - /* remember the buffer where we start, we come back there when all - * buffers are unlisted. */ + // remember the buffer where we start, we come back there when all + // buffers are unlisted. if (bp == NULL) bp = buf; if (dir == FORWARD) @@ -1367,26 +1367,26 @@ do_buffer( if (buf == NULL) buf = lastbuf; } - /* don't count unlisted buffers */ + // don't count unlisted buffers if (unload || buf->b_p_bl) { --count; - bp = NULL; /* use this buffer as new starting point */ + bp = NULL; // use this buffer as new starting point } if (bp == buf) { - /* back where we started, didn't find anything. */ + // back where we started, didn't find anything. emsg(_("E85: There is no listed buffer")); return FAIL; } } } - if (buf == NULL) /* could not find it */ + if (buf == NULL) // could not find it { if (start == DOBUF_FIRST) { - /* don't warn when deleting */ + // don't warn when deleting if (!unload) semsg(_(e_nobufnr), count); } @@ -1414,8 +1414,8 @@ do_buffer( set_bufref(&bufref, buf); - /* When unloading or deleting a buffer that's already unloaded and - * unlisted: fail silently. */ + // When unloading or deleting a buffer that's already unloaded and + // unlisted: fail silently. if (action != DOBUF_WIPE && action != DOBUF_WIPE_REUSE && buf->b_ml.ml_mfp == NULL && !buf->b_p_bl) return FAIL; @@ -1427,11 +1427,11 @@ do_buffer( { dialog_changed(buf, FALSE); if (!bufref_valid(&bufref)) - /* Autocommand deleted buffer, oops! It's not changed - * now. */ + // Autocommand deleted buffer, oops! It's not changed + // now. return FAIL; - /* If it's still changed fail silently, the dialog already - * mentioned why it fails. */ + // If it's still changed fail silently, the dialog already + // mentioned why it fails. if (bufIsChanged(buf)) return FAIL; } @@ -1444,7 +1444,7 @@ do_buffer( } } - /* When closing the current buffer stop Visual mode. */ + // When closing the current buffer stop Visual mode. if (buf == curbuf && VIsual_active) end_visual_mode(); @@ -1492,8 +1492,8 @@ do_buffer( * then before the current buffer. * Finally use any buffer. */ - buf = NULL; /* selected buffer */ - bp = NULL; /* used when no loaded buffer found */ + buf = NULL; // selected buffer + bp = NULL; // used when no loaded buffer found if (au_new_curbuf.br_buf != NULL && bufref_valid(&au_new_curbuf)) buf = au_new_curbuf.br_buf; #ifdef FEAT_JUMPLIST @@ -1512,29 +1512,29 @@ do_buffer( if (buf != NULL) { if (buf == curbuf || !buf->b_p_bl) - buf = NULL; /* skip current and unlisted bufs */ + buf = NULL; // skip current and unlisted bufs else if (buf->b_ml.ml_mfp == NULL) { - /* skip unloaded buf, but may keep it for later */ + // skip unloaded buf, but may keep it for later if (bp == NULL) bp = buf; buf = NULL; } } - if (buf != NULL) /* found a valid buffer: stop searching */ + if (buf != NULL) // found a valid buffer: stop searching break; - /* advance to older entry in jump list */ + // advance to older entry in jump list if (!jumpidx && curwin->w_jumplistidx == curwin->w_jumplistlen) break; if (--jumpidx < 0) jumpidx = curwin->w_jumplistlen - 1; - if (jumpidx == forward) /* List exhausted for sure */ + if (jumpidx == forward) // List exhausted for sure break; } } #endif - if (buf == NULL) /* No previous buffer, Try 2'nd approach */ + if (buf == NULL) // No previous buffer, Try 2'nd approach { forward = TRUE; buf = curbuf->b_next; @@ -1542,18 +1542,18 @@ do_buffer( { if (buf == NULL) { - if (!forward) /* tried both directions */ + if (!forward) // tried both directions break; buf = curbuf->b_prev; forward = FALSE; continue; } - /* in non-help buffer, try to skip help buffers, and vv */ + // in non-help buffer, try to skip help buffers, and vv if (buf->b_help == curbuf->b_help && buf->b_p_bl) { - if (buf->b_ml.ml_mfp != NULL) /* found loaded buffer */ + if (buf->b_ml.ml_mfp != NULL) // found loaded buffer break; - if (bp == NULL) /* remember unloaded buf for later */ + if (bp == NULL) // remember unloaded buf for later bp = buf; } if (forward) @@ -1562,15 +1562,15 @@ do_buffer( buf = buf->b_prev; } } - if (buf == NULL) /* No loaded buffer, use unloaded one */ + if (buf == NULL) // No loaded buffer, use unloaded one buf = bp; - if (buf == NULL) /* No loaded buffer, find listed one */ + if (buf == NULL) // No loaded buffer, find listed one { FOR_ALL_BUFFERS(buf) if (buf->b_p_bl && buf != curbuf) break; } - if (buf == NULL) /* Still no buffer, just take one */ + if (buf == NULL) // Still no buffer, just take one { if (curbuf->b_next != NULL) buf = curbuf->b_next; @@ -1581,29 +1581,29 @@ do_buffer( if (buf == NULL) { - /* Autocommands must have wiped out all other buffers. Only option - * now is to make the current buffer empty. */ + // Autocommands must have wiped out all other buffers. Only option + // now is to make the current buffer empty. return empty_curbuf(FALSE, forceit, action); } /* * make buf current buffer */ - if (action == DOBUF_SPLIT) /* split window first */ + if (action == DOBUF_SPLIT) // split window first { - /* If 'switchbuf' contains "useopen": jump to first window containing - * "buf" if one exists */ + // If 'switchbuf' contains "useopen": jump to first window containing + // "buf" if one exists if ((swb_flags & SWB_USEOPEN) && buf_jump_open_win(buf)) return OK; - /* If 'switchbuf' contains "usetab": jump to first window in any tab - * page containing "buf" if one exists */ + // If 'switchbuf' contains "usetab": jump to first window in any tab + // page containing "buf" if one exists if ((swb_flags & SWB_USETAB) && buf_jump_open_tab(buf)) return OK; if (win_split(0, 0) == FAIL) return FAIL; } - /* go to current buffer - nothing to do */ + // go to current buffer - nothing to do if (buf == curbuf) return OK; @@ -1620,7 +1620,7 @@ do_buffer( set_bufref(&bufref, buf); dialog_changed(curbuf, FALSE); if (!bufref_valid(&bufref)) - /* Autocommand deleted buffer, oops! */ + // Autocommand deleted buffer, oops! return FAIL; } if (bufIsChanged(curbuf)) @@ -1631,14 +1631,14 @@ do_buffer( } } - /* Go to the other buffer. */ + // Go to the other buffer. set_curbuf(buf, action); if (action == DOBUF_SPLIT) - RESET_BINDING(curwin); /* reset 'scrollbind' and 'cursorbind' */ + RESET_BINDING(curwin); // reset 'scrollbind' and 'cursorbind' #if defined(FEAT_EVAL) - if (aborting()) /* autocmds may abort script processing */ + if (aborting()) // autocmds may abort script processing return FAIL; #endif @@ -1669,20 +1669,19 @@ set_curbuf(buf_T *buf, int action) setpcmark(); if (!cmdmod.keepalt) - curwin->w_alt_fnum = curbuf->b_fnum; /* remember alternate file */ - buflist_altfpos(curwin); /* remember curpos */ + curwin->w_alt_fnum = curbuf->b_fnum; // remember alternate file + buflist_altfpos(curwin); // remember curpos - /* Don't restart Select mode after switching to another buffer. */ + // Don't restart Select mode after switching to another buffer. VIsual_reselect = FALSE; - /* close_windows() or apply_autocmds() may change curbuf and wipe out "buf" - */ + // close_windows() or apply_autocmds() may change curbuf and wipe out "buf" prevbuf = curbuf; set_bufref(&prevbufref, prevbuf); set_bufref(&newbufref, buf); - /* Autocommands may delete the curren buffer and/or the buffer we wan to go - * to. In those cases don't close the buffer. */ + // Autocommands may delete the curren buffer and/or the buffer we wan to go + // to. In those cases don't close the buffer. if (!apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf) || (bufref_valid(&prevbufref) && bufref_valid(&newbufref) @@ -1711,13 +1710,13 @@ set_curbuf(buf_T *buf, int action) && !buf_hide(prevbuf) && !bufIsChanged(prevbuf)) ? DOBUF_UNLOAD : 0, FALSE); if (curwin != previouswin && win_valid(previouswin)) - /* autocommands changed curwin, Grr! */ + // autocommands changed curwin, Grr! curwin = previouswin; } } - /* An autocommand may have deleted "buf", already entered it (e.g., when - * it did ":bunload") or aborted the script processing. - * If curwin->w_buffer is null, enter_buffer() will make it valid again */ + // An autocommand may have deleted "buf", already entered it (e.g., when + // it did ":bunload") or aborted the script processing. + // If curwin->w_buffer is null, enter_buffer() will make it valid again if ((buf_valid(buf) && buf != curbuf #ifdef FEAT_EVAL && !aborting() @@ -1765,25 +1764,25 @@ enter_buffer(buf_T *buf) curwin->w_s = &(curbuf->b_s); #endif - /* Cursor on first line by default. */ + // Cursor on first line by default. curwin->w_cursor.lnum = 1; curwin->w_cursor.col = 0; curwin->w_cursor.coladd = 0; curwin->w_set_curswant = TRUE; curwin->w_topline_was_set = FALSE; |