To: vim_dev@googlegroups.com Subject: Patch 8.1.2096 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.2096 Problem: Too many #ifdefs. Solution: Graduate FEAT_COMMENTS. Files: src/feature.h, src/buffer.c, src/change.c, src/edit.c, src/evalfunc.c, src/fold.c, src/insexpand.c, src/misc1.c, src/normal.c, src/ops.c, src/option.c, src/optionstr.c, src/search.c, src/version.c, src/globals.h, src/option.h, src/optiondefs.h, src/structs.h, runtime/doc/change.txt, runtime/doc/options.txt, runtime/doc/various.txt *** ../vim-8.1.2095/src/feature.h 2019-09-15 13:16:55.204317458 +0200 --- src/feature.h 2019-09-28 18:33:19.779000578 +0200 *************** *** 108,113 **** --- 108,114 ---- * +cmdline_compl completion of mappings/abbreviations in cmdline mode. * +insert_expand CTRL-N/CTRL-P/CTRL-X in insert mode. * +modify_fname modifiers for file name. E.g., "%:p:h". + * +comments 'comments' option. * * Obsolete: * +tag_old_static Old style static tags: "file:tag file ..". *************** *** 496,508 **** #endif /* - * +comments 'comments' option. - */ - #ifdef FEAT_NORMAL - # define FEAT_COMMENTS - #endif - - /* * +cryptv Encryption (by Mohsin Ahmed ). */ #if defined(FEAT_NORMAL) && !defined(FEAT_CRYPT) || defined(PROTO) --- 497,502 ---- *** ../vim-8.1.2095/src/buffer.c 2019-09-25 20:37:22.073343455 +0200 --- src/buffer.c 2019-09-28 18:25:14.613522198 +0200 *************** *** 2226,2234 **** keymap_clear(&buf->b_kmap_ga); ga_clear(&buf->b_kmap_ga); #endif - #ifdef FEAT_COMMENTS clear_string_option(&buf->b_p_com); - #endif #ifdef FEAT_FOLDING clear_string_option(&buf->b_p_cms); #endif --- 2226,2232 ---- *** ../vim-8.1.2095/src/change.c 2019-09-14 21:00:01.379100893 +0200 --- src/change.c 2019-09-28 18:26:16.721176493 +0200 *************** *** 1414,1431 **** int n; int trunc_line = FALSE; // truncate current line afterwards int retval = FAIL; // return value - #ifdef FEAT_COMMENTS int extra_len = 0; // length of p_extra string int lead_len; // length of comment leader char_u *lead_flags; // position in 'comments' for comment leader char_u *leader = NULL; // copy of comment leader - #endif char_u *allocated = NULL; // allocated memory char_u *p; int saved_char = NUL; // init for GCC - #if defined(FEAT_SMARTINDENT) || defined(FEAT_COMMENTS) pos_T *pos; - #endif #ifdef FEAT_SMARTINDENT int do_si = (!p_paste && curbuf->b_p_si # ifdef FEAT_CINDENT --- 1414,1427 ---- *************** *** 1493,1501 **** first_char = *p; } #endif - #ifdef FEAT_COMMENTS extra_len = (int)STRLEN(p_extra); - #endif saved_char = *p_extra; *p_extra = NUL; } --- 1489,1495 ---- *************** *** 1544,1570 **** old_cursor = curwin->w_cursor; ptr = saved_line; - # ifdef FEAT_COMMENTS if (flags & OPENLINE_DO_COM) lead_len = get_leader_len(ptr, NULL, FALSE, TRUE); else lead_len = 0; - # endif if (dir == FORWARD) { // Skip preprocessor directives, unless they are // recognised as comments. ! if ( ! # ifdef FEAT_COMMENTS ! lead_len == 0 && ! # endif ! ptr[0] == '#') { while (ptr[0] == '#' && curwin->w_cursor.lnum > 1) ptr = ml_get(--curwin->w_cursor.lnum); newindent = get_indent(); } - # ifdef FEAT_COMMENTS if (flags & OPENLINE_DO_COM) lead_len = get_leader_len(ptr, NULL, FALSE, TRUE); else --- 1538,1557 ---- old_cursor = curwin->w_cursor; ptr = saved_line; if (flags & OPENLINE_DO_COM) lead_len = get_leader_len(ptr, NULL, FALSE, TRUE); else lead_len = 0; if (dir == FORWARD) { // Skip preprocessor directives, unless they are // recognised as comments. ! if ( lead_len == 0 && ptr[0] == '#') { while (ptr[0] == '#' && curwin->w_cursor.lnum > 1) ptr = ml_get(--curwin->w_cursor.lnum); newindent = get_indent(); } if (flags & OPENLINE_DO_COM) lead_len = get_leader_len(ptr, NULL, FALSE, TRUE); else *************** *** 1600,1606 **** } } else // Not a comment line - # endif { // Find last non-blank in line p = ptr + STRLEN(ptr) - 1; --- 1587,1592 ---- *************** *** 1651,1661 **** { // Skip preprocessor directives, unless they are // recognised as comments. ! if ( ! # ifdef FEAT_COMMENTS ! lead_len == 0 && ! # endif ! ptr[0] == '#') { int was_backslashed = FALSE; --- 1637,1643 ---- { // Skip preprocessor directives, unless they are // recognised as comments. ! if (lead_len == 0 && ptr[0] == '#') { int was_backslashed = FALSE; *************** *** 1688,1694 **** did_ai = TRUE; } - #ifdef FEAT_COMMENTS // Find out if the current line starts with a comment leader. // This may then be inserted in front of the new line. end_comment_pending = NUL; --- 1670,1675 ---- *************** *** 2086,2092 **** } } } - #endif // (State == INSERT || State == REPLACE), only when dir == FORWARD if (p_extra != NULL) --- 2067,2072 ---- *************** *** 2120,2126 **** if (p_extra == NULL) p_extra = (char_u *)""; // append empty line - #ifdef FEAT_COMMENTS // concatenate leader and p_extra, if there is a leader if (lead_len) { --- 2100,2105 ---- *************** *** 2147,2153 **** } else end_comment_pending = NUL; // turns out there was no leader - #endif old_cursor = curwin->w_cursor; if (dir == BACKWARD) --- 2126,2131 ---- *************** *** 2237,2249 **** #endif } - #ifdef FEAT_COMMENTS // In REPLACE mode, for each character in the extra leader, there must be // a NUL on the replace stack, for when it is deleted with BS. if (REPLACE_NORMAL(State)) while (lead_len-- > 0) replace_push(NUL); - #endif curwin->w_cursor = old_cursor; --- 2215,2225 ---- *************** *** 2299,2307 **** #ifdef FEAT_LISP // May do lisp indenting. if (!p_paste - # ifdef FEAT_COMMENTS && leader == NULL - # endif && curbuf->b_p_lisp && curbuf->b_p_ai) { --- 2275,2281 ---- *** ../vim-8.1.2095/src/edit.c 2019-09-21 20:46:14.720275786 +0200 --- src/edit.c 2019-09-28 18:27:35.704748664 +0200 *************** *** 2272,2280 **** int second_indent) /* indent for second line if >= 0 */ { int textwidth; - #ifdef FEAT_COMMENTS char_u *p; - #endif int fo_ins_blank; int force_format = flags & INSCHAR_FORMAT; --- 2272,2278 ---- *************** *** 2332,2343 **** if (c == NUL) /* only formatting was wanted */ return; ! #ifdef FEAT_COMMENTS ! /* Check whether this character should end a comment. */ if (did_ai && (int)c == end_comment_pending) { char_u *line; ! char_u lead_end[COM_MAX_LEN]; /* end-comment string */ int middle_len, end_len; int i; --- 2330,2340 ---- if (c == NUL) /* only formatting was wanted */ return; ! // Check whether this character should end a comment. if (did_ai && (int)c == end_comment_pending) { char_u *line; ! char_u lead_end[COM_MAX_LEN]; // end-comment string int middle_len, end_len; int i; *************** *** 2346,2391 **** * comment leader. First, check what comment leader we can find. */ i = get_leader_len(line = ml_get_curline(), &p, FALSE, TRUE); ! if (i > 0 && vim_strchr(p, COM_MIDDLE) != NULL) /* Just checking */ { ! /* Skip middle-comment string */ ! while (*p && p[-1] != ':') /* find end of middle flags */ ++p; middle_len = copy_option_part(&p, lead_end, COM_MAX_LEN, ","); ! /* Don't count trailing white space for middle_len */ while (middle_len > 0 && VIM_ISWHITE(lead_end[middle_len - 1])) --middle_len; ! /* Find the end-comment string */ ! while (*p && p[-1] != ':') /* find end of end flags */ ++p; end_len = copy_option_part(&p, lead_end, COM_MAX_LEN, ","); ! /* Skip white space before the cursor */ i = curwin->w_cursor.col; while (--i >= 0 && VIM_ISWHITE(line[i])) ; i++; ! /* Skip to before the middle leader */ i -= middle_len; ! /* Check some expected things before we go on */ if (i >= 0 && lead_end[end_len - 1] == end_comment_pending) { ! /* Backspace over all the stuff we want to replace */ backspace_until_column(i); ! /* ! * Insert the end-comment string, except for the last ! * character, which will get inserted as normal later. ! */ ins_bytes_len(lead_end, end_len - 1); } } } end_comment_pending = NUL; - #endif did_ai = FALSE; #ifdef FEAT_SMARTINDENT --- 2343,2385 ---- * comment leader. First, check what comment leader we can find. */ i = get_leader_len(line = ml_get_curline(), &p, FALSE, TRUE); ! if (i > 0 && vim_strchr(p, COM_MIDDLE) != NULL) // Just checking { ! // Skip middle-comment string ! while (*p && p[-1] != ':') // find end of middle flags ++p; middle_len = copy_option_part(&p, lead_end, COM_MAX_LEN, ","); ! // Don't count trailing white space for middle_len while (middle_len > 0 && VIM_ISWHITE(lead_end[middle_len - 1])) --middle_len; ! // Find the end-comment string ! while (*p && p[-1] != ':') // find end of end flags ++p; end_len = copy_option_part(&p, lead_end, COM_MAX_LEN, ","); ! // Skip white space before the cursor i = curwin->w_cursor.col; while (--i >= 0 && VIM_ISWHITE(line[i])) ; i++; ! // Skip to before the middle leader i -= middle_len; ! // Check some expected things before we go on if (i >= 0 && lead_end[end_len - 1] == end_comment_pending) { ! // Backspace over all the stuff we want to replace backspace_until_column(i); ! // Insert the end-comment string, except for the last ! // character, which will get inserted as normal later. ins_bytes_len(lead_end, end_len - 1); } } } end_comment_pending = NUL; did_ai = FALSE; #ifdef FEAT_SMARTINDENT *************** *** 2518,2528 **** int fo_multibyte = has_format_option(FO_MBYTE_BREAK); int fo_white_par = has_format_option(FO_WHITE_PAR); int first_line = TRUE; - #ifdef FEAT_COMMENTS colnr_T leader_len; int no_leader = FALSE; int do_comments = (flags & INSCHAR_DO_COM); - #endif #ifdef FEAT_LINEBREAK int has_lbr = curwin->w_p_lbr; --- 2512,2520 ---- *************** *** 2566,2572 **** if (virtcol <= (colnr_T)textwidth) break; - #ifdef FEAT_COMMENTS if (no_leader) do_comments = FALSE; else if (!(flags & INSCHAR_FORMAT) --- 2558,2563 ---- *************** *** 2585,2595 **** * to start with %. */ if (leader_len == 0) no_leader = TRUE; - #endif if (!(flags & INSCHAR_FORMAT) - #ifdef FEAT_COMMENTS && leader_len == 0 - #endif && !has_format_option(FO_WRAP)) break; --- 2576,2583 ---- *************** *** 2641,2661 **** if (has_format_option(FO_PERIOD_ABBR) && cc == '.' && wcc < 2) continue; - #ifdef FEAT_COMMENTS /* Don't break until after the comment leader */ if (curwin->w_cursor.col < leader_len) break; - #endif if (has_format_option(FO_ONE_LETTER)) { /* do not break after one-letter words */ if (curwin->w_cursor.col == 0) break; /* one-letter word at begin */ - #ifdef FEAT_COMMENTS /* do not break "#a b" when 'tw' is 2 */ if (curwin->w_cursor.col <= leader_len) break; - #endif col = curwin->w_cursor.col; dec_cursor(); cc = gchar_cursor(); --- 2629,2645 ---- *************** *** 2677,2687 **** /* Break after or before a multi-byte character. */ if (curwin->w_cursor.col != startcol) { - #ifdef FEAT_COMMENTS /* Don't break until after the comment leader */ if (curwin->w_cursor.col < leader_len) break; - #endif col = curwin->w_cursor.col; inc_cursor(); /* Don't change end_foundcol if already set. */ --- 2661,2669 ---- *************** *** 2705,2715 **** if (WHITECHAR(cc)) continue; /* break with space */ - #ifdef FEAT_COMMENTS /* Don't break until after the comment leader */ if (curwin->w_cursor.col < leader_len) break; - #endif curwin->w_cursor.col = col; --- 2687,2695 ---- *************** *** 2783,2792 **** */ open_line(FORWARD, OPENLINE_DELSPACES + OPENLINE_MARKFIX + (fo_white_par ? OPENLINE_KEEPTRAIL : 0) - #ifdef FEAT_COMMENTS + (do_comments ? OPENLINE_DO_COM : 0) + ((flags & INSCHAR_COM_LIST) ? OPENLINE_COM_LIST : 0) - #endif , ((flags & INSCHAR_COM_LIST) ? second_indent : old_indent)); if (!(flags & INSCHAR_COM_LIST)) old_indent = 0; --- 2763,2770 ---- *************** *** 2812,2818 **** change_indent(INDENT_SET, second_indent, FALSE, NUL, TRUE); else - #ifdef FEAT_COMMENTS if (leader_len > 0 && second_indent - leader_len > 0) { int i; --- 2790,2795 ---- *************** *** 2829,2839 **** } else { - #endif (void)set_indent(second_indent, SIN_CHANGED); - #ifdef FEAT_COMMENTS } - #endif } } first_line = FALSE; --- 2806,2813 ---- *************** *** 2937,2949 **** curwin->w_cursor = pos; } - #ifdef FEAT_COMMENTS /* With the 'c' flag in 'formatoptions' and 't' missing: only format * comments. */ if (has_format_option(FO_WRAP_COMS) && !has_format_option(FO_WRAP) ! && get_leader_len(old, NULL, FALSE, TRUE) == 0) return; - #endif /* * May start formatting in a previous line, so that after "x" a word is --- 2911,2921 ---- curwin->w_cursor = pos; } /* With the 'c' flag in 'formatoptions' and 't' missing: only format * comments. */ if (has_format_option(FO_WRAP_COMS) && !has_format_option(FO_WRAP) ! && get_leader_len(old, NULL, FALSE, TRUE) == 0) return; /* * May start formatting in a previous line, so that after "x" a word is *************** *** 4796,4804 **** if (in_indent) can_cindent = FALSE; #endif - #ifdef FEAT_COMMENTS end_comment_pending = NUL; /* After BS, don't auto-end comment */ - #endif #ifdef FEAT_RIGHTLEFT if (revins_on) /* put cursor after last inserted char */ inc_cursor(); --- 4768,4774 ---- *************** *** 5912,5921 **** AppendToRedobuff(NL_STR); i = open_line(FORWARD, ! #ifdef FEAT_COMMENTS ! has_format_option(FO_RET_COMS) ? OPENLINE_DO_COM : ! #endif ! 0, old_indent); old_indent = 0; #ifdef FEAT_CINDENT can_cindent = TRUE; --- 5882,5888 ---- AppendToRedobuff(NL_STR); i = open_line(FORWARD, ! has_format_option(FO_RET_COMS) ? OPENLINE_DO_COM : 0, old_indent); old_indent = 0; #ifdef FEAT_CINDENT can_cindent = TRUE; *** ../vim-8.1.2095/src/evalfunc.c 2019-09-26 23:08:10.501926883 +0200 --- src/evalfunc.c 2019-09-28 18:27:48.580680064 +0200 *************** *** 3315,3323 **** #endif "cmdline_compl", "cmdline_hist", - #ifdef FEAT_COMMENTS "comments", - #endif #ifdef FEAT_CONCEAL "conceal", #endif --- 3315,3321 ---- *** ../vim-8.1.2095/src/fold.c 2019-09-01 17:52:27.334698921 +0200 --- src/fold.c 2019-09-28 18:28:01.040613984 +0200 *************** *** 1773,1782 **** if (u_save(lnum - 1, lnum + 1) == OK) { - #if defined(FEAT_COMMENTS) /* Check if the line ends with an unclosed comment */ (void)skip_comment(line, FALSE, FALSE, &line_is_comment); - #endif newline = alloc(line_len + markerlen + STRLEN(cms) + 1); if (newline == NULL) return; --- 1773,1780 ---- *** ../vim-8.1.2095/src/insexpand.c 2019-09-21 20:46:14.724275765 +0200 --- src/insexpand.c 2019-09-28 18:28:15.908535491 +0200 *************** *** 3861,3877 **** if (ctrl_x_mode_line_or_eval()) { // Insert a new line, keep indentation but ignore 'comments' - #ifdef FEAT_COMMENTS char_u *old = curbuf->b_p_com; curbuf->b_p_com = (char_u *)""; - #endif compl_startpos.lnum = curwin->w_cursor.lnum; compl_startpos.col = compl_col; ins_eol('\r'); - #ifdef FEAT_COMMENTS curbuf->b_p_com = old; - #endif compl_length = 0; compl_col = curwin->w_cursor.col; } --- 3861,3873 ---- *** ../vim-8.1.2095/src/misc1.c 2019-09-22 21:29:49.659426007 +0200 --- src/misc1.c 2019-09-28 18:28:32.952445992 +0200 *************** *** 466,476 **** return -1; pos.lnum = 0; - #ifdef FEAT_COMMENTS /* In format_lines() (i.e. not insert mode), fo+=q is needed too... */ if ((State & INSERT) || has_format_option(FO_Q_COMS)) lead_len = get_leader_len(ml_get(lnum), NULL, FALSE, TRUE); ! #endif regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC); if (regmatch.regprog != NULL) { --- 466,475 ---- return -1; pos.lnum = 0; /* In format_lines() (i.e. not insert mode), fo+=q is needed too... */ if ((State & INSERT) || has_format_option(FO_Q_COMS)) lead_len = get_leader_len(ml_get(lnum), NULL, FALSE, TRUE); ! regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC); if (regmatch.regprog != NULL) { *************** *** 561,567 **** } #endif - #if defined(FEAT_COMMENTS) || defined(PROTO) /* * get_leader_len() returns the length in bytes of the prefix of the given * string which introduces a comment. If this string is not a comment then --- 560,565 ---- *************** *** 862,868 **** } return result; } - #endif /* * Return the number of window lines occupied by buffer line "lnum". --- 860,865 ---- *************** *** 1548,1555 **** if (msg_row > 0) cmdline_row = msg_row - 1; need_wait_return = FALSE; - msg_didany = FALSE; - msg_didout = FALSE; } else cmdline_row = save_cmdline_row; --- 1545,1550 ---- *** ../vim-8.1.2095/src/normal.c 2019-09-24 22:47:42.578098633 +0200 --- src/normal.c 2019-09-28 18:29:04.340282450 +0200 *************** *** 3281,3287 **** } break; } - #ifdef FEAT_COMMENTS if (get_leader_len(ml_get_curline(), NULL, FALSE, TRUE) > 0) { /* Ignore this line, continue at start of next line. */ --- 3281,3286 ---- *************** *** 3289,3295 **** curwin->w_cursor.col = 0; continue; } - #endif valid = is_ident(ml_get_curline(), curwin->w_cursor.col); /* If the current position is not a valid identifier and a previous --- 3288,3293 ---- *************** *** 7228,7237 **** (cap->cmdchar == 'o' ? 1 : 0)) ) == OK && open_line(cap->cmdchar == 'O' ? BACKWARD : FORWARD, ! #ifdef FEAT_COMMENTS ! has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM : ! #endif ! 0, 0) == OK) { #ifdef FEAT_CONCEAL if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum) --- 7226,7233 ---- (cap->cmdchar == 'o' ? 1 : 0)) ) == OK && open_line(cap->cmdchar == 'O' ? BACKWARD : FORWARD, ! has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM : 0, ! 0) == OK) { #ifdef FEAT_CONCEAL if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum) *** ../vim-8.1.2095/src/ops.c 2019-09-25 22:36:57.300103046 +0200 --- src/ops.c 2019-09-28 18:32:00.775388803 +0200 *************** *** 18,28 **** static void mb_adjust_opend(oparg_T *oap); static int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1); static int ends_in_white(linenr_T lnum); - #ifdef FEAT_COMMENTS static int fmt_check_par(linenr_T, int *, char_u **, int do_comments); - #else - static int fmt_check_par(linenr_T); - #endif // Flags for third item in "opchars". #define OPF_LINES 1 // operator always works on lines --- 18,24 ---- *************** *** 229,247 **** int left, int round, int amount, ! int call_changed_bytes) /* call changed_bytes() */ { int count; int i, j; int sw_val = (int)get_sw_value_indent(curbuf); ! count = get_indent(); /* get current indent */ ! if (round) /* round off indent */ { ! i = count / sw_val; /* number of p_sw rounded down */ ! j = count % sw_val; /* extra spaces */ ! if (j && left) /* first remove extra spaces */ --amount; if (left) { --- 225,243 ---- int left, int round, int amount, ! int call_changed_bytes) // call changed_bytes() { int count; int i, j; int sw_val = (int)get_sw_value_indent(curbuf); ! count = get_indent(); // get current indent ! if (round) // round off indent { ! i = count / sw_val; // number of 'shiftwidth' rounded down ! j = count % sw_val; // extra spaces ! if (j && left) // first remove extra spaces --amount; if (left) { *************** *** 253,259 **** i += amount; count = i * sw_val; } ! else /* original vi indent */ { if (left) { --- 249,255 ---- i += amount; count = i * sw_val; } ! else // original vi indent { if (left) { *************** *** 265,271 **** count += sw_val * amount; } ! /* Set new indent */ if (State & VREPLACE_FLAG) change_indent(INDENT_SET, count, FALSE, NUL, call_changed_bytes); else --- 261,267 ---- count += sw_val * amount; } ! // Set new indent if (State & VREPLACE_FLAG) change_indent(INDENT_SET, count, FALSE, NUL, call_changed_bytes); else *************** *** 1944,1950 **** } #endif - #if defined(FEAT_COMMENTS) || defined(PROTO) /* * If "process" is TRUE and the line begins with a comment leader (possibly * after some white space), return a pointer to the text after it. Put a boolean --- 1940,1945 ---- *************** *** 2015,2021 **** return line; } - #endif /* * Join 'count' lines (minimal 2) at cursor position. --- 2010,2015 ---- *************** *** 2047,2058 **** linenr_T t; colnr_T col = 0; int ret = OK; - #if defined(FEAT_COMMENTS) || defined(PROTO) int *comments = NULL; int remove_comments = (use_formatoptions == TRUE) && has_format_option(FO_REMOVE_COMS); int prev_was_comment; - #endif #ifdef FEAT_TEXT_PROP textprop_T **prop_lines = NULL; int *prop_lengths = NULL; --- 2041,2050 ---- *************** *** 2068,2074 **** spaces = lalloc_clear(count, TRUE); if (spaces == NULL) return FAIL; - #if defined(FEAT_COMMENTS) || defined(PROTO) if (remove_comments) { comments = lalloc_clear(count * sizeof(int), TRUE); --- 2060,2065 ---- *************** *** 2078,2084 **** return FAIL; } } - #endif /* * Don't move anything yet, just compute the final line length --- 2069,2074 ---- *************** *** 2094,2100 **** curwin->w_buffer->b_op_start.lnum = curwin->w_cursor.lnum; curwin->w_buffer->b_op_start.col = (colnr_T)STRLEN(curr); } - #if defined(FEAT_COMMENTS) || defined(PROTO) if (remove_comments) { /* We don't want to remove the comment leader if the --- 2084,2089 ---- *************** *** 2111,2117 **** curr = skip_comment(curr, FALSE, insert_space, &prev_was_comment); } - #endif if (insert_space && t > 0) { --- 2100,2105 ---- *************** *** 2230,2239 **** #endif curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t - 1)); - #if defined(FEAT_COMMENTS) if (remove_comments) curr += comments[t - 1]; - #endif if (insert_space && t > 1) curr = skipwhite(curr); currsize = (int)STRLEN(curr); --- 2218,2225 ---- *************** *** 2282,2295 **** theend: vim_free(spaces); - #if defined(FEAT_COMMENTS) || defined(PROTO) if (remove_comments) vim_free(comments); - #endif return ret; } - #ifdef FEAT_COMMENTS /* * Return TRUE if the two comment leaders given are the same. "lnum" is * the first line. White-space is ignored. Note that the whole of --- 2268,2278 ---- *************** *** 2365,2371 **** } return (idx2 == leader2_len && idx1 == leader1_len); } - #endif /* * Implementation of the format operator 'gq'. --- 2348,2353 ---- *************** *** 2513,2526 **** int is_end_par; /* at end of paragraph */ int prev_is_end_par = FALSE;/* prev. line not part of parag. */ int next_is_start_par = FALSE; - #ifdef FEAT_COMMENTS int leader_len = 0; /* leader len of current line */ int next_leader_len; /* leader len of next line */ char_u *leader_flags = NULL; /* flags for leader of current line */ char_u *next_leader_flags; /* flags for leader of next line */ int do_comments; /* format comments */ int do_comments_list = 0; /* format comments with 'n' or '2' */ - #endif int advance = TRUE; int second_indent = -1; /* indent for second line (comment * aware) */ --- 2495,2506 ---- *************** *** 2538,2546 **** max_len = comp_textwidth(TRUE) * 3; /* check for 'q', '2' and '1' in 'formatoptions' */ - #ifdef FEAT_COMMENTS do_comments = has_format_option(FO_Q_COMS); - #endif do_second_indent = has_format_option(FO_Q_SECOND); do_number_indent = has_format_option(FO_Q_NUMBER); do_trail_white = has_format_option(FO_WHITE_PAR); --- 2518,2524 ---- *************** *** 2550,2566 **** */ if (curwin->w_cursor.lnum > 1) is_not_par = fmt_check_par(curwin->w_cursor.lnum - 1 ! #ifdef FEAT_COMMENTS ! , &leader_len, &leader_flags, do_comments ! #endif ! ); else is_not_par = TRUE; next_is_not_par = fmt_check_par(curwin->w_cursor.lnum ! #ifdef FEAT_COMMENTS ! , &next_leader_len, &next_leader_flags, do_comments ! #endif ! ); is_end_par = (is_not_par || next_is_not_par); if (!is_end_par && do_trail_white) is_end_par = !ends_in_white(curwin->w_cursor.lnum - 1); --- 2528,2538 ---- */ if (curwin->w_cursor.lnum > 1) is_not_par = fmt_check_par(curwin->w_cursor.lnum - 1 ! , &leader_len, &leader_flags, do_comments); else is_not_par = TRUE; next_is_not_par = fmt_check_par(curwin->w_cursor.lnum ! , &next_leader_len, &next_leader_flags, do_comments); is_end_par = (is_not_par || next_is_not_par); if (!is_end_par && do_trail_white) is_end_par = !ends_in_white(curwin->w_cursor.lnum - 1); *************** *** 2576,2585 **** curwin->w_cursor.lnum++; prev_is_end_par = is_end_par; is_not_par = next_is_not_par; - #ifdef FEAT_COMMENTS leader_len = next_leader_len; leader_flags = next_leader_flags; - #endif } /* --- 2548,2555 ---- *************** *** 2588,2605 **** if (count == 1 || curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count) { next_is_not_par = TRUE; - #ifdef FEAT_COMMENTS next_leader_len = 0; next_leader_flags = NULL; - #endif } else { next_is_not_par = fmt_check_par(curwin->w_cursor.lnum + 1 ! #ifdef FEAT_COMMENTS ! , &next_leader_len, &next_leader_flags, do_comments ! #endif ! ); if (do_number_indent) next_is_start_par = (get_number_indent(curwin->w_cursor.lnum + 1) > 0); --- 2558,2570 ---- if (count == 1 || curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count) { next_is_not_par = TRUE; next_leader_len = 0; next_leader_flags = NULL; } else { next_is_not_par = fmt_check_par(curwin->w_cursor.lnum + 1 ! , &next_leader_len, &next_leader_flags, do_comments); if (do_number_indent) next_is_start_par = (get_number_indent(curwin->w_cursor.lnum + 1) > 0); *************** *** 2630,2661 **** { if (do_second_indent && !LINEEMPTY(curwin->w_cursor.lnum + 1)) { - #ifdef FEAT_COMMENTS if (leader_len == 0 && next_leader_len == 0) { /* no comment found */ - #endif second_indent = get_indent_lnum(curwin->w_cursor.lnum + 1); - #ifdef FEAT_COMMENTS } else { second_indent = next_leader_len; do_comments_list = 1; } - #endif } else if (do_number_indent) { - #ifdef FEAT_COMMENTS if (leader_len == 0 && next_leader_len == 0) { /* no comment found */ - #endif second_indent = get_number_indent(curwin->w_cursor.lnum); - #ifdef FEAT_COMMENTS } else { --- 2595,2619 ---- *************** *** 2664,2670 **** get_number_indent(curwin->w_cursor.lnum); do_comments_list = 1; } - #endif } } --- 2622,2627 ---- *************** *** 2672,2683 **** * When the comment leader changes, it's the end of the paragraph. */ if (curwin->w_cursor.lnum >= curbuf->b_ml.ml_line_count - #ifdef FEAT_COMMENTS || !same_leader(curwin->w_cursor.lnum, leader_len, leader_flags, ! next_leader_len, next_leader_flags) ! #endif ! ) is_end_par = TRUE; /* --- 2629,2637 ---- * When the comment leader changes, it's the end of the paragraph. */ if (curwin->w_cursor.lnum >= curbuf->b_ml.ml_line_count || !same_leader(curwin->w_cursor.lnum, leader_len, leader_flags, ! next_leader_len, next_leader_flags)) is_end_par = TRUE; /* *************** *** 2702,2712 **** smd_save = p_smd; p_smd = FALSE; insertchar(NUL, INSCHAR_FORMAT - #ifdef FEAT_COMMENTS + (do_comments ? INSCHAR_DO_COM : 0) + (do_comments && do_comments_list ? INSCHAR_COM_LIST : 0) - #endif + (avoid_fex ? INSCHAR_NO_FEX : 0), second_indent); State = old_State; p_smd = smd_save; --- 2656,2664 ---- *************** *** 2735,2749 **** curwin->w_cursor.col = 0; if (line_count < 0 && u_save_cursor() == FAIL) break; - #ifdef FEAT_COMMENTS if (next_leader_len > 0) { (void)del_bytes((long)next_leader_len, FALSE, FALSE); mark_col_adjust(curwin->w_cursor.lnum, (colnr_T)0, 0L, ! (long)-next_leader_len, 0); ! } else ! #endif ! if (second_indent > 0) /* the "leader" for FO_Q_SECOND */ { int indent = getwhitecols_curline(); --- 2687,2699 ---- curwin->w_cursor.col = 0; if (line_count < 0 && u_save_cursor() == FAIL) break; if (next_leader_len > 0) { (void)del_bytes((long)next_leader_len, FALSE, FALSE); mark_col_adjust(curwin->w_cursor.lnum, (colnr_T)0, 0L, ! (long)-next_leader_len, 0); ! } ! else if (second_indent > 0) // the "leader" for FO_Q_SECOND { int indent = getwhitecols_curline(); *************** *** 2797,2803 **** * previous line. A new paragraph starts after a blank line, or when the * comment leader changes -- webb. */ - #ifdef FEAT_COMMENTS static int fmt_check_par( linenr_T lnum, --- 2747,2752 ---- *************** *** 2828,2840 **** || (*leader_len > 0 && *flags == COM_END) || startPS(lnum, NUL, FALSE)); } - #else - static int - fmt_check_par(linenr_T lnum) - { - return (*skipwhite(ml_get(lnum)) == NUL || startPS(lnum, NUL, FALSE)); - } - #endif /* * Return TRUE when a paragraph starts in line "lnum". Return FALSE when the --- 2777,2782 ---- *************** *** 2844,2856 **** paragraph_start(linenr_T lnum) { char_u *p; - #ifdef FEAT_COMMENTS int leader_len = 0; /* leader len of current line */ char_u *leader_flags = NULL; /* flags for leader of current line */ int next_leader_len; /* leader len of next line */ char_u *next_leader_flags; /* flags for leader of next line */ int do_comments; /* format comments */ - #endif if (lnum <= 1) return TRUE; /* start of the file */ --- 2786,2796 ---- *************** *** 2859,2879 **** if (*p == NUL) return TRUE; /* after empty line */ - #ifdef FEAT_COMMENTS do_comments = has_format_option(FO_Q_COMS); ! #endif ! if (fmt_check_par(lnum - 1 ! #ifdef FEAT_COMMENTS ! , &leader_len, &leader_flags, do_comments ! #endif ! )) return TRUE; /* after non-paragraph line */ ! if (fmt_check_par(lnum ! #ifdef FEAT_COMMENTS ! , &next_leader_len, &next_leader_flags, do_comments ! #endif ! )) return TRUE; /* "lnum" is not a paragraph line */ if (has_format_option(FO_WHITE_PAR) && !ends_in_white(lnum - 1)) --- 2799,2809 ---- if (*p == NUL) return TRUE; /* after empty line */ do_comments = has_format_option(FO_Q_COMS); ! if (fmt_check_par(lnum - 1, &leader_len, &leader_flags, do_comments)) return TRUE; /* after non-paragraph line */ ! if (fmt_check_par(lnum, &next_leader_len, &next_leader_flags, do_comments)) return TRUE; /* "lnum" is not a paragraph line */ if (has_format_option(FO_WHITE_PAR) && !ends_in_white(lnum - 1)) *************** *** 2882,2892 **** if (has_format_option(FO_Q_NUMBER) && (get_number_indent(lnum) > 0)) return TRUE; /* numbered item starts in "lnum". */ - #ifdef FEAT_COMMENTS if (!same_leader(lnum - 1, leader_len, leader_flags, next_leader_len, next_leader_flags)) return TRUE; /* change of comment leader. */ - #endif return FALSE; } --- 2812,2820 ---- *** ../vim-8.1.2095/src/option.c 2019-09-28 16:29:44.171649790 +0200 --- src/option.c 2019-09-28 18:32:14.195322380 +0200 *************** *** 5386,5394 **** #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) case PV_CINW: return (char_u *)&(curbuf->b_p_cinw); #endif - #ifdef FEAT_COMMENTS case PV_COM: return (char_u *)&(curbuf->b_p_com); - #endif #ifdef FEAT_FOLDING case PV_CMS: return (char_u *)&(curbuf->b_p_cms); #endif --- 5386,5392 ---- *************** *** 5844,5852 **** ? vim_strsave(p_vsts_nopaste) : NULL; #endif buf->b_p_sn = p_sn; - #ifdef FEAT_COMMENTS buf->b_p_com = vim_strsave(p_com); - #endif #ifdef FEAT_FOLDING buf->b_p_cms = vim_strsave(p_cms); #endif --- 5842,5848 ---- *** ../vim-8.1.2095/src/optionstr.c 2019-09-16 21:05:21.123911709 +0200 --- src/optionstr.c 2019-09-28 18:32:28.931249677 +0200 *************** *** 231,239 **** check_string_option(&buf->b_p_fo); check_string_option(&buf->b_p_flp); check_string_option(&buf->b_p_isk); - #ifdef FEAT_COMMENTS check_string_option(&buf->b_p_com); - #endif #ifdef FEAT_FOLDING check_string_option(&buf->b_p_cms); #endif --- 231,237 ---- *************** *** 1263,1269 **** } } - #ifdef FEAT_COMMENTS // 'comments' else if (gvarp == &p_com) { --- 1261,1266 ---- *************** *** 1294,1300 **** s = skip_to_option_part(s); } } - #endif // 'listchars' else if (varp == &p_lcs) --- 1291,1296 ---- *** ../vim-8.1.2095/src/search.c 2019-09-21 20:46:14.728275744 +0200 --- src/search.c 2019-09-28 18:32:42.307183885 +0200 *************** *** 5393,5399 **** */ if (!define_matched && skip_comments) { - #ifdef FEAT_COMMENTS if ((*line != '#' || STRNCMP(skipwhite(line + 1), "define", 6) != 0) && get_leader_len(line, NULL, FALSE, TRUE)) --- 5393,5398 ---- *************** *** 5408,5414 **** p = skipwhite(line); if (matched || (p[0] == '/' && p[1] == '*') || p[0] == '*') - #endif for (p = line; *p && p < startp; ++p) { if (matched --- 5407,5412 ---- *** ../vim-8.1.2095/src/version.c 2019-09-28 17:25:06.518498628 +0200 --- src/version.c 2019-09-28 19:02:08.913701938 +0200 *************** *** 165,175 **** #else "-cmdline_info", #endif - #ifdef FEAT_COMMENTS "+comments", - #else - "-comments", - #endif #ifdef FEAT_CONCEAL "+conceal", #else --- 165,171 ---- *** ../vim-8.1.2095/src/globals.h 2019-09-25 21:43:07.275251603 +0200 --- src/globals.h 2019-09-28 18:33:44.590879941 +0200 *************** *** 800,806 **** */ EXTERN colnr_T ai_col INIT(= 0); - #ifdef FEAT_COMMENTS /* * This is a character which will end a start-middle-end comment when typed as * the first character on a new line. It is taken from the last character of --- 800,805 ---- *************** *** 808,814 **** * comment end in 'comments'. It is only valid when did_ai is TRUE. */ EXTERN int end_comment_pending INIT(= NUL); - #endif /* * This flag is set after a ":syncbind" to let the check_scrollbind() function --- 807,812 ---- *** ../vim-8.1.2095/src/option.h 2019-09-16 21:05:21.123911709 +0200 --- src/option.h 2019-09-28 18:33:56.650821511 +0200 *************** *** 478,486 **** #endif EXTERN long p_ph; // 'pumheight' EXTERN long p_pw; // 'pumwidth' - #ifdef FEAT_COMMENTS EXTERN char_u *p_com; // 'comments' - #endif EXTERN char_u *p_cpo; // 'cpoptions' #ifdef FEAT_CSCOPE EXTERN char_u *p_csprg; // 'cscopeprg' --- 478,484 ---- *************** *** 1094,1102 **** #ifdef FEAT_FOLDING , BV_CMS #endif - #ifdef FEAT_COMMENTS , BV_COM - #endif , BV_CPT , BV_DICT , BV_TSR --- 1092,1098 ---- *** ../vim-8.1.2095/src/optiondefs.h 2019-09-16 21:05:21.123911709 +0200 --- src/optiondefs.h 2019-09-28 18:34:19.346711874 +0200 *************** *** 52,60 **** #ifdef FEAT_FOLDING # define PV_CMS OPT_BUF(BV_CMS) #endif ! #ifdef FEAT_COMMENTS ! # define PV_COM OPT_BUF(BV_COM) ! #endif #define PV_CPT OPT_BUF(BV_CPT) #define PV_DICT OPT_BOTH(OPT_BUF(BV_DICT)) #define PV_TSR OPT_BOTH(OPT_BUF(BV_TSR)) --- 52,58 ---- #ifdef FEAT_FOLDING # define PV_CMS OPT_BUF(BV_CMS) #endif ! #define PV_COM OPT_BUF(BV_COM) #define PV_CPT OPT_BUF(BV_CPT) #define PV_DICT OPT_BOTH(OPT_BUF(BV_DICT)) #define PV_TSR OPT_BOTH(OPT_BUF(BV_TSR)) *************** *** 634,647 **** {(char_u *)80L, (char_u *)0L} SCTX_INIT}, {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA |P_NODUP|P_CURSWANT, - #ifdef FEAT_COMMENTS (char_u *)&p_com, PV_COM, {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-", (char_u *)0L} - #else - (char_u *)NULL, PV_NONE, - {(char_u *)0L, (char_u *)0L} - #endif SCTX_INIT}, {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT, #ifdef FEAT_FOLDING --- 632,640 ---- *** ../vim-8.1.2095/src/structs.h 2019-09-28 16:29:44.175649771 +0200 --- src/structs.h 2019-09-28 18:34:31.870651569 +0200 *************** *** 2429,2437 **** #if defined(FEAT_CINDENT) || defined(FEAT_SMARTINDENT) char_u *b_p_cinw; // 'cinwords' #endif - #ifdef FEAT_COMMENTS char_u *b_p_com; // 'comments' - #endif #ifdef FEAT_FOLDING char_u *b_p_cms; // 'commentstring' #endif --- 2429,2435 ---- *** ../vim-8.1.2095/runtime/doc/change.txt 2019-08-21 14:36:29.395376065 +0200 --- runtime/doc/change.txt 2019-09-28 18:34:55.370538761 +0200 *************** *** 1622,1629 **** "#include" is not recognized as a comment line. But a line that starts with "# define" is recognized. This is a compromise. - {not available when compiled without the |+comments| feature} - *fo-table* You can use the 'formatoptions' option to influence how Vim formats text. 'formatoptions' is a string that can contain any of the letters below. The --- 1618,1623 ---- *** ../vim-8.1.2095/runtime/doc/options.txt 2019-09-20 17:00:05.439834655 +0200 --- runtime/doc/options.txt 2019-09-28 18:35:14.098449179 +0200 *************** *** 1685,1692 **** 'comments' 'com' string (default "s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-") local to buffer - {not available when compiled without the |+comments| - feature} A comma separated list of strings that can start a comment line. See |format-comments|. See |option-backslash| about using backslashes to insert a space. --- 1685,1690 ---- *** ../vim-8.1.2095/runtime/doc/various.txt 2019-05-09 18:59:27.224463628 +0200 --- runtime/doc/various.txt 2019-09-28 18:35:35.562346834 +0200 *************** *** 332,342 **** m *+channel* inter process communication |channel| N *+cindent* |'cindent'|, C indenting N *+clientserver* Unix and Win32: Remote invocation |clientserver| ! *+clipboard* |clipboard| support ! N *+cmdline_compl* command line completion |cmdline-completion| S *+cmdline_hist* command line history |cmdline-history| N *+cmdline_info* |'showcmd'| and |'ruler'| ! N *+comments* |'comments'| support B *+conceal* "conceal" support, see |conceal| |:syn-conceal| etc. N *+cryptv* encryption support |encryption| B *+cscope* |cscope| support --- 332,343 ---- m *+channel* inter process communication |channel| N *+cindent* |'cindent'|, C indenting N *+clientserver* Unix and Win32: Remote invocation |clientserver| ! *+clipboard* |clipboard| support compiled-in ! *+clipboard_working* |clipboard| support compiled-in and working ! T *+cmdline_compl* command line completion |cmdline-completion| S *+cmdline_hist* command line history |cmdline-history| N *+cmdline_info* |'showcmd'| and |'ruler'| ! T *+comments* |'comments'| support B *+conceal* "conceal" support, see |conceal| |:syn-conceal| etc. N *+cryptv* encryption support |encryption| B *+cscope* |cscope| support *** ../vim-8.1.2095/src/version.c 2019-09-28 17:25:06.518498628 +0200 --- src/version.c 2019-09-28 19:02:08.913701938 +0200 *************** *** 759,760 **** --- 755,758 ---- { /* Add new patch number below this line */ + /**/ + 2096, /**/ -- ARTHUR: Then who is your lord? WOMAN: We don't have a lord. ARTHUR: What? DENNIS: I told you. We're an anarcho-syndicalist commune. We take it in turns to act as a sort of executive officer for the week. The Quest for the Holy Grail (Monty Python) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///