|
Karsten Hopp |
d068b3 |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
d068b3 |
Subject: Patch 7.3.576
|
|
Karsten Hopp |
d068b3 |
Fcc: outbox
|
|
Karsten Hopp |
d068b3 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
d068b3 |
Mime-Version: 1.0
|
|
Karsten Hopp |
d068b3 |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
d068b3 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
d068b3 |
------------
|
|
Karsten Hopp |
d068b3 |
|
|
Karsten Hopp |
d068b3 |
Patch 7.3.576
|
|
Karsten Hopp |
d068b3 |
Problem: Formatting of lists inside comments is not right yet.
|
|
Karsten Hopp |
d068b3 |
Solution: Use another solution and add a test. (Tor Perkins)
|
|
Karsten Hopp |
d068b3 |
Files: src/edit.c, src/misc1.c, src/testdir/test68.in,
|
|
Karsten Hopp |
d068b3 |
src/testdir/test69.ok
|
|
Karsten Hopp |
d068b3 |
|
|
Karsten Hopp |
d068b3 |
|
|
Karsten Hopp |
d068b3 |
*** ../vim-7.3.575/src/edit.c 2012-06-20 22:55:56.000000000 +0200
|
|
Karsten Hopp |
d068b3 |
--- src/edit.c 2012-06-29 14:10:36.000000000 +0200
|
|
Karsten Hopp |
d068b3 |
***************
|
|
Karsten Hopp |
d068b3 |
*** 6320,6333 ****
|
|
Karsten Hopp |
d068b3 |
if (!(flags & INSCHAR_COM_LIST))
|
|
Karsten Hopp |
d068b3 |
{
|
|
Karsten Hopp |
d068b3 |
/*
|
|
Karsten Hopp |
d068b3 |
! * This section is for numeric lists w/o comments. If comment
|
|
Karsten Hopp |
d068b3 |
! * indents are needed with numeric lists (formatoptions=nq),
|
|
Karsten Hopp |
d068b3 |
! * then the INSCHAR_COM_LIST flag will cause the corresponding
|
|
Karsten Hopp |
d068b3 |
! * OPENLINE_COM_LIST flag to be passed through to open_line()
|
|
Karsten Hopp |
d068b3 |
! * (as seen above)...
|
|
Karsten Hopp |
d068b3 |
*/
|
|
Karsten Hopp |
d068b3 |
if (second_indent < 0 && has_format_option(FO_Q_NUMBER))
|
|
Karsten Hopp |
d068b3 |
! second_indent = get_number_indent(curwin->w_cursor.lnum -1);
|
|
Karsten Hopp |
d068b3 |
if (second_indent >= 0)
|
|
Karsten Hopp |
d068b3 |
{
|
|
Karsten Hopp |
d068b3 |
#ifdef FEAT_VREPLACE
|
|
Karsten Hopp |
d068b3 |
--- 6320,6334 ----
|
|
Karsten Hopp |
d068b3 |
if (!(flags & INSCHAR_COM_LIST))
|
|
Karsten Hopp |
d068b3 |
{
|
|
Karsten Hopp |
d068b3 |
/*
|
|
Karsten Hopp |
d068b3 |
! * This section is for auto-wrap of numeric lists. When not
|
|
Karsten Hopp |
d068b3 |
! * in insert mode (i.e. format_lines()), the INSCHAR_COM_LIST
|
|
Karsten Hopp |
d068b3 |
! * flag will be set and open_line() will handle it (as seen
|
|
Karsten Hopp |
d068b3 |
! * above). The code here (and in get_number_indent()) will
|
|
Karsten Hopp |
d068b3 |
! * recognize comments if needed...
|
|
Karsten Hopp |
d068b3 |
*/
|
|
Karsten Hopp |
d068b3 |
if (second_indent < 0 && has_format_option(FO_Q_NUMBER))
|
|
Karsten Hopp |
d068b3 |
! second_indent =
|
|
Karsten Hopp |
d068b3 |
! get_number_indent(curwin->w_cursor.lnum - 1);
|
|
Karsten Hopp |
d068b3 |
if (second_indent >= 0)
|
|
Karsten Hopp |
d068b3 |
{
|
|
Karsten Hopp |
d068b3 |
#ifdef FEAT_VREPLACE
|
|
Karsten Hopp |
d068b3 |
***************
|
|
Karsten Hopp |
d068b3 |
*** 6336,6342 ****
|
|
Karsten Hopp |
d068b3 |
--- 6337,6367 ----
|
|
Karsten Hopp |
d068b3 |
FALSE, NUL, TRUE);
|
|
Karsten Hopp |
d068b3 |
else
|
|
Karsten Hopp |
d068b3 |
#endif
|
|
Karsten Hopp |
d068b3 |
+ #ifdef FEAT_COMMENTS
|
|
Karsten Hopp |
d068b3 |
+ if (leader_len > 0 && second_indent - leader_len > 0)
|
|
Karsten Hopp |
d068b3 |
+ {
|
|
Karsten Hopp |
d068b3 |
+ int i;
|
|
Karsten Hopp |
d068b3 |
+ int padding = second_indent - leader_len;
|
|
Karsten Hopp |
d068b3 |
+
|
|
Karsten Hopp |
d068b3 |
+ /* We started at the first_line of a numbered list
|
|
Karsten Hopp |
d068b3 |
+ * that has a comment. the open_line() function has
|
|
Karsten Hopp |
d068b3 |
+ * inserted the proper comment leader and positioned
|
|
Karsten Hopp |
d068b3 |
+ * the cursor at the end of the split line. Now we
|
|
Karsten Hopp |
d068b3 |
+ * add the additional whitespace needed after the
|
|
Karsten Hopp |
d068b3 |
+ * comment leader for the numbered list. */
|
|
Karsten Hopp |
d068b3 |
+ for (i = 0; i < padding; i++)
|
|
Karsten Hopp |
d068b3 |
+ {
|
|
Karsten Hopp |
d068b3 |
+ ins_str((char_u *)" ");
|
|
Karsten Hopp |
d068b3 |
+ changed_bytes(curwin->w_cursor.lnum, leader_len);
|
|
Karsten Hopp |
d068b3 |
+ }
|
|
Karsten Hopp |
d068b3 |
+ }
|
|
Karsten Hopp |
d068b3 |
+ else
|
|
Karsten Hopp |
d068b3 |
+ {
|
|
Karsten Hopp |
d068b3 |
+ #endif
|
|
Karsten Hopp |
d068b3 |
(void)set_indent(second_indent, SIN_CHANGED);
|
|
Karsten Hopp |
d068b3 |
+ #ifdef FEAT_COMMENTS
|
|
Karsten Hopp |
d068b3 |
+ }
|
|
Karsten Hopp |
d068b3 |
+ #endif
|
|
Karsten Hopp |
d068b3 |
}
|
|
Karsten Hopp |
d068b3 |
}
|
|
Karsten Hopp |
d068b3 |
first_line = FALSE;
|
|
Karsten Hopp |
d068b3 |
*** ../vim-7.3.575/src/misc1.c 2012-06-20 17:56:06.000000000 +0200
|
|
Karsten Hopp |
d068b3 |
--- src/misc1.c 2012-06-29 14:10:12.000000000 +0200
|
|
Karsten Hopp |
d068b3 |
***************
|
|
Karsten Hopp |
d068b3 |
*** 424,491 ****
|
|
Karsten Hopp |
d068b3 |
colnr_T col;
|
|
Karsten Hopp |
d068b3 |
pos_T pos;
|
|
Karsten Hopp |
d068b3 |
|
|
Karsten Hopp |
d068b3 |
if (lnum > curbuf->b_ml.ml_line_count)
|
|
Karsten Hopp |
d068b3 |
return -1;
|
|
Karsten Hopp |
d068b3 |
pos.lnum = 0;
|
|
Karsten Hopp |
d068b3 |
|
|
Karsten Hopp |
d068b3 |
#ifdef FEAT_COMMENTS
|
|
Karsten Hopp |
d068b3 |
! if (has_format_option(FO_Q_COMS) && has_format_option(FO_Q_NUMBER))
|
|
Karsten Hopp |
d068b3 |
! {
|
|
Karsten Hopp |
d068b3 |
! regmatch_T regmatch;
|
|
Karsten Hopp |
d068b3 |
! int lead_len; /* length of comment leader */
|
|
Karsten Hopp |
d068b3 |
!
|
|
Karsten Hopp |
d068b3 |
lead_len = get_leader_len(ml_get(lnum), NULL, FALSE, TRUE);
|
|
Karsten Hopp |
d068b3 |
- regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC);
|
|
Karsten Hopp |
d068b3 |
- if (regmatch.regprog != NULL)
|
|
Karsten Hopp |
d068b3 |
- {
|
|
Karsten Hopp |
d068b3 |
- regmatch.rm_ic = FALSE;
|
|
Karsten Hopp |
d068b3 |
-
|
|
Karsten Hopp |
d068b3 |
- /* vim_regexec() expects a pointer to a line. This lets us
|
|
Karsten Hopp |
d068b3 |
- * start matching for the flp beyond any comment leader... */
|
|
Karsten Hopp |
d068b3 |
- if (vim_regexec(®match, ml_get(lnum) + lead_len, (colnr_T)0))
|
|
Karsten Hopp |
d068b3 |
- {
|
|
Karsten Hopp |
d068b3 |
- pos.lnum = lnum;
|
|
Karsten Hopp |
d068b3 |
- pos.col = (colnr_T)(*regmatch.endp - ml_get(lnum));
|
|
Karsten Hopp |
d068b3 |
- #ifdef FEAT_VIRTUALEDIT
|
|
Karsten Hopp |
d068b3 |
- pos.coladd = 0;
|
|
Karsten Hopp |
d068b3 |
#endif
|
|
Karsten Hopp |
d068b3 |
! }
|
|
Karsten Hopp |
d068b3 |
! }
|
|
Karsten Hopp |
d068b3 |
! vim_free(regmatch.regprog);
|
|
Karsten Hopp |
d068b3 |
! }
|
|
Karsten Hopp |
d068b3 |
! else
|
|
Karsten Hopp |
d068b3 |
{
|
|
Karsten Hopp |
d068b3 |
! /*
|
|
Karsten Hopp |
d068b3 |
! * What follows is the orig code that is not "comment aware"...
|
|
Karsten Hopp |
d068b3 |
! *
|
|
Karsten Hopp |
d068b3 |
! * I'm not sure if regmmatch_T (multi-match) is needed in this case.
|
|
Karsten Hopp |
d068b3 |
! * It may be true that this section would work properly using the
|
|
Karsten Hopp |
d068b3 |
! * regmatch_T code above, in which case, these two separate sections
|
|
Karsten Hopp |
d068b3 |
! * should be consolidated w/ FEAT_COMMENTS making lead_len > 0...
|
|
Karsten Hopp |
d068b3 |
! */
|
|
Karsten Hopp |
d068b3 |
! #endif
|
|
Karsten Hopp |
d068b3 |
! regmmatch_T regmatch;
|
|
Karsten Hopp |
d068b3 |
|
|
Karsten Hopp |
d068b3 |
! regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC);
|
|
Karsten Hopp |
d068b3 |
!
|
|
Karsten Hopp |
d068b3 |
! if (regmatch.regprog != NULL)
|
|
Karsten Hopp |
d068b3 |
{
|
|
Karsten Hopp |
d068b3 |
! regmatch.rmm_ic = FALSE;
|
|
Karsten Hopp |
d068b3 |
! regmatch.rmm_maxcol = 0;
|
|
Karsten Hopp |
d068b3 |
! if (vim_regexec_multi(®match, curwin, curbuf,
|
|
Karsten Hopp |
d068b3 |
! lnum, (colnr_T)0, NULL))
|
|
Karsten Hopp |
d068b3 |
! {
|
|
Karsten Hopp |
d068b3 |
! pos.lnum = regmatch.endpos[0].lnum + lnum;
|
|
Karsten Hopp |
d068b3 |
! pos.col = regmatch.endpos[0].col;
|
|
Karsten Hopp |
d068b3 |
#ifdef FEAT_VIRTUALEDIT
|
|
Karsten Hopp |
d068b3 |
! pos.coladd = 0;
|
|
Karsten Hopp |
d068b3 |
#endif
|
|
Karsten Hopp |
d068b3 |
- }
|
|
Karsten Hopp |
d068b3 |
- vim_free(regmatch.regprog);
|
|
Karsten Hopp |
d068b3 |
}
|
|
Karsten Hopp |
d068b3 |
- #ifdef FEAT_COMMENTS
|
|
Karsten Hopp |
d068b3 |
}
|
|
Karsten Hopp |
d068b3 |
! #endif
|
|
Karsten Hopp |
d068b3 |
|
|
Karsten Hopp |
d068b3 |
if (pos.lnum == 0 || *ml_get_pos(&pos) == NUL)
|
|
Karsten Hopp |
d068b3 |
return -1;
|
|
Karsten Hopp |
d068b3 |
--- 424,458 ----
|
|
Karsten Hopp |
d068b3 |
colnr_T col;
|
|
Karsten Hopp |
d068b3 |
pos_T pos;
|
|
Karsten Hopp |
d068b3 |
|
|
Karsten Hopp |
d068b3 |
+ regmatch_T regmatch;
|
|
Karsten Hopp |
d068b3 |
+ int lead_len = 0; /* length of comment leader */
|
|
Karsten Hopp |
d068b3 |
+
|
|
Karsten Hopp |
d068b3 |
if (lnum > curbuf->b_ml.ml_line_count)
|
|
Karsten Hopp |
d068b3 |
return -1;
|
|
Karsten Hopp |
d068b3 |
pos.lnum = 0;
|
|
Karsten Hopp |
d068b3 |
|
|
Karsten Hopp |
d068b3 |
#ifdef FEAT_COMMENTS
|
|
Karsten Hopp |
d068b3 |
! /* In format_lines() (i.e. not insert mode), fo+=q is needed too... */
|
|
Karsten Hopp |
d068b3 |
! if ((State & INSERT) || has_format_option(FO_Q_COMS))
|
|
Karsten Hopp |
d068b3 |
lead_len = get_leader_len(ml_get(lnum), NULL, FALSE, TRUE);
|
|
Karsten Hopp |
d068b3 |
#endif
|
|
Karsten Hopp |
d068b3 |
! regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC);
|
|
Karsten Hopp |
d068b3 |
! if (regmatch.regprog != NULL)
|
|
Karsten Hopp |
d068b3 |
{
|
|
Karsten Hopp |
d068b3 |
! regmatch.rm_ic = FALSE;
|
|
Karsten Hopp |
d068b3 |
|
|
Karsten Hopp |
d068b3 |
! /* vim_regexec() expects a pointer to a line. This lets us
|
|
Karsten Hopp |
d068b3 |
! * start matching for the flp beyond any comment leader... */
|
|
Karsten Hopp |
d068b3 |
! if (vim_regexec(®match, ml_get(lnum) + lead_len, (colnr_T)0))
|
|
Karsten Hopp |
d068b3 |
{
|
|
Karsten Hopp |
d068b3 |
! pos.lnum = lnum;
|
|
Karsten Hopp |
d068b3 |
! pos.col = (colnr_T)(*regmatch.endp - ml_get(lnum));
|
|
Karsten Hopp |
d068b3 |
#ifdef FEAT_VIRTUALEDIT
|
|
Karsten Hopp |
d068b3 |
! pos.coladd = 0;
|
|
Karsten Hopp |
d068b3 |
#endif
|
|
Karsten Hopp |
d068b3 |
}
|
|
Karsten Hopp |
d068b3 |
}
|
|
Karsten Hopp |
d068b3 |
! vim_free(regmatch.regprog);
|
|
Karsten Hopp |
d068b3 |
|
|
Karsten Hopp |
d068b3 |
if (pos.lnum == 0 || *ml_get_pos(&pos) == NUL)
|
|
Karsten Hopp |
d068b3 |
return -1;
|
|
Karsten Hopp |
d068b3 |
*** ../vim-7.3.575/src/testdir/test68.in 2012-06-13 17:28:51.000000000 +0200
|
|
Karsten Hopp |
d068b3 |
--- src/testdir/test68.in 2012-06-29 14:27:27.000000000 +0200
|
|
Karsten Hopp |
d068b3 |
***************
|
|
Karsten Hopp |
d068b3 |
*** 52,57 ****
|
|
Karsten Hopp |
d068b3 |
--- 52,68 ----
|
|
Karsten Hopp |
d068b3 |
|
|
Karsten Hopp |
d068b3 |
STARTTEST
|
|
Karsten Hopp |
d068b3 |
/^{/+1
|
|
Karsten Hopp |
d068b3 |
+ :set tw=5 fo=tcn comments=:#
|
|
Karsten Hopp |
d068b3 |
+ A b?jA b?
|
|
Karsten Hopp |
d068b3 |
+ ENDTEST
|
|
Karsten Hopp |
d068b3 |
+
|
|
Karsten Hopp |
d068b3 |
+ {
|
|
Karsten Hopp |
d068b3 |
+ 1 a
|
|
Karsten Hopp |
d068b3 |
+ # 1 a
|
|
Karsten Hopp |
d068b3 |
+ }
|
|
Karsten Hopp |
d068b3 |
+
|
|
Karsten Hopp |
d068b3 |
+ STARTTEST
|
|
Karsten Hopp |
d068b3 |
+ /^{/+1
|
|
Karsten Hopp |
d068b3 |
:set tw=5 fo=qn comments=:#
|
|
Karsten Hopp |
d068b3 |
gwap
|
|
Karsten Hopp |
d068b3 |
ENDTEST
|
|
Karsten Hopp |
d068b3 |
***************
|
|
Karsten Hopp |
d068b3 |
*** 83,88 ****
|
|
Karsten Hopp |
d068b3 |
--- 94,107 ----
|
|
Karsten Hopp |
d068b3 |
}
|
|
Karsten Hopp |
d068b3 |
|
|
Karsten Hopp |
d068b3 |
STARTTEST
|
|
Karsten Hopp |
d068b3 |
+ /^#/
|
|
Karsten Hopp |
d068b3 |
+ :setl tw=12 fo=tqnc comments=:#
|
|
Karsten Hopp |
d068b3 |
+ A foobar?
|
|
Karsten Hopp |
d068b3 |
+ ENDTEST
|
|
Karsten Hopp |
d068b3 |
+
|
|
Karsten Hopp |
d068b3 |
+ # 1 xxxxx
|
|
Karsten Hopp |
d068b3 |
+
|
|
Karsten Hopp |
d068b3 |
+ STARTTEST
|
|
Karsten Hopp |
d068b3 |
:g/^STARTTEST/.,/^ENDTEST/d
|
|
Karsten Hopp |
d068b3 |
:1;/^Results/,$wq! test.out
|
|
Karsten Hopp |
d068b3 |
ENDTEST
|
|
Karsten Hopp |
d068b3 |
*** ../vim-7.3.575/src/version.c 2012-06-29 13:56:01.000000000 +0200
|
|
Karsten Hopp |
d068b3 |
--- src/version.c 2012-06-29 15:03:10.000000000 +0200
|
|
Karsten Hopp |
d068b3 |
***************
|
|
Karsten Hopp |
d068b3 |
*** 716,717 ****
|
|
Karsten Hopp |
d068b3 |
--- 716,719 ----
|
|
Karsten Hopp |
d068b3 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
d068b3 |
+ /**/
|
|
Karsten Hopp |
d068b3 |
+ 576,
|
|
Karsten Hopp |
d068b3 |
/**/
|
|
Karsten Hopp |
d068b3 |
|
|
Karsten Hopp |
d068b3 |
--
|
|
Karsten Hopp |
d068b3 |
Proof techniques #2: Proof by Oddity.
|
|
Karsten Hopp |
d068b3 |
SAMPLE: To prove that horses have an infinite number of legs.
|
|
Karsten Hopp |
d068b3 |
(1) Horses have an even number of legs.
|
|
Karsten Hopp |
d068b3 |
(2) They have two legs in back and fore legs in front.
|
|
Karsten Hopp |
d068b3 |
(3) This makes a total of six legs, which certainly is an odd number of
|
|
Karsten Hopp |
d068b3 |
legs for a horse.
|
|
Karsten Hopp |
d068b3 |
(4) But the only number that is both odd and even is infinity.
|
|
Karsten Hopp |
d068b3 |
(5) Therefore, horses must have an infinite number of legs.
|
|
Karsten Hopp |
d068b3 |
|
|
Karsten Hopp |
d068b3 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
d068b3 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
d068b3 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
d068b3 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|