|
Karsten Hopp |
e32f63 |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
e32f63 |
Subject: Patch 7.3.552
|
|
Karsten Hopp |
e32f63 |
Fcc: outbox
|
|
Karsten Hopp |
e32f63 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
e32f63 |
Mime-Version: 1.0
|
|
Karsten Hopp |
e32f63 |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
e32f63 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
e32f63 |
------------
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
Patch 7.3.552
|
|
Karsten Hopp |
e32f63 |
Problem: Formatting inside comments does not use the "2" flag in
|
|
Karsten Hopp |
e32f63 |
'formatoptions'.
|
|
Karsten Hopp |
e32f63 |
Solution: Support the "2" flag. (Tor Perkins)
|
|
Karsten Hopp |
e32f63 |
Files: src/vim.h, src/ops.c, src/edit.c, src/misc1.c,
|
|
Karsten Hopp |
e32f63 |
src/testdir/test68.in, src/testdir/test68.ok
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
*** ../vim-7.3.551/src/vim.h 2012-06-06 18:03:01.000000000 +0200
|
|
Karsten Hopp |
e32f63 |
--- src/vim.h 2012-06-13 16:07:27.000000000 +0200
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 1072,1083 ****
|
|
Karsten Hopp |
e32f63 |
--- 1072,1085 ----
|
|
Karsten Hopp |
e32f63 |
#define INSCHAR_DO_COM 2 /* format comments */
|
|
Karsten Hopp |
e32f63 |
#define INSCHAR_CTRLV 4 /* char typed just after CTRL-V */
|
|
Karsten Hopp |
e32f63 |
#define INSCHAR_NO_FEX 8 /* don't use 'formatexpr' */
|
|
Karsten Hopp |
e32f63 |
+ #define INSCHAR_COM_LIST 16 /* format comments with list/2nd line indent */
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
/* flags for open_line() */
|
|
Karsten Hopp |
e32f63 |
#define OPENLINE_DELSPACES 1 /* delete spaces after cursor */
|
|
Karsten Hopp |
e32f63 |
#define OPENLINE_DO_COM 2 /* format comments */
|
|
Karsten Hopp |
e32f63 |
#define OPENLINE_KEEPTRAIL 4 /* keep trailing spaces */
|
|
Karsten Hopp |
e32f63 |
#define OPENLINE_MARKFIX 8 /* fix mark positions */
|
|
Karsten Hopp |
e32f63 |
+ #define OPENLINE_COM_LIST 16 /* format comments with list/2nd line indent */
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
/*
|
|
Karsten Hopp |
e32f63 |
* There are four history tables:
|
|
Karsten Hopp |
e32f63 |
*** ../vim-7.3.551/src/ops.c 2012-06-13 14:01:36.000000000 +0200
|
|
Karsten Hopp |
e32f63 |
--- src/ops.c 2012-06-13 16:53:44.000000000 +0200
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 1727,1734 ****
|
|
Karsten Hopp |
e32f63 |
* and the delete is within one line. */
|
|
Karsten Hopp |
e32f63 |
if ((
|
|
Karsten Hopp |
e32f63 |
#ifdef FEAT_CLIPBOARD
|
|
Karsten Hopp |
e32f63 |
! ((clip_unnamed & CLIP_UNNAMED) && oap->regname == '*') ||
|
|
Karsten Hopp |
e32f63 |
! ((clip_unnamed & CLIP_UNNAMED_PLUS) && oap->regname == '+') ||
|
|
Karsten Hopp |
e32f63 |
#endif
|
|
Karsten Hopp |
e32f63 |
oap->regname == 0) && oap->motion_type != MLINE
|
|
Karsten Hopp |
e32f63 |
&& oap->line_count == 1)
|
|
Karsten Hopp |
e32f63 |
--- 1727,1734 ----
|
|
Karsten Hopp |
e32f63 |
* and the delete is within one line. */
|
|
Karsten Hopp |
e32f63 |
if ((
|
|
Karsten Hopp |
e32f63 |
#ifdef FEAT_CLIPBOARD
|
|
Karsten Hopp |
e32f63 |
! ((clip_unnamed & CLIP_UNNAMED) && oap->regname == '*') ||
|
|
Karsten Hopp |
e32f63 |
! ((clip_unnamed & CLIP_UNNAMED_PLUS) && oap->regname == '+') ||
|
|
Karsten Hopp |
e32f63 |
#endif
|
|
Karsten Hopp |
e32f63 |
oap->regname == 0) && oap->motion_type != MLINE
|
|
Karsten Hopp |
e32f63 |
&& oap->line_count == 1)
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 4208,4217 ****
|
|
Karsten Hopp |
e32f63 |
* "is_comment".
|
|
Karsten Hopp |
e32f63 |
* line - line to be processed,
|
|
Karsten Hopp |
e32f63 |
* process - if FALSE, will only check whether the line ends with an unclosed
|
|
Karsten Hopp |
e32f63 |
! * comment,
|
|
Karsten Hopp |
e32f63 |
* include_space - whether to also skip space following the comment leader,
|
|
Karsten Hopp |
e32f63 |
* is_comment - will indicate whether the current line ends with an unclosed
|
|
Karsten Hopp |
e32f63 |
! * comment.
|
|
Karsten Hopp |
e32f63 |
*/
|
|
Karsten Hopp |
e32f63 |
static char_u *
|
|
Karsten Hopp |
e32f63 |
skip_comment(line, process, include_space, is_comment)
|
|
Karsten Hopp |
e32f63 |
--- 4208,4217 ----
|
|
Karsten Hopp |
e32f63 |
* "is_comment".
|
|
Karsten Hopp |
e32f63 |
* line - line to be processed,
|
|
Karsten Hopp |
e32f63 |
* process - if FALSE, will only check whether the line ends with an unclosed
|
|
Karsten Hopp |
e32f63 |
! * comment,
|
|
Karsten Hopp |
e32f63 |
* include_space - whether to also skip space following the comment leader,
|
|
Karsten Hopp |
e32f63 |
* is_comment - will indicate whether the current line ends with an unclosed
|
|
Karsten Hopp |
e32f63 |
! * comment.
|
|
Karsten Hopp |
e32f63 |
*/
|
|
Karsten Hopp |
e32f63 |
static char_u *
|
|
Karsten Hopp |
e32f63 |
skip_comment(line, process, include_space, is_comment)
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 4723,4731 ****
|
|
Karsten Hopp |
e32f63 |
char_u *leader_flags = NULL; /* flags for leader of current line */
|
|
Karsten Hopp |
e32f63 |
char_u *next_leader_flags; /* flags for leader of next line */
|
|
Karsten Hopp |
e32f63 |
int do_comments; /* format comments */
|
|
Karsten Hopp |
e32f63 |
#endif
|
|
Karsten Hopp |
e32f63 |
int advance = TRUE;
|
|
Karsten Hopp |
e32f63 |
! int second_indent = -1;
|
|
Karsten Hopp |
e32f63 |
int do_second_indent;
|
|
Karsten Hopp |
e32f63 |
int do_number_indent;
|
|
Karsten Hopp |
e32f63 |
int do_trail_white;
|
|
Karsten Hopp |
e32f63 |
--- 4723,4733 ----
|
|
Karsten Hopp |
e32f63 |
char_u *leader_flags = NULL; /* flags for leader of current line */
|
|
Karsten Hopp |
e32f63 |
char_u *next_leader_flags; /* flags for leader of next line */
|
|
Karsten Hopp |
e32f63 |
int do_comments; /* format comments */
|
|
Karsten Hopp |
e32f63 |
+ int do_comments_list = 0; /* format comments with 'n' or '2' */
|
|
Karsten Hopp |
e32f63 |
#endif
|
|
Karsten Hopp |
e32f63 |
int advance = TRUE;
|
|
Karsten Hopp |
e32f63 |
! int second_indent = -1; /* indent for second line (comment
|
|
Karsten Hopp |
e32f63 |
! * aware) */
|
|
Karsten Hopp |
e32f63 |
int do_second_indent;
|
|
Karsten Hopp |
e32f63 |
int do_number_indent;
|
|
Karsten Hopp |
e32f63 |
int do_trail_white;
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 4828,4845 ****
|
|
Karsten Hopp |
e32f63 |
if (first_par_line
|
|
Karsten Hopp |
e32f63 |
&& (do_second_indent || do_number_indent)
|
|
Karsten Hopp |
e32f63 |
&& prev_is_end_par
|
|
Karsten Hopp |
e32f63 |
! && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count
|
|
Karsten Hopp |
e32f63 |
#ifdef FEAT_COMMENTS
|
|
Karsten Hopp |
e32f63 |
! && leader_len == 0
|
|
Karsten Hopp |
e32f63 |
! && next_leader_len == 0
|
|
Karsten Hopp |
e32f63 |
#endif
|
|
Karsten Hopp |
e32f63 |
! )
|
|
Karsten Hopp |
e32f63 |
! {
|
|
Karsten Hopp |
e32f63 |
! if (do_second_indent
|
|
Karsten Hopp |
e32f63 |
! && !lineempty(curwin->w_cursor.lnum + 1))
|
|
Karsten Hopp |
e32f63 |
! second_indent = get_indent_lnum(curwin->w_cursor.lnum + 1);
|
|
Karsten Hopp |
e32f63 |
else if (do_number_indent)
|
|
Karsten Hopp |
e32f63 |
! second_indent = get_number_indent(curwin->w_cursor.lnum);
|
|
Karsten Hopp |
e32f63 |
}
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
/*
|
|
Karsten Hopp |
e32f63 |
--- 4830,4875 ----
|
|
Karsten Hopp |
e32f63 |
if (first_par_line
|
|
Karsten Hopp |
e32f63 |
&& (do_second_indent || do_number_indent)
|
|
Karsten Hopp |
e32f63 |
&& prev_is_end_par
|
|
Karsten Hopp |
e32f63 |
! && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count)
|
|
Karsten Hopp |
e32f63 |
! {
|
|
Karsten Hopp |
e32f63 |
! if (do_second_indent && !lineempty(curwin->w_cursor.lnum + 1))
|
|
Karsten Hopp |
e32f63 |
! {
|
|
Karsten Hopp |
e32f63 |
#ifdef FEAT_COMMENTS
|
|
Karsten Hopp |
e32f63 |
! if (leader_len == 0 && next_leader_len == 0)
|
|
Karsten Hopp |
e32f63 |
! {
|
|
Karsten Hopp |
e32f63 |
! /* no comment found */
|
|
Karsten Hopp |
e32f63 |
#endif
|
|
Karsten Hopp |
e32f63 |
! second_indent =
|
|
Karsten Hopp |
e32f63 |
! get_indent_lnum(curwin->w_cursor.lnum + 1);
|
|
Karsten Hopp |
e32f63 |
! #ifdef FEAT_COMMENTS
|
|
Karsten Hopp |
e32f63 |
! }
|
|
Karsten Hopp |
e32f63 |
! else
|
|
Karsten Hopp |
e32f63 |
! {
|
|
Karsten Hopp |
e32f63 |
! second_indent = next_leader_len;
|
|
Karsten Hopp |
e32f63 |
! do_comments_list = 1;
|
|
Karsten Hopp |
e32f63 |
! }
|
|
Karsten Hopp |
e32f63 |
! #endif
|
|
Karsten Hopp |
e32f63 |
! }
|
|
Karsten Hopp |
e32f63 |
else if (do_number_indent)
|
|
Karsten Hopp |
e32f63 |
! {
|
|
Karsten Hopp |
e32f63 |
! #ifdef FEAT_COMMENTS
|
|
Karsten Hopp |
e32f63 |
! if (leader_len == 0 && next_leader_len == 0)
|
|
Karsten Hopp |
e32f63 |
! {
|
|
Karsten Hopp |
e32f63 |
! /* no comment found */
|
|
Karsten Hopp |
e32f63 |
! #endif
|
|
Karsten Hopp |
e32f63 |
! second_indent =
|
|
Karsten Hopp |
e32f63 |
! get_number_indent(curwin->w_cursor.lnum);
|
|
Karsten Hopp |
e32f63 |
! #ifdef FEAT_COMMENTS
|
|
Karsten Hopp |
e32f63 |
! }
|
|
Karsten Hopp |
e32f63 |
! else
|
|
Karsten Hopp |
e32f63 |
! {
|
|
Karsten Hopp |
e32f63 |
! /* get_number_indent() is now "comment aware"... */
|
|
Karsten Hopp |
e32f63 |
! second_indent =
|
|
Karsten Hopp |
e32f63 |
! get_number_indent(curwin->w_cursor.lnum);
|
|
Karsten Hopp |
e32f63 |
! do_comments_list = 1;
|
|
Karsten Hopp |
e32f63 |
! }
|
|
Karsten Hopp |
e32f63 |
! #endif
|
|
Karsten Hopp |
e32f63 |
! }
|
|
Karsten Hopp |
e32f63 |
}
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
/*
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 4878,4883 ****
|
|
Karsten Hopp |
e32f63 |
--- 4908,4915 ----
|
|
Karsten Hopp |
e32f63 |
insertchar(NUL, INSCHAR_FORMAT
|
|
Karsten Hopp |
e32f63 |
#ifdef FEAT_COMMENTS
|
|
Karsten Hopp |
e32f63 |
+ (do_comments ? INSCHAR_DO_COM : 0)
|
|
Karsten Hopp |
e32f63 |
+ + (do_comments && do_comments_list
|
|
Karsten Hopp |
e32f63 |
+ ? INSCHAR_COM_LIST : 0)
|
|
Karsten Hopp |
e32f63 |
#endif
|
|
Karsten Hopp |
e32f63 |
+ (avoid_fex ? INSCHAR_NO_FEX : 0), second_indent);
|
|
Karsten Hopp |
e32f63 |
State = old_State;
|
|
Karsten Hopp |
e32f63 |
*** ../vim-7.3.551/src/edit.c 2012-06-06 16:12:54.000000000 +0200
|
|
Karsten Hopp |
e32f63 |
--- src/edit.c 2012-06-13 16:54:10.000000000 +0200
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 1463,1469 ****
|
|
Karsten Hopp |
e32f63 |
* what check_abbr() expects. */
|
|
Karsten Hopp |
e32f63 |
(has_mbyte && c >= 0x100) ? (c + ABBR_OFF) :
|
|
Karsten Hopp |
e32f63 |
#endif
|
|
Karsten Hopp |
e32f63 |
! c) && c != Ctrl_RSB))
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
insert_special(c, FALSE, FALSE);
|
|
Karsten Hopp |
e32f63 |
#ifdef FEAT_RIGHTLEFT
|
|
Karsten Hopp |
e32f63 |
--- 1463,1469 ----
|
|
Karsten Hopp |
e32f63 |
* what check_abbr() expects. */
|
|
Karsten Hopp |
e32f63 |
(has_mbyte && c >= 0x100) ? (c + ABBR_OFF) :
|
|
Karsten Hopp |
e32f63 |
#endif
|
|
Karsten Hopp |
e32f63 |
! c) && c != Ctrl_RSB))
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
insert_special(c, FALSE, FALSE);
|
|
Karsten Hopp |
e32f63 |
#ifdef FEAT_RIGHTLEFT
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 5769,5774 ****
|
|
Karsten Hopp |
e32f63 |
--- 5769,5784 ----
|
|
Karsten Hopp |
e32f63 |
# define WHITECHAR(cc) vim_iswhite(cc)
|
|
Karsten Hopp |
e32f63 |
#endif
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
+ /*
|
|
Karsten Hopp |
e32f63 |
+ * "flags": INSCHAR_FORMAT - force formatting
|
|
Karsten Hopp |
e32f63 |
+ * INSCHAR_CTRLV - char typed just after CTRL-V
|
|
Karsten Hopp |
e32f63 |
+ * INSCHAR_NO_FEX - don't use 'formatexpr'
|
|
Karsten Hopp |
e32f63 |
+ *
|
|
Karsten Hopp |
e32f63 |
+ * NOTE: passes the flags value straight through to internal_format() which,
|
|
Karsten Hopp |
e32f63 |
+ * beside INSCHAR_FORMAT (above), is also looking for these:
|
|
Karsten Hopp |
e32f63 |
+ * INSCHAR_DO_COM - format comments
|
|
Karsten Hopp |
e32f63 |
+ * INSCHAR_COM_LIST - format comments with num list or 2nd line indent
|
|
Karsten Hopp |
e32f63 |
+ */
|
|
Karsten Hopp |
e32f63 |
void
|
|
Karsten Hopp |
e32f63 |
insertchar(c, flags, second_indent)
|
|
Karsten Hopp |
e32f63 |
int c; /* character to insert or NUL */
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 6011,6016 ****
|
|
Karsten Hopp |
e32f63 |
--- 6021,6029 ----
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
/*
|
|
Karsten Hopp |
e32f63 |
* Format text at the current insert position.
|
|
Karsten Hopp |
e32f63 |
+ *
|
|
Karsten Hopp |
e32f63 |
+ * If the INSCHAR_COM_LIST flag is present, then the value of second_indent
|
|
Karsten Hopp |
e32f63 |
+ * will be the comment leader length sent to open_line().
|
|
Karsten Hopp |
e32f63 |
*/
|
|
Karsten Hopp |
e32f63 |
static void
|
|
Karsten Hopp |
e32f63 |
internal_format(textwidth, second_indent, flags, format_only, c)
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 6289,6311 ****
|
|
Karsten Hopp |
e32f63 |
+ (fo_white_par ? OPENLINE_KEEPTRAIL : 0)
|
|
Karsten Hopp |
e32f63 |
#ifdef FEAT_COMMENTS
|
|
Karsten Hopp |
e32f63 |
+ (do_comments ? OPENLINE_DO_COM : 0)
|
|
Karsten Hopp |
e32f63 |
#endif
|
|
Karsten Hopp |
e32f63 |
! , old_indent);
|
|
Karsten Hopp |
e32f63 |
! old_indent = 0;
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
replace_offset = 0;
|
|
Karsten Hopp |
e32f63 |
if (first_line)
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
! if (second_indent < 0 && has_format_option(FO_Q_NUMBER))
|
|
Karsten Hopp |
e32f63 |
! second_indent = get_number_indent(curwin->w_cursor.lnum -1);
|
|
Karsten Hopp |
e32f63 |
! if (second_indent >= 0)
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
#ifdef FEAT_VREPLACE
|
|
Karsten Hopp |
e32f63 |
! if (State & VREPLACE_FLAG)
|
|
Karsten Hopp |
e32f63 |
! change_indent(INDENT_SET, second_indent, FALSE, NUL, TRUE);
|
|
Karsten Hopp |
e32f63 |
! else
|
|
Karsten Hopp |
e32f63 |
#endif
|
|
Karsten Hopp |
e32f63 |
! (void)set_indent(second_indent, SIN_CHANGED);
|
|
Karsten Hopp |
e32f63 |
}
|
|
Karsten Hopp |
e32f63 |
first_line = FALSE;
|
|
Karsten Hopp |
e32f63 |
}
|
|
Karsten Hopp |
e32f63 |
--- 6302,6337 ----
|
|
Karsten Hopp |
e32f63 |
+ (fo_white_par ? OPENLINE_KEEPTRAIL : 0)
|
|
Karsten Hopp |
e32f63 |
#ifdef FEAT_COMMENTS
|
|
Karsten Hopp |
e32f63 |
+ (do_comments ? OPENLINE_DO_COM : 0)
|
|
Karsten Hopp |
e32f63 |
+ + ((flags & INSCHAR_COM_LIST) ? OPENLINE_COM_LIST : 0)
|
|
Karsten Hopp |
e32f63 |
#endif
|
|
Karsten Hopp |
e32f63 |
! , ((flags & INSCHAR_COM_LIST) ? second_indent : old_indent));
|
|
Karsten Hopp |
e32f63 |
! if (!(flags & INSCHAR_COM_LIST))
|
|
Karsten Hopp |
e32f63 |
! old_indent = 0;
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
replace_offset = 0;
|
|
Karsten Hopp |
e32f63 |
if (first_line)
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
! if (!(flags & INSCHAR_COM_LIST))
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
+ /*
|
|
Karsten Hopp |
e32f63 |
+ * This section is for numeric lists w/o comments. If comment
|
|
Karsten Hopp |
e32f63 |
+ * indents are needed with numeric lists (formatoptions=nq),
|
|
Karsten Hopp |
e32f63 |
+ * then the INSCHAR_COM_LIST flag will cause the corresponding
|
|
Karsten Hopp |
e32f63 |
+ * OPENLINE_COM_LIST flag to be passed through to open_line()
|
|
Karsten Hopp |
e32f63 |
+ * (as seen above)...
|
|
Karsten Hopp |
e32f63 |
+ */
|
|
Karsten Hopp |
e32f63 |
+ if (second_indent < 0 && has_format_option(FO_Q_NUMBER))
|
|
Karsten Hopp |
e32f63 |
+ second_indent = get_number_indent(curwin->w_cursor.lnum -1);
|
|
Karsten Hopp |
e32f63 |
+ if (second_indent >= 0)
|
|
Karsten Hopp |
e32f63 |
+ {
|
|
Karsten Hopp |
e32f63 |
#ifdef FEAT_VREPLACE
|
|
Karsten Hopp |
e32f63 |
! if (State & VREPLACE_FLAG)
|
|
Karsten Hopp |
e32f63 |
! change_indent(INDENT_SET, second_indent,
|
|
Karsten Hopp |
e32f63 |
! FALSE, NUL, TRUE);
|
|
Karsten Hopp |
e32f63 |
! else
|
|
Karsten Hopp |
e32f63 |
#endif
|
|
Karsten Hopp |
e32f63 |
! (void)set_indent(second_indent, SIN_CHANGED);
|
|
Karsten Hopp |
e32f63 |
! }
|
|
Karsten Hopp |
e32f63 |
}
|
|
Karsten Hopp |
e32f63 |
first_line = FALSE;
|
|
Karsten Hopp |
e32f63 |
}
|
|
Karsten Hopp |
e32f63 |
*** ../vim-7.3.551/src/misc1.c 2012-06-13 13:40:45.000000000 +0200
|
|
Karsten Hopp |
e32f63 |
--- src/misc1.c 2012-06-13 16:54:59.000000000 +0200
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 423,449 ****
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
colnr_T col;
|
|
Karsten Hopp |
e32f63 |
pos_T pos;
|
|
Karsten Hopp |
e32f63 |
- regmmatch_T regmatch;
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
if (lnum > curbuf->b_ml.ml_line_count)
|
|
Karsten Hopp |
e32f63 |
return -1;
|
|
Karsten Hopp |
e32f63 |
pos.lnum = 0;
|
|
Karsten Hopp |
e32f63 |
! regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC);
|
|
Karsten Hopp |
e32f63 |
! if (regmatch.regprog != NULL)
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
! regmatch.rmm_ic = FALSE;
|
|
Karsten Hopp |
e32f63 |
! regmatch.rmm_maxcol = 0;
|
|
Karsten Hopp |
e32f63 |
! if (vim_regexec_multi(®match, curwin, curbuf, lnum,
|
|
Karsten Hopp |
e32f63 |
! (colnr_T)0, NULL))
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
! pos.lnum = regmatch.endpos[0].lnum + lnum;
|
|
Karsten Hopp |
e32f63 |
! pos.col = regmatch.endpos[0].col;
|
|
Karsten Hopp |
e32f63 |
#ifdef FEAT_VIRTUALEDIT
|
|
Karsten Hopp |
e32f63 |
! pos.coladd = 0;
|
|
Karsten Hopp |
e32f63 |
#endif
|
|
Karsten Hopp |
e32f63 |
}
|
|
Karsten Hopp |
e32f63 |
vim_free(regmatch.regprog);
|
|
Karsten Hopp |
e32f63 |
}
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
if (pos.lnum == 0 || *ml_get_pos(&pos) == NUL)
|
|
Karsten Hopp |
e32f63 |
return -1;
|
|
Karsten Hopp |
e32f63 |
--- 423,492 ----
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
colnr_T col;
|
|
Karsten Hopp |
e32f63 |
pos_T pos;
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
if (lnum > curbuf->b_ml.ml_line_count)
|
|
Karsten Hopp |
e32f63 |
return -1;
|
|
Karsten Hopp |
e32f63 |
pos.lnum = 0;
|
|
Karsten Hopp |
e32f63 |
!
|
|
Karsten Hopp |
e32f63 |
! #ifdef FEAT_COMMENTS
|
|
Karsten Hopp |
e32f63 |
! if (has_format_option(FO_Q_COMS) && has_format_option(FO_Q_NUMBER))
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
! regmatch_T regmatch;
|
|
Karsten Hopp |
e32f63 |
! int lead_len; /* length of comment leader */
|
|
Karsten Hopp |
e32f63 |
!
|
|
Karsten Hopp |
e32f63 |
! lead_len = get_leader_len(ml_get(lnum), NULL, FALSE, TRUE);
|
|
Karsten Hopp |
e32f63 |
! regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC);
|
|
Karsten Hopp |
e32f63 |
! if (regmatch.regprog != NULL)
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
! regmatch.rm_ic = FALSE;
|
|
Karsten Hopp |
e32f63 |
!
|
|
Karsten Hopp |
e32f63 |
! /* vim_regexec() expects a pointer to a line. This lets us
|
|
Karsten Hopp |
e32f63 |
! * start matching for the flp beyond any comment leader... */
|
|
Karsten Hopp |
e32f63 |
! if (vim_regexec(®match, ml_get(lnum) + lead_len, (colnr_T)0))
|
|
Karsten Hopp |
e32f63 |
! {
|
|
Karsten Hopp |
e32f63 |
! pos.lnum = lnum;
|
|
Karsten Hopp |
e32f63 |
! pos.col = *regmatch.endp - (ml_get(lnum) + lead_len);
|
|
Karsten Hopp |
e32f63 |
! pos.col += lead_len;
|
|
Karsten Hopp |
e32f63 |
#ifdef FEAT_VIRTUALEDIT
|
|
Karsten Hopp |
e32f63 |
! pos.coladd = 0;
|
|
Karsten Hopp |
e32f63 |
#endif
|
|
Karsten Hopp |
e32f63 |
+ }
|
|
Karsten Hopp |
e32f63 |
}
|
|
Karsten Hopp |
e32f63 |
vim_free(regmatch.regprog);
|
|
Karsten Hopp |
e32f63 |
}
|
|
Karsten Hopp |
e32f63 |
+ else
|
|
Karsten Hopp |
e32f63 |
+ {
|
|
Karsten Hopp |
e32f63 |
+ /*
|
|
Karsten Hopp |
e32f63 |
+ * What follows is the orig code that is not "comment aware"...
|
|
Karsten Hopp |
e32f63 |
+ *
|
|
Karsten Hopp |
e32f63 |
+ * I'm not sure if regmmatch_T (multi-match) is needed in this case.
|
|
Karsten Hopp |
e32f63 |
+ * It may be true that this section would work properly using the
|
|
Karsten Hopp |
e32f63 |
+ * regmatch_T code above, in which case, these two seperate sections
|
|
Karsten Hopp |
e32f63 |
+ * should be consolidated w/ FEAT_COMMENTS making lead_len > 0...
|
|
Karsten Hopp |
e32f63 |
+ */
|
|
Karsten Hopp |
e32f63 |
+ #endif
|
|
Karsten Hopp |
e32f63 |
+ regmmatch_T regmatch;
|
|
Karsten Hopp |
e32f63 |
+
|
|
Karsten Hopp |
e32f63 |
+ regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC);
|
|
Karsten Hopp |
e32f63 |
+
|
|
Karsten Hopp |
e32f63 |
+ if (regmatch.regprog != NULL)
|
|
Karsten Hopp |
e32f63 |
+ {
|
|
Karsten Hopp |
e32f63 |
+ regmatch.rmm_ic = FALSE;
|
|
Karsten Hopp |
e32f63 |
+ regmatch.rmm_maxcol = 0;
|
|
Karsten Hopp |
e32f63 |
+ if (vim_regexec_multi(®match, curwin, curbuf,
|
|
Karsten Hopp |
e32f63 |
+ lnum, (colnr_T)0, NULL))
|
|
Karsten Hopp |
e32f63 |
+ {
|
|
Karsten Hopp |
e32f63 |
+ pos.lnum = regmatch.endpos[0].lnum + lnum;
|
|
Karsten Hopp |
e32f63 |
+ pos.col = regmatch.endpos[0].col;
|
|
Karsten Hopp |
e32f63 |
+ #ifdef FEAT_VIRTUALEDIT
|
|
Karsten Hopp |
e32f63 |
+ pos.coladd = 0;
|
|
Karsten Hopp |
e32f63 |
+ #endif
|
|
Karsten Hopp |
e32f63 |
+ }
|
|
Karsten Hopp |
e32f63 |
+ vim_free(regmatch.regprog);
|
|
Karsten Hopp |
e32f63 |
+ }
|
|
Karsten Hopp |
e32f63 |
+ #ifdef FEAT_COMMENTS
|
|
Karsten Hopp |
e32f63 |
+ }
|
|
Karsten Hopp |
e32f63 |
+ #endif
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
if (pos.lnum == 0 || *ml_get_pos(&pos) == NUL)
|
|
Karsten Hopp |
e32f63 |
return -1;
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 502,515 ****
|
|
Karsten Hopp |
e32f63 |
* OPENLINE_DO_COM format comments
|
|
Karsten Hopp |
e32f63 |
* OPENLINE_KEEPTRAIL keep trailing spaces
|
|
Karsten Hopp |
e32f63 |
* OPENLINE_MARKFIX adjust mark positions after the line break
|
|
Karsten Hopp |
e32f63 |
*
|
|
Karsten Hopp |
e32f63 |
* Return TRUE for success, FALSE for failure
|
|
Karsten Hopp |
e32f63 |
*/
|
|
Karsten Hopp |
e32f63 |
int
|
|
Karsten Hopp |
e32f63 |
! open_line(dir, flags, old_indent)
|
|
Karsten Hopp |
e32f63 |
int dir; /* FORWARD or BACKWARD */
|
|
Karsten Hopp |
e32f63 |
int flags;
|
|
Karsten Hopp |
e32f63 |
! int old_indent; /* indent for after ^^D in Insert mode */
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
char_u *saved_line; /* copy of the original line */
|
|
Karsten Hopp |
e32f63 |
char_u *next_line = NULL; /* copy of the next line */
|
|
Karsten Hopp |
e32f63 |
--- 545,562 ----
|
|
Karsten Hopp |
e32f63 |
* OPENLINE_DO_COM format comments
|
|
Karsten Hopp |
e32f63 |
* OPENLINE_KEEPTRAIL keep trailing spaces
|
|
Karsten Hopp |
e32f63 |
* OPENLINE_MARKFIX adjust mark positions after the line break
|
|
Karsten Hopp |
e32f63 |
+ * OPENLINE_COM_LIST format comments with list or 2nd line indent
|
|
Karsten Hopp |
e32f63 |
+ *
|
|
Karsten Hopp |
e32f63 |
+ * "second_line_indent": indent for after ^^D in Insert mode or if flag
|
|
Karsten Hopp |
e32f63 |
+ * OPENLINE_COM_LIST
|
|
Karsten Hopp |
e32f63 |
*
|
|
Karsten Hopp |
e32f63 |
* Return TRUE for success, FALSE for failure
|
|
Karsten Hopp |
e32f63 |
*/
|
|
Karsten Hopp |
e32f63 |
int
|
|
Karsten Hopp |
e32f63 |
! open_line(dir, flags, second_line_indent)
|
|
Karsten Hopp |
e32f63 |
int dir; /* FORWARD or BACKWARD */
|
|
Karsten Hopp |
e32f63 |
int flags;
|
|
Karsten Hopp |
e32f63 |
! int second_line_indent;
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
char_u *saved_line; /* copy of the original line */
|
|
Karsten Hopp |
e32f63 |
char_u *next_line = NULL; /* copy of the next line */
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 650,657 ****
|
|
Karsten Hopp |
e32f63 |
* count white space on current line
|
|
Karsten Hopp |
e32f63 |
*/
|
|
Karsten Hopp |
e32f63 |
newindent = get_indent_str(saved_line, (int)curbuf->b_p_ts);
|
|
Karsten Hopp |
e32f63 |
! if (newindent == 0)
|
|
Karsten Hopp |
e32f63 |
! newindent = old_indent; /* for ^^D command in insert mode */
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
#ifdef FEAT_SMARTINDENT
|
|
Karsten Hopp |
e32f63 |
/*
|
|
Karsten Hopp |
e32f63 |
--- 697,704 ----
|
|
Karsten Hopp |
e32f63 |
* count white space on current line
|
|
Karsten Hopp |
e32f63 |
*/
|
|
Karsten Hopp |
e32f63 |
newindent = get_indent_str(saved_line, (int)curbuf->b_p_ts);
|
|
Karsten Hopp |
e32f63 |
! if (newindent == 0 && !(flags & OPENLINE_COM_LIST))
|
|
Karsten Hopp |
e32f63 |
! newindent = second_line_indent; /* for ^^D command in insert mode */
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
#ifdef FEAT_SMARTINDENT
|
|
Karsten Hopp |
e32f63 |
/*
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 1008,1015 ****
|
|
Karsten Hopp |
e32f63 |
if (lead_len)
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
/* allocate buffer (may concatenate p_exta later) */
|
|
Karsten Hopp |
e32f63 |
! leader = alloc(lead_len + lead_repl_len + extra_space +
|
|
Karsten Hopp |
e32f63 |
! extra_len + 1);
|
|
Karsten Hopp |
e32f63 |
allocated = leader; /* remember to free it later */
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
if (leader == NULL)
|
|
Karsten Hopp |
e32f63 |
--- 1055,1062 ----
|
|
Karsten Hopp |
e32f63 |
if (lead_len)
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
/* allocate buffer (may concatenate p_exta later) */
|
|
Karsten Hopp |
e32f63 |
! leader = alloc(lead_len + lead_repl_len + extra_space + extra_len
|
|
Karsten Hopp |
e32f63 |
! + (second_line_indent > 0 ? second_line_indent : 0));
|
|
Karsten Hopp |
e32f63 |
allocated = leader; /* remember to free it later */
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
if (leader == NULL)
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 1304,1309 ****
|
|
Karsten Hopp |
e32f63 |
--- 1351,1370 ----
|
|
Karsten Hopp |
e32f63 |
/* concatenate leader and p_extra, if there is a leader */
|
|
Karsten Hopp |
e32f63 |
if (lead_len)
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
+ if (flags & OPENLINE_COM_LIST && second_line_indent > 0)
|
|
Karsten Hopp |
e32f63 |
+ {
|
|
Karsten Hopp |
e32f63 |
+ int i;
|
|
Karsten Hopp |
e32f63 |
+ int padding = second_line_indent - (newindent + STRLEN(leader));
|
|
Karsten Hopp |
e32f63 |
+
|
|
Karsten Hopp |
e32f63 |
+ /* Here whitespace is inserted after the comment char.
|
|
Karsten Hopp |
e32f63 |
+ * Below, set_indent(newindent, SIN_INSERT) will insert the
|
|
Karsten Hopp |
e32f63 |
+ * whitespace needed before the comment char. */
|
|
Karsten Hopp |
e32f63 |
+ for (i = 0; i < padding; i++)
|
|
Karsten Hopp |
e32f63 |
+ {
|
|
Karsten Hopp |
e32f63 |
+ STRCAT(leader, " ");
|
|
Karsten Hopp |
e32f63 |
+ newcol++;
|
|
Karsten Hopp |
e32f63 |
+ }
|
|
Karsten Hopp |
e32f63 |
+ }
|
|
Karsten Hopp |
e32f63 |
STRCAT(leader, p_extra);
|
|
Karsten Hopp |
e32f63 |
p_extra = leader;
|
|
Karsten Hopp |
e32f63 |
did_ai = TRUE; /* So truncating blanks works with comments */
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 4966,4973 ****
|
|
Karsten Hopp |
e32f63 |
char_u *
|
|
Karsten Hopp |
e32f63 |
FullName_save(fname, force)
|
|
Karsten Hopp |
e32f63 |
char_u *fname;
|
|
Karsten Hopp |
e32f63 |
! int force; /* force expansion, even when it already looks
|
|
Karsten Hopp |
e32f63 |
! like a full path name */
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
char_u *buf;
|
|
Karsten Hopp |
e32f63 |
char_u *new_fname = NULL;
|
|
Karsten Hopp |
e32f63 |
--- 5027,5034 ----
|
|
Karsten Hopp |
e32f63 |
char_u *
|
|
Karsten Hopp |
e32f63 |
FullName_save(fname, force)
|
|
Karsten Hopp |
e32f63 |
char_u *fname;
|
|
Karsten Hopp |
e32f63 |
! int force; /* force expansion, even when it already looks
|
|
Karsten Hopp |
e32f63 |
! * like a full path name */
|
|
Karsten Hopp |
e32f63 |
{
|
|
Karsten Hopp |
e32f63 |
char_u *buf;
|
|
Karsten Hopp |
e32f63 |
char_u *new_fname = NULL;
|
|
Karsten Hopp |
e32f63 |
*** ../vim-7.3.551/src/testdir/test68.in 2010-10-09 17:21:42.000000000 +0200
|
|
Karsten Hopp |
e32f63 |
--- src/testdir/test68.in 2012-06-13 15:49:38.000000000 +0200
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 51,56 ****
|
|
Karsten Hopp |
e32f63 |
--- 51,77 ----
|
|
Karsten Hopp |
e32f63 |
}
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
STARTTEST
|
|
Karsten Hopp |
e32f63 |
+ /^{/+1
|
|
Karsten Hopp |
e32f63 |
+ :set tw=5 fo=qn comments=:#
|
|
Karsten Hopp |
e32f63 |
+ gwap
|
|
Karsten Hopp |
e32f63 |
+ ENDTEST
|
|
Karsten Hopp |
e32f63 |
+
|
|
Karsten Hopp |
e32f63 |
+ {
|
|
Karsten Hopp |
e32f63 |
+ # 1 a b
|
|
Karsten Hopp |
e32f63 |
+ }
|
|
Karsten Hopp |
e32f63 |
+
|
|
Karsten Hopp |
e32f63 |
+ STARTTEST
|
|
Karsten Hopp |
e32f63 |
+ /^{/+1
|
|
Karsten Hopp |
e32f63 |
+ :set tw=5 fo=q2 comments=:#
|
|
Karsten Hopp |
e32f63 |
+ gwap
|
|
Karsten Hopp |
e32f63 |
+ ENDTEST
|
|
Karsten Hopp |
e32f63 |
+
|
|
Karsten Hopp |
e32f63 |
+ {
|
|
Karsten Hopp |
e32f63 |
+ # x
|
|
Karsten Hopp |
e32f63 |
+ # a b
|
|
Karsten Hopp |
e32f63 |
+ }
|
|
Karsten Hopp |
e32f63 |
+
|
|
Karsten Hopp |
e32f63 |
+ STARTTEST
|
|
Karsten Hopp |
e32f63 |
/^{/+2
|
|
Karsten Hopp |
e32f63 |
:set tw& fo=a
|
|
Karsten Hopp |
e32f63 |
I^^?
|
|
Karsten Hopp |
e32f63 |
*** ../vim-7.3.551/src/testdir/test68.ok 2010-10-09 17:21:42.000000000 +0200
|
|
Karsten Hopp |
e32f63 |
--- src/testdir/test68.ok 2012-06-13 15:49:38.000000000 +0200
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 34,38 ****
|
|
Karsten Hopp |
e32f63 |
--- 34,50 ----
|
|
Karsten Hopp |
e32f63 |
}
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
+ {
|
|
Karsten Hopp |
e32f63 |
+ # 1 a
|
|
Karsten Hopp |
e32f63 |
+ # b
|
|
Karsten Hopp |
e32f63 |
+ }
|
|
Karsten Hopp |
e32f63 |
+
|
|
Karsten Hopp |
e32f63 |
+
|
|
Karsten Hopp |
e32f63 |
+ {
|
|
Karsten Hopp |
e32f63 |
+ # x a
|
|
Karsten Hopp |
e32f63 |
+ # b
|
|
Karsten Hopp |
e32f63 |
+ }
|
|
Karsten Hopp |
e32f63 |
+
|
|
Karsten Hopp |
e32f63 |
+
|
|
Karsten Hopp |
e32f63 |
{ 1aa ^^2bb }
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
*** ../vim-7.3.551/src/version.c 2012-06-13 14:28:16.000000000 +0200
|
|
Karsten Hopp |
e32f63 |
--- src/version.c 2012-06-13 16:36:14.000000000 +0200
|
|
Karsten Hopp |
e32f63 |
***************
|
|
Karsten Hopp |
e32f63 |
*** 716,717 ****
|
|
Karsten Hopp |
e32f63 |
--- 716,719 ----
|
|
Karsten Hopp |
e32f63 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
e32f63 |
+ /**/
|
|
Karsten Hopp |
e32f63 |
+ 552,
|
|
Karsten Hopp |
e32f63 |
/**/
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
--
|
|
Karsten Hopp |
e32f63 |
hundred-and-one symptoms of being an internet addict:
|
|
Karsten Hopp |
e32f63 |
31. You code your homework in HTML and give your instructor the URL.
|
|
Karsten Hopp |
e32f63 |
|
|
Karsten Hopp |
e32f63 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
e32f63 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
e32f63 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
e32f63 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|