home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.0.143 < prev    next >
Encoding:
Internet Message Format  |  2002-01-16  |  10.0 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.0.143
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.0.143
  11. Problem:    When a syntax item includes a line break in a pattern, the syntax
  12.         may not be updated properly when making a change.
  13. Solution:   Add the "linebreaks" argument to ":syn sync".
  14. Files:        runtime/doc/syntax.txt, src/screen.c, src/structs.h, src/syntax.c
  15.  
  16.  
  17. *** ../vim60.142/runtime/doc/syntax.txt    Tue Sep 25 21:40:39 2001
  18. --- runtime/doc/syntax.txt    Thu Jan 17 15:21:41 2002
  19. ***************
  20. *** 1895,1901 ****
  21.                   need to make sure syncing takes care of this.
  22.   
  23.       Example (match a character constant): >
  24. !   :syntax match Character /'.'/s+1e-1
  25.   <
  26.   
  27.   DEFINING REGIONS    *:syn-region* *:syn-start* *:syn-skip* *:syn-end*
  28. --- 1962,1968 ----
  29.                   need to make sure syncing takes care of this.
  30.   
  31.       Example (match a character constant): >
  32. !   :syntax match Character /'.'/hs=s+1,he=e-1
  33.   <
  34.   
  35.   DEFINING REGIONS    *:syn-region* *:syn-start* *:syn-skip* *:syn-end*
  36. ***************
  37. *** 2594,2603 ****
  38.         include".
  39.   
  40.   ==============================================================================
  41. ! 10. Synchronizing                    *:syn-sync* *E403* *E404*
  42.   
  43.   Vim wants to be able to start redrawing in any position in the document.  To
  44. ! make this possible it needs to know the syntax item at the position where
  45.   redrawing starts.
  46.   
  47.   :sy[ntax] sync [ccomment [group-name] | minlines={N} | ...]
  48. --- 2661,2670 ----
  49.         include".
  50.   
  51.   ==============================================================================
  52. ! 10. Synchronizing                *:syn-sync* *E403* *E404*
  53.   
  54.   Vim wants to be able to start redrawing in any position in the document.  To
  55. ! make this possible it needs to know the syntax state at the position where
  56.   redrawing starts.
  57.   
  58.   :sy[ntax] sync [ccomment [group-name] | minlines={N} | ...]
  59. ***************
  60. *** 2626,2631 ****
  61. --- 2693,2709 ----
  62.   adding "minlines".  This is useful if you have few things to sync on and a
  63.   slow machine.  Example: >
  64.      :syntax sync ccomment maxlines=500
  65. + <
  66. +                         *:syn-sync-linebreaks*
  67. + When using a pattern that matches multiple lines, a change in one line may
  68. + cause a pattern to no longer match in a previous line.  This means has to
  69. + start above where the change was made.  How many lines can be specified with
  70. + the "linebreaks" argument.  For example, when a pattern may include one line
  71. + break use this: >
  72. +    :syntax sync linebreaks=1
  73. + The result is that redrawing always starts at least one line before where a
  74. + change was made.  The default value for "linebreaks" is zero.  Usually the
  75. + value for "minlines" is bigger than "linebreaks".
  76.   
  77.   
  78.   First syncing method:            *:syn-sync-first*
  79. *** ../vim60.142/src/screen.c    Wed Jan 16 12:28:44 2002
  80. --- src/screen.c    Thu Jan 17 15:23:49 2002
  81. ***************
  82. *** 823,829 ****
  83. --- 823,837 ----
  84.       if (buf->b_mod_set)
  85.       {
  86.           if (mod_top == 0 || mod_top > buf->b_mod_top)
  87. +         {
  88.           mod_top = buf->b_mod_top;
  89. + #ifdef FEAT_SYN_HL
  90. +         /* Need to redraw lines above the change that may be included
  91. +          * in a pattern match. */
  92. +         if (syntax_present(buf))
  93. +             mod_top -= buf->b_syn_sync_linebreaks;
  94. + #endif
  95. +         }
  96.           if (mod_bot == 0 || mod_bot < buf->b_mod_bot)
  97.           mod_bot = buf->b_mod_bot;
  98.   
  99. *** ../vim60.142/src/structs.h    Tue Jan 15 14:34:37 2002
  100. --- src/structs.h    Thu Jan 17 15:22:02 2002
  101. ***************
  102. *** 1049,1054 ****
  103. --- 1049,1055 ----
  104.       short    b_syn_sync_id;        /* group to sync on */
  105.       long    b_syn_sync_minlines;    /* minimal sync lines offset */
  106.       long    b_syn_sync_maxlines;    /* maximal sync lines offset */
  107. +     long    b_syn_sync_linebreaks;    /* offset for multi-line pattern */
  108.       char_u    *b_syn_linecont_pat;    /* line continuation pattern */
  109.       regprog_T    *b_syn_linecont_prog;    /* line continuation program */
  110.       int        b_syn_linecont_ic;    /* ignore-case flag for above */
  111. *** ../vim60.142/src/syntax.c    Thu Nov  1 12:22:41 2001
  112. --- src/syntax.c    Thu Jan 17 15:23:39 2002
  113. ***************
  114. *** 383,388 ****
  115. --- 383,389 ----
  116.   static void syn_cmd_onoff __ARGS((exarg_T *eap, char *name));
  117.   static void syn_cmd_list __ARGS((exarg_T *eap, int syncing));
  118.   static void syn_lines_msg __ARGS((void));
  119. + static void syn_match_msg __ARGS((void));
  120.   static void syn_list_one __ARGS((int id, int syncing, int link_only));
  121.   static void syn_list_cluster __ARGS((int id));
  122.   static void put_id_list __ARGS((char_u *name, short *list, int attr));
  123. ***************
  124. *** 1149,1155 ****
  125.       prev = NULL;
  126.       for (p = buf->b_sst_first; p != NULL; )
  127.       {
  128. !     if (p->sst_lnum > buf->b_mod_top)
  129.       {
  130.           n = p->sst_lnum + buf->b_mod_xlines;
  131.           if (n <= buf->b_mod_bot)
  132. --- 1150,1156 ----
  133.       prev = NULL;
  134.       for (p = buf->b_sst_first; p != NULL; )
  135.       {
  136. !     if (p->sst_lnum + syn_buf->b_syn_sync_linebreaks > buf->b_mod_top)
  137.       {
  138.           n = p->sst_lnum + buf->b_mod_xlines;
  139.           if (n <= buf->b_mod_bot)
  140. ***************
  141. *** 3029,3034 ****
  142. --- 3030,3036 ----
  143.       buf->b_syn_sync_flags = 0;
  144.       buf->b_syn_sync_minlines = 0;
  145.       buf->b_syn_sync_maxlines = 0;
  146. +     buf->b_syn_sync_linebreaks = 0;
  147.   
  148.       vim_free(buf->b_syn_linecont_prog);
  149.       buf->b_syn_linecont_prog = NULL;
  150. ***************
  151. *** 3059,3064 ****
  152. --- 3061,3067 ----
  153.       curbuf->b_syn_sync_flags = 0;
  154.       curbuf->b_syn_sync_minlines = 0;
  155.       curbuf->b_syn_sync_maxlines = 0;
  156. +     curbuf->b_syn_sync_linebreaks = 0;
  157.   
  158.       vim_free(curbuf->b_syn_linecont_prog);
  159.       curbuf->b_syn_linecont_prog = NULL;
  160. ***************
  161. *** 3346,3353 ****
  162.       if (curbuf->b_syn_sync_flags & SF_CCOMMENT)
  163.       {
  164.           MSG_PUTS(_("syncing on C-style comments"));
  165. !         if (curbuf->b_syn_sync_minlines || curbuf->b_syn_sync_maxlines)
  166. !         syn_lines_msg();
  167.           return;
  168.       }
  169.       else if (!(curbuf->b_syn_sync_flags & SF_MATCH))
  170. --- 3349,3356 ----
  171.       if (curbuf->b_syn_sync_flags & SF_CCOMMENT)
  172.       {
  173.           MSG_PUTS(_("syncing on C-style comments"));
  174. !         syn_lines_msg();
  175. !         syn_match_msg();
  176.           return;
  177.       }
  178.       else if (!(curbuf->b_syn_sync_flags & SF_MATCH))
  179. ***************
  180. *** 3359,3372 ****
  181.           MSG_PUTS(_("syncing starts "));
  182.           msg_outnum(curbuf->b_syn_sync_minlines);
  183.           MSG_PUTS(_(" lines before top line"));
  184.           }
  185.           return;
  186.       }
  187.       MSG_PUTS_TITLE(_("\n--- Syntax sync items ---"));
  188. !     if (curbuf->b_syn_sync_minlines || curbuf->b_syn_sync_maxlines)
  189.       {
  190.           MSG_PUTS(_("\nsyncing on items"));
  191.           syn_lines_msg();
  192.       }
  193.       }
  194.       else
  195. --- 3362,3379 ----
  196.           MSG_PUTS(_("syncing starts "));
  197.           msg_outnum(curbuf->b_syn_sync_minlines);
  198.           MSG_PUTS(_(" lines before top line"));
  199. +         syn_match_msg();
  200.           }
  201.           return;
  202.       }
  203.       MSG_PUTS_TITLE(_("\n--- Syntax sync items ---"));
  204. !     if (curbuf->b_syn_sync_minlines > 0
  205. !         || curbuf->b_syn_sync_maxlines > 0
  206. !         || curbuf->b_syn_sync_linebreaks > 0)
  207.       {
  208.           MSG_PUTS(_("\nsyncing on items"));
  209.           syn_lines_msg();
  210. +         syn_match_msg();
  211.       }
  212.       }
  213.       else
  214. ***************
  215. *** 3414,3433 ****
  216.       static void
  217.   syn_lines_msg()
  218.   {
  219. !     MSG_PUTS("; ");
  220. !     if (curbuf->b_syn_sync_minlines)
  221.       {
  222. !     MSG_PUTS(_("minimal "));
  223. !     msg_outnum(curbuf->b_syn_sync_minlines);
  224. !     if (curbuf->b_syn_sync_maxlines)
  225. !         MSG_PUTS(", ");
  226.       }
  227. !     if (curbuf->b_syn_sync_maxlines)
  228.       {
  229. !     MSG_PUTS(_("maximal "));
  230. !     msg_outnum(curbuf->b_syn_sync_maxlines);
  231.       }
  232. -     MSG_PUTS(_(" lines before top line"));
  233.   }
  234.   
  235.   static int  last_matchgroup;
  236. --- 3421,3454 ----
  237.       static void
  238.   syn_lines_msg()
  239.   {
  240. !     if (curbuf->b_syn_sync_maxlines > 0 || curbuf->b_syn_sync_minlines > 0)
  241.       {
  242. !     MSG_PUTS("; ");
  243. !     if (curbuf->b_syn_sync_minlines > 0)
  244. !     {
  245. !         MSG_PUTS(_("minimal "));
  246. !         msg_outnum(curbuf->b_syn_sync_minlines);
  247. !         if (curbuf->b_syn_sync_maxlines)
  248. !         MSG_PUTS(", ");
  249. !     }
  250. !     if (curbuf->b_syn_sync_maxlines > 0)
  251. !     {
  252. !         MSG_PUTS(_("maximal "));
  253. !         msg_outnum(curbuf->b_syn_sync_maxlines);
  254. !     }
  255. !     MSG_PUTS(_(" lines before top line"));
  256.       }
  257. ! }
  258. !     static void
  259. ! syn_match_msg()
  260. ! {
  261. !     if (curbuf->b_syn_sync_linebreaks > 0)
  262.       {
  263. !     MSG_PUTS(_("; match "));
  264. !     msg_outnum(curbuf->b_syn_sync_linebreaks);
  265. !     MSG_PUTS(_(" line breaks"));
  266.       }
  267.   }
  268.   
  269.   static int  last_matchgroup;
  270. ***************
  271. *** 5187,5196 ****
  272.       }
  273.       else if (  STRNCMP(key, "LINES", 5) == 0
  274.           || STRNCMP(key, "MINLINES", 8) == 0
  275. !         || STRNCMP(key, "MAXLINES", 8) == 0)
  276.       {
  277. !         if (key[0] == 'L')
  278.           arg_end = key + 6;
  279.           else
  280.           arg_end = key + 9;
  281.           if (arg_end[-1] != '=' || !isdigit(*arg_end))
  282. --- 5208,5220 ----
  283.       }
  284.       else if (  STRNCMP(key, "LINES", 5) == 0
  285.           || STRNCMP(key, "MINLINES", 8) == 0
  286. !         || STRNCMP(key, "MAXLINES", 8) == 0
  287. !         || STRNCMP(key, "LINEBREAKS", 10) == 0)
  288.       {
  289. !         if (key[4] == 'S')
  290.           arg_end = key + 6;
  291. +         else if (key[0] == 'L')
  292. +         arg_end = key + 11;
  293.           else
  294.           arg_end = key + 9;
  295.           if (arg_end[-1] != '=' || !isdigit(*arg_end))
  296. ***************
  297. *** 5201,5207 ****
  298.           n = getdigits(&arg_end);
  299.           if (!eap->skip)
  300.           {
  301. !         if (key[1] == 'A')
  302.               curbuf->b_syn_sync_maxlines = n;
  303.           else
  304.               curbuf->b_syn_sync_minlines = n;
  305. --- 5225,5233 ----
  306.           n = getdigits(&arg_end);
  307.           if (!eap->skip)
  308.           {
  309. !         if (key[4] == 'B')
  310. !             curbuf->b_syn_sync_linebreaks = n;
  311. !         else if (key[1] == 'A')
  312.               curbuf->b_syn_sync_maxlines = n;
  313.           else
  314.               curbuf->b_syn_sync_minlines = n;
  315. *** ../vim60.142/src/version.c    Thu Jan 17 12:12:55 2002
  316. --- src/version.c    Thu Jan 17 15:29:23 2002
  317. ***************
  318. *** 608,609 ****
  319. --- 608,611 ----
  320.   {   /* Add new patch number below this line */
  321. + /**/
  322. +     143,
  323.   /**/
  324.  
  325. -- 
  326. Q: What is the difference betwee open-source and commercial software?
  327. A: If you have a problem with commercial software you can call a phone
  328.    number and they will tell you it might be solved in a future version.
  329.    For open-source sofware there isn't a phone number to call, but you
  330.    get the solution within a day.
  331.  
  332.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  333. (((   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   )))
  334.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  335.