Hi Bram,

On Wed, Jun 15, 2016 at 1:41 PM, Bram Moolenaar <[email protected]> wrote:
>
> Yegappan Lakshmanan wrote:
>
>> The attached patch makes the following changes to
>> the quickfix tests:
>>
>> 1. Extends several test cases which currently tests only
>>     quickfix list to also test location lists.
>> 2. Uses command aliases for quickfix/location list commands,
>>     instead of using "exe" to convert the command names.
>
> Thanks!
>
> I have been thinking of making :caddexpr work better by keeping state
> between invocations.  What needs to be done (at least):
>
> - Move 'efm' parsing to a separate function.  If 'efm' is the same as last
>   time re-use the fmt_first list.
>
> - Do not clear "dir_stack", "directory" and "file_stack", "currfile" when
>   using ":caddexpr".
>   Move multiline, multiignore, multiscan outside of the function.
>
> Perhaps more?
>
> We could perhaps use one of the existing tests for directory entry/exit
> and instead of doing all lines at once feed one line at a time to
> :caddexpr.
>

I am attaching a patch that implements all of the above changes.
All the tests are passing. Need to review the diff and see whether
any more changes are needed.

BTW, I observed only a slight improvement in a simple caddexpr
test with a large number of entries.

Need to run additional tests to make sure this doesn't introduce
any regressions.

- Yegappan

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/quickfix.c b/src/quickfix.c
index b72f7d1..8aff363 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -205,6 +205,278 @@ qf_grow_linebuf(char_u **growbuf, int *growbufsiz, int 
newsz, int *allocsz)
     return *growbuf;
 }
 
+static struct fmtpattern
+{
+    char_u     convchar;
+    char       *pattern;
+} fmt_pat[FMT_PATTERNS] =
+               {
+                   {'f', ".\\+"},          /* only used when at end */
+                   {'n', "\\d\\+"},
+                   {'l', "\\d\\+"},
+                   {'c', "\\d\\+"},
+                   {'t', "."},
+                   {'m', ".\\+"},
+                   {'r', ".*"},
+                   {'p', "[-   .]*"},
+                   {'v', "\\d\\+"},
+                   {'s', ".\\+"}
+               };
+
+/*
+ * Converts a 'errorformat' string to regular expression pattern
+ */
+    static int
+efm_to_regpat(
+    char_u     *efm,
+    int                len,
+    efm_T      *fmt_ptr,
+    char_u     *fmtstr,
+    char_u     *errmsg)
+{
+    char_u             *ptr;
+    int                        round;
+    char_u             *efmp;
+    int                        idx = 0;
+    char_u             *srcptr;
+
+    /*
+     * Build regexp pattern from current 'errorformat' option
+     */
+    ptr = fmtstr;
+    *ptr++ = '^';
+    round = 0;
+    for (efmp = efm; efmp < efm + len; ++efmp)
+    {
+       if (*efmp == '%')
+       {
+           ++efmp;
+           for (idx = 0; idx < FMT_PATTERNS; ++idx)
+               if (fmt_pat[idx].convchar == *efmp)
+                   break;
+           if (idx < FMT_PATTERNS)
+           {
+               if (fmt_ptr->addr[idx])
+               {
+                   sprintf((char *)errmsg,
+                           _("E372: Too many %%%c in format string"), *efmp);
+                   EMSG(errmsg);
+                   return -1;
+               }
+               if ((idx
+                           && idx < 6
+                           && vim_strchr((char_u *)"DXOPQ",
+                               fmt_ptr->prefix) != NULL)
+                       || (idx == 6
+                           && vim_strchr((char_u *)"OPQ",
+                               fmt_ptr->prefix) == NULL))
+               {
+                   sprintf((char *)errmsg,
+                           _("E373: Unexpected %%%c in format string"), *efmp);
+                   EMSG(errmsg);
+                   return -1;
+               }
+               fmt_ptr->addr[idx] = (char_u)++round;
+               *ptr++ = '\\';
+               *ptr++ = '(';
+#ifdef BACKSLASH_IN_FILENAME
+               if (*efmp == 'f')
+               {
+                   /* Also match "c:" in the file name, even when
+                    * checking for a colon next: "%f:".
+                    * "\%(\a:\)\=" */
+                   STRCPY(ptr, "\\%(\\a:\\)\\=");
+                   ptr += 10;
+               }
+#endif
+               if (*efmp == 'f' && efmp[1] != NUL)
+               {
+                   if (efmp[1] != '\\' && efmp[1] != '%')
+                   {
+                       /* A file name may contain spaces, but this isn't
+                        * in "\f".  For "%f:%l:%m" there may be a ":" in
+                        * the file name.  Use ".\{-1,}x" instead (x is
+                        * the next character), the requirement that :999:
+                        * follows should work. */
+                       STRCPY(ptr, ".\\{-1,}");
+                       ptr += 7;
+                   }
+                   else
+                   {
+                       /* File name followed by '\\' or '%': include as
+                        * many file name chars as possible. */
+                       STRCPY(ptr, "\\f\\+");
+                       ptr += 4;
+                   }
+               }
+               else
+               {
+                   srcptr = (char_u *)fmt_pat[idx].pattern;
+                   while ((*ptr = *srcptr++) != NUL)
+                       ++ptr;
+               }
+               *ptr++ = '\\';
+               *ptr++ = ')';
+           }
+           else if (*efmp == '*')
+           {
+               if (*++efmp == '[' || *efmp == '\\')
+               {
+                   if ((*ptr++ = *efmp) == '[')        /* %*[^a-z0-9] etc. */
+                   {
+                       if (efmp[1] == '^')
+                           *ptr++ = *++efmp;
+                       if (efmp < efm + len)
+                       {
+                           *ptr++ = *++efmp;       /* could be ']' */
+                           while (efmp < efm + len
+                                   && (*ptr++ = *++efmp) != ']')
+                               /* skip */;
+                           if (efmp == efm + len)
+                           {
+                               EMSG(_("E374: Missing ] in format string"));
+                               return -1;
+                           }
+                       }
+                   }
+                   else if (efmp < efm + len)  /* %*\D, %*\s etc. */
+                       *ptr++ = *++efmp;
+                   *ptr++ = '\\';
+                   *ptr++ = '+';
+               }
+               else
+               {
+                   /* TODO: scanf()-like: %*ud, %*3c, %*f, ... ? */
+                   sprintf((char *)errmsg,
+                           _("E375: Unsupported %%%c in format string"), 
*efmp);
+                   EMSG(errmsg);
+                   return -1;
+               }
+           }
+           else if (vim_strchr((char_u *)"%\\.^$~[", *efmp) != NULL)
+               *ptr++ = *efmp;         /* regexp magic characters */
+           else if (*efmp == '#')
+               *ptr++ = '*';
+           else if (*efmp == '>')
+               fmt_ptr->conthere = TRUE;
+           else if (efmp == efm + 1)           /* analyse prefix */
+           {
+               if (vim_strchr((char_u *)"+-", *efmp) != NULL)
+                   fmt_ptr->flags = *efmp++;
+               if (vim_strchr((char_u *)"DXAEWICZGOPQ", *efmp) != NULL)
+                   fmt_ptr->prefix = *efmp;
+               else
+               {
+                   sprintf((char *)errmsg,
+                           _("E376: Invalid %%%c in format string prefix"), 
*efmp);
+                   EMSG(errmsg);
+                   return -1;
+               }
+           }
+           else
+           {
+               sprintf((char *)errmsg,
+                       _("E377: Invalid %%%c in format string"), *efmp);
+               EMSG(errmsg);
+               return -1;
+           }
+       }
+       else                    /* copy normal character */
+       {
+           if (*efmp == '\\' && efmp + 1 < efm + len)
+               ++efmp;
+           else if (vim_strchr((char_u *)".*^$~[", *efmp) != NULL)
+               *ptr++ = '\\';  /* escape regexp atoms */
+           if (*efmp)
+               *ptr++ = *efmp;
+       }
+    }
+    *ptr++ = '$';
+    *ptr = NUL;
+
+    return 0;
+}
+
+/* Parse 'errorformat' option */
+    static efm_T *
+parse_efm_option(char_u *efm)
+{
+    char_u     *errmsg;
+    int                errmsglen;
+    efm_T      *fmt_ptr;
+    efm_T      *fmt_first = NULL;
+    efm_T      *fmt_last = NULL;
+    char_u     *fmtstr = NULL;
+    int                len;
+    int                i;
+    int                round;
+
+    errmsglen = CMDBUFFSIZE + 1;
+    errmsg = alloc_id(errmsglen, aid_qf_errmsg);
+    if (errmsg == NULL)
+       goto parse_efm_end;
+
+    /*
+     * Get some space to modify the format string into.
+     */
+    i = (FMT_PATTERNS * 3) + ((int)STRLEN(efm) << 2);
+    for (round = FMT_PATTERNS; round > 0; )
+       i += (int)STRLEN(fmt_pat[--round].pattern);
+#ifdef COLON_IN_FILENAME
+    i += 12; /* "%f" can become twelve chars longer */
+#else
+    i += 2; /* "%f" can become two chars longer */
+#endif
+    if ((fmtstr = alloc(i)) == NULL)
+       goto parse_efm_error;
+
+    while (efm[0] != NUL)
+    {
+       /*
+        * Allocate a new eformat structure and put it at the end of the list
+        */
+       fmt_ptr = (efm_T *)alloc_clear((unsigned)sizeof(efm_T));
+       if (fmt_ptr == NULL)
+           goto parse_efm_error;
+       if (fmt_first == NULL)      /* first one */
+           fmt_first = fmt_ptr;
+       else
+           fmt_last->next = fmt_ptr;
+       fmt_last = fmt_ptr;
+
+       /*
+        * Isolate one part in the 'errorformat' option
+        */
+       for (len = 0; efm[len] != NUL && efm[len] != ','; ++len)
+           if (efm[len] == '\\' && efm[len + 1] != NUL)
+               ++len;
+
+       if (efm_to_regpat(efm, len, fmt_ptr, fmtstr, errmsg) == -1)
+           goto parse_efm_error;
+       if ((fmt_ptr->prog = vim_regcomp(fmtstr, RE_MAGIC + RE_STRING)) == NULL)
+           goto parse_efm_error;
+       /*
+        * Advance to next part
+        */
+       efm = skip_to_option_part(efm + len);   /* skip comma and spaces */
+    }
+
+    goto parse_efm_end;
+
+parse_efm_error:
+    for (fmt_ptr = fmt_first; fmt_ptr != NULL; fmt_ptr = fmt_first)
+    {
+       fmt_first = fmt_ptr->next;
+       vim_regfree(fmt_ptr->prog);
+       vim_free(fmt_ptr);
+    }
+parse_efm_end:
+    vim_free(fmtstr);
+    vim_free(errmsg);
+
+    return fmt_first;
+}
+
 /*
  * Read the errorfile "efile" into memory, line by line, building the error
  * list.
@@ -231,7 +503,6 @@ qf_init_ext(
     char_u         *errmsg;
     int                    errmsglen;
     char_u         *pattern;
-    char_u         *fmtstr = NULL;
     char_u         *growbuf = NULL;
     int                    growbuflen;
     int                    growbufsiz = 0;
@@ -249,47 +520,27 @@ qf_init_ext(
 #ifdef FEAT_WINDOWS
     qfline_T       *old_last = NULL;
 #endif
-    char_u         *efmp;
-    efm_T          *fmt_first = NULL;
-    efm_T          *fmt_last = NULL;
+    static efm_T    *fmt_first = NULL;
     efm_T          *fmt_ptr;
     efm_T          *fmt_start = NULL;
     char_u         *efm;
+    static char_u   *last_efm = NULL;
     char_u         *ptr;
-    char_u         *srcptr;
     int                    len;
     int                    i;
-    int                    round;
     int                    idx = 0;
-    int                    multiline = FALSE;
-    int                    multiignore = FALSE;
-    int                    multiscan = FALSE;
+    static int     multiline = FALSE;
+    static int     multiignore = FALSE;
+    static int     multiscan = FALSE;
     int                    retval = -1;        /* default: return error flag */
-    char_u         *directory = NULL;
-    char_u         *currfile = NULL;
+    static char_u   *directory = NULL;
+    static char_u   *currfile = NULL;
     char_u         *tail = NULL;
     char_u         *p_buf = NULL;
     char_u         *p_str = NULL;
     listitem_T     *p_li = NULL;
-    struct dir_stack_T  *file_stack = NULL;
+    static struct dir_stack_T  *file_stack = NULL;
     regmatch_T     regmatch;
-    static struct fmtpattern
-    {
-       char_u  convchar;
-       char    *pattern;
-    }              fmt_pat[FMT_PATTERNS] =
-                   {
-                       {'f', ".\\+"},      /* only used when at end */
-                       {'n', "\\d\\+"},
-                       {'l', "\\d\\+"},
-                       {'c', "\\d\\+"},
-                       {'t', "."},
-                       {'m', ".\\+"},
-                       {'r', ".*"},
-                       {'p', "[-       .]*"},
-                       {'v', "\\d\\+"},
-                       {'s', ".\\+"}
-                   };
 
     namebuf = alloc_id(CMDBUFFSIZE + 1, aid_qf_namebuf);
     errmsglen = CMDBUFFSIZE + 1;
@@ -324,200 +575,31 @@ qf_init_ext(
        efm = buf->b_p_efm;
     else
        efm = errorformat;
+
     /*
-     * Get some space to modify the format string into.
+     * If the errorformat didn't change between calls, then reuse the
+     * previously parsed values.
      */
-    i = (FMT_PATTERNS * 3) + ((int)STRLEN(efm) << 2);
-    for (round = FMT_PATTERNS; round > 0; )
-       i += (int)STRLEN(fmt_pat[--round].pattern);
-#ifdef COLON_IN_FILENAME
-    i += 12; /* "%f" can become twelve chars longer */
-#else
-    i += 2; /* "%f" can become two chars longer */
-#endif
-    if ((fmtstr = alloc(i)) == NULL)
-       goto error2;
-
-    while (efm[0] != NUL)
+    if (last_efm == NULL || (STRCMP(last_efm, efm) != 0))
     {
-       /*
-        * Allocate a new eformat structure and put it at the end of the list
-        */
-       fmt_ptr = (efm_T *)alloc_clear((unsigned)sizeof(efm_T));
-       if (fmt_ptr == NULL)
-           goto error2;
-       if (fmt_first == NULL)      /* first one */
-           fmt_first = fmt_ptr;
-       else
-           fmt_last->next = fmt_ptr;
-       fmt_last = fmt_ptr;
-
-       /*
-        * Isolate one part in the 'errorformat' option
-        */
-       for (len = 0; efm[len] != NUL && efm[len] != ','; ++len)
-           if (efm[len] == '\\' && efm[len + 1] != NUL)
-               ++len;
-
-       /*
-        * Build regexp pattern from current 'errorformat' option
-        */
-       ptr = fmtstr;
-       *ptr++ = '^';
-       round = 0;
-       for (efmp = efm; efmp < efm + len; ++efmp)
+       /* Free the previously parsed data */
+       vim_free(last_efm);
+       for (fmt_ptr = fmt_first; fmt_ptr != NULL; fmt_ptr = fmt_first)
        {
-           if (*efmp == '%')
-           {
-               ++efmp;
-               for (idx = 0; idx < FMT_PATTERNS; ++idx)
-                   if (fmt_pat[idx].convchar == *efmp)
-                       break;
-               if (idx < FMT_PATTERNS)
-               {
-                   if (fmt_ptr->addr[idx])
-                   {
-                       sprintf((char *)errmsg,
-                               _("E372: Too many %%%c in format string"), 
*efmp);
-                       EMSG(errmsg);
-                       goto error2;
-                   }
-                   if ((idx
-                               && idx < 6
-                               && vim_strchr((char_u *)"DXOPQ",
-                                                    fmt_ptr->prefix) != NULL)
-                           || (idx == 6
-                               && vim_strchr((char_u *)"OPQ",
-                                                   fmt_ptr->prefix) == NULL))
-                   {
-                       sprintf((char *)errmsg,
-                               _("E373: Unexpected %%%c in format string"), 
*efmp);
-                       EMSG(errmsg);
-                       goto error2;
-                   }
-                   fmt_ptr->addr[idx] = (char_u)++round;
-                   *ptr++ = '\\';
-                   *ptr++ = '(';
-#ifdef BACKSLASH_IN_FILENAME
-                   if (*efmp == 'f')
-                   {
-                       /* Also match "c:" in the file name, even when
-                        * checking for a colon next: "%f:".
-                        * "\%(\a:\)\=" */
-                       STRCPY(ptr, "\\%(\\a:\\)\\=");
-                       ptr += 10;
-                   }
-#endif
-                   if (*efmp == 'f' && efmp[1] != NUL)
-                   {
-                       if (efmp[1] != '\\' && efmp[1] != '%')
-                       {
-                           /* A file name may contain spaces, but this isn't
-                            * in "\f".  For "%f:%l:%m" there may be a ":" in
-                            * the file name.  Use ".\{-1,}x" instead (x is
-                            * the next character), the requirement that :999:
-                            * follows should work. */
-                           STRCPY(ptr, ".\\{-1,}");
-                           ptr += 7;
-                       }
-                       else
-                       {
-                           /* File name followed by '\\' or '%': include as
-                            * many file name chars as possible. */
-                           STRCPY(ptr, "\\f\\+");
-                           ptr += 4;
-                       }
-                   }
-                   else
-                   {
-                       srcptr = (char_u *)fmt_pat[idx].pattern;
-                       while ((*ptr = *srcptr++) != NUL)
-                           ++ptr;
-                   }
-                   *ptr++ = '\\';
-                   *ptr++ = ')';
-               }
-               else if (*efmp == '*')
-               {
-                   if (*++efmp == '[' || *efmp == '\\')
-                   {
-                       if ((*ptr++ = *efmp) == '[')    /* %*[^a-z0-9] etc. */
-                       {
-                           if (efmp[1] == '^')
-                               *ptr++ = *++efmp;
-                           if (efmp < efm + len)
-                           {
-                               *ptr++ = *++efmp;           /* could be ']' */
-                               while (efmp < efm + len
-                                       && (*ptr++ = *++efmp) != ']')
-                                   /* skip */;
-                               if (efmp == efm + len)
-                               {
-                                   EMSG(_("E374: Missing ] in format string"));
-                                   goto error2;
-                               }
-                           }
-                       }
-                       else if (efmp < efm + len)      /* %*\D, %*\s etc. */
-                           *ptr++ = *++efmp;
-                       *ptr++ = '\\';
-                       *ptr++ = '+';
-                   }
-                   else
-                   {
-                       /* TODO: scanf()-like: %*ud, %*3c, %*f, ... ? */
-                       sprintf((char *)errmsg,
-                               _("E375: Unsupported %%%c in format string"), 
*efmp);
-                       EMSG(errmsg);
-                       goto error2;
-                   }
-               }
-               else if (vim_strchr((char_u *)"%\\.^$~[", *efmp) != NULL)
-                   *ptr++ = *efmp;             /* regexp magic characters */
-               else if (*efmp == '#')
-                   *ptr++ = '*';
-               else if (*efmp == '>')
-                   fmt_ptr->conthere = TRUE;
-               else if (efmp == efm + 1)               /* analyse prefix */
-               {
-                   if (vim_strchr((char_u *)"+-", *efmp) != NULL)
-                       fmt_ptr->flags = *efmp++;
-                   if (vim_strchr((char_u *)"DXAEWICZGOPQ", *efmp) != NULL)
-                       fmt_ptr->prefix = *efmp;
-                   else
-                   {
-                       sprintf((char *)errmsg,
-                               _("E376: Invalid %%%c in format string 
prefix"), *efmp);
-                       EMSG(errmsg);
-                       goto error2;
-                   }
-               }
-               else
-               {
-                   sprintf((char *)errmsg,
-                           _("E377: Invalid %%%c in format string"), *efmp);
-                   EMSG(errmsg);
-                   goto error2;
-               }
-           }
-           else                        /* copy normal character */
-           {
-               if (*efmp == '\\' && efmp + 1 < efm + len)
-                   ++efmp;
-               else if (vim_strchr((char_u *)".*^$~[", *efmp) != NULL)
-                   *ptr++ = '\\';      /* escape regexp atoms */
-               if (*efmp)
-                   *ptr++ = *efmp;
-           }
+           fmt_first = fmt_ptr->next;
+           vim_regfree(fmt_ptr->prog);
+           vim_free(fmt_ptr);
        }
-       *ptr++ = '$';
-       *ptr = NUL;
-       if ((fmt_ptr->prog = vim_regcomp(fmtstr, RE_MAGIC + RE_STRING)) == NULL)
-           goto error2;
-       /*
-        * Advance to next part
-        */
-       efm = skip_to_option_part(efm + len);   /* skip comma and spaces */
+       qf_clean_dir_stack(&dir_stack);
+       qf_clean_dir_stack(&file_stack);
+       directory = NULL;
+       currfile = NULL;
+       multiline = FALSE;
+       multiignore = FALSE;
+       multiscan = FALSE;
+
+       fmt_first = parse_efm_option(efm);
+       last_efm = vim_strsave(efm);
     }
     if (fmt_first == NULL)     /* nothing found */
     {
@@ -1043,19 +1125,10 @@ error2:
 qf_init_ok:
     if (fd != NULL)
        fclose(fd);
-    for (fmt_ptr = fmt_first; fmt_ptr != NULL; fmt_ptr = fmt_first)
-    {
-       fmt_first = fmt_ptr->next;
-       vim_regfree(fmt_ptr->prog);
-       vim_free(fmt_ptr);
-    }
-    qf_clean_dir_stack(&dir_stack);
-    qf_clean_dir_stack(&file_stack);
 qf_init_end:
     vim_free(namebuf);
     vim_free(errmsg);
     vim_free(pattern);
-    vim_free(fmtstr);
     vim_free(growbuf);
 
 #ifdef FEAT_WINDOWS
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index 380d64b..20ef80a 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -9,7 +9,6 @@ set encoding=utf-8
 function! s:setup_commands(cchar)
   if a:cchar == 'c'
     command! -nargs=* -bang Xlist <mods>clist<bang> <args>
-    command! -nargs=* Xgetexpr <mods>cgetexpr <args>
     command! -nargs=* Xolder <mods>colder <args>
     command! -nargs=* Xnewer <mods>cnewer <args>
     command! -nargs=* Xopen <mods>copen <args>
@@ -24,12 +23,13 @@ function! s:setup_commands(cchar)
     command! -nargs=* Xrewind <mods>crewind <args>
     command! -nargs=* -bang Xnext <mods>cnext<bang> <args>
     command! -nargs=* Xexpr <mods>cexpr <args>
+    command! -nargs=* Xgetexpr <mods>cgetexpr <args>
+    command! -nargs=* Xaddexpr <mods>caddexpr <args>
     command! -nargs=* Xvimgrep <mods>vimgrep <args>
     let g:Xgetlist = function('getqflist')
     let g:Xsetlist = function('setqflist')
   else
     command! -nargs=* -bang Xlist <mods>llist<bang> <args>
-    command! -nargs=* Xgetexpr <mods>lgetexpr <args>
     command! -nargs=* Xolder <mods>lolder <args>
     command! -nargs=* Xnewer <mods>lnewer <args>
     command! -nargs=* Xopen <mods>lopen <args>
@@ -44,6 +44,8 @@ function! s:setup_commands(cchar)
     command! -nargs=* Xrewind <mods>lrewind <args>
     command! -nargs=* -bang Xnext <mods>lnext<bang> <args>
     command! -nargs=* Xexpr <mods>lexpr <args>
+    command! -nargs=* Xgetexpr <mods>lgetexpr <args>
+    command! -nargs=* Xaddexpr <mods>laddexpr <args>
     command! -nargs=* Xvimgrep <mods>lvimgrep <args>
     let g:Xgetlist = function('getloclist', [0])
     let g:Xsetlist = function('setloclist', [0])
@@ -653,24 +655,29 @@ endfunction
 
 " Test for quickfix directory stack support
 function! s:dir_stack_tests(cchar)
+  call s:setup_commands(a:cchar)
+
   let save_efm=&efm
   set efm=%DEntering\ dir\ '%f',%f:%l:%m,%XLeaving\ dir\ '%f'
 
-  let l = "Entering dir 'dir1/a'\n" .
-               \ 'habits2.txt:1:Nine Healthy Habits' . "\n" .
-               \ "Entering dir 'b'\n" .
-               \ 'habits3.txt:2:0 Hours of television' . "\n" .
-               \ 'habits2.txt:7:5 Small meals' . "\n" .
-               \ "Entering dir 'dir1/c'\n" .
-               \ 'habits4.txt:3:1 Hour of exercise' . "\n" .
-               \ "Leaving dir 'dir1/c'\n" .
-               \ "Leaving dir 'dir1/a'\n" .
-               \ 'habits1.txt:4:2 Liters of water' . "\n" .
-               \ "Entering dir 'dir2'\n" .
-               \ 'habits5.txt:5:3 Cups of hot green tea' . "\n"
-               \ "Leaving dir 'dir2'\n"
-
-  Xgetexpr l
+  let l = ["Entering dir 'dir1/a'",
+               \ 'habits2.txt:1:Nine Healthy Habits',
+               \ "Entering dir 'b'",
+               \ 'habits3.txt:2:0 Hours of television',
+               \ 'habits2.txt:7:5 Small meals',
+               \ "Entering dir 'dir1/c'",
+               \ 'habits4.txt:3:1 Hour of exercise',
+               \ "Leaving dir 'dir1/c'",
+               \ "Leaving dir 'dir1/a'",
+               \ 'habits1.txt:4:2 Liters of water',
+               \ "Entering dir 'dir2'",
+               \ 'habits5.txt:5:3 Cups of hot green tea',
+               \ "Leaving dir 'dir2'"]
+
+  Xexpr []
+  for one_line in l
+      Xaddexpr one_line
+  endfor
 
   let qf = g:Xgetlist()
 

Raspunde prin e-mail lui