On 2013-05-07 15:15:13, Ben Fritz wrote:
> On Tuesday, May 7, 2013 4:03:54 PM UTC-5, Christian Brabandt wrote:
> > Bram,
> > 
> > this patch allows to directly set the w:quickfix_title using 
> > 
> > setqflist()/setloclist() functions. Since the w:quickfix_title is 
> > 
> > already stored inside each quickfix list, it makes sense to have it also 
> > 
> > being settable using VimL functions. This allows plugin writers to 
> > 
> > handle existing quickfix lists better (e.g. they can use the 
> > 
> > w:quickfix_title variable to tag and identify quickfix lists).
> > 
> > 
> 
> Hi, Christian!
> 
> The maintainer of Eclim, Eric Van Dewoestine, sent me a patch to try once 
> which not only allowed setting the quickfix title but it also made :colder 
> and :cnewer restore that title.
> 
> I can't tell from looking quickly, does your patch allow this as well?
> 
> I never dug deeply enough into the first one to give him feedback one way or 
> another. I remember it had compiler errors that looked worrisome to me.
> 
> I wanted this patch to fix something in Eclim that has bugged me for a while, 
> that there is very little info on WHAT search resulted in a given quickfix 
> list. But as mentioned I hadn't really gotten around to trying out the patch.

Attached is the patch that Ben is referring to. I never got around to
dealing with the compiler warning (my experience w/ c is severely
limited).

-- 
eric

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1792,10 +1792,12 @@
 getline( {lnum})               String  line {lnum} of current buffer
 getline( {lnum}, {end})                List    lines {lnum} to {end} of 
current buffer
 getloclist( {nr})              List    list of location list items
+getloctitle( {nr})             String  title of the location list
 getmatches()                   List    list of current matches
 getpid()                       Number  process ID of Vim
 getpos( {expr})                        List    position of cursor, mark, etc.
 getqflist()                    List    list of quickfix items
+getqftitle()                   String  title of the quickfix list
 getreg( [{regname} [, 1]])     String  contents of register
 getregtype( [{regname}])       String  type of register
 gettabvar( {nr}, {varname})    any     variable {varname} in tab {nr}
@@ -1919,9 +1921,12 @@
 setline( {lnum}, {line})       Number  set line {lnum} to {line}
 setloclist( {nr}, {list}[, {action}])
                                Number  modify location list using {list}
+setloctitle( {nr}, {title})    Number  set the location list title using
+                                       {title}
 setmatches( {list})            Number  restore a list of matches
 setpos( {expr}, {list})                Number  set the {expr} position to 
{list}
 setqflist( {list}[, {action}]) Number  modify quickfix list using {list}
+setqftitle( {title})           Number  set the quickfix title using {title}
 setreg( {n}, {v}[, {opt}])     Number  set register to value and type
 settabvar( {nr}, {varname}, {val})     set {varname} in tab page {nr} to {val}
 settabwinvar( {tabnr}, {winnr}, {varname}, {val})    set {varname} in window
@@ -3350,6 +3355,11 @@
                returned.  For an invalid window number {nr}, an empty list is
                returned. Otherwise, same as |getqflist()|.
 
+getloctitle({nr})                                      *getloctitle()*
+               Returns the title of the location list for window {nr}.
+               When {nr} is zero the current window is used.  For a location
+               list window, the displayed location list's title is returned.
+
 getmatches()                                           *getmatches()*
                Returns a |List| with all matches previously defined by
                |matchadd()| and the |:match| commands.  |getmatches()| is
@@ -3398,6 +3408,9 @@
                        :   echo bufname(d.bufnr) ':' d.lnum '=' d.text
                        :endfor
 
+getqftitle()                                           *getqftitle()*
+               Returns the title of the current quickfix list.
+
 
 getreg([{regname} [, 1]])                              *getreg()*
                The result is a String, which is the contents of register
@@ -5123,6 +5136,12 @@
                Otherwise, same as |setqflist()|.
                Also see |location-list|.
 
+setloctitle({nr}, {title})                             *setloctitle()*
+               Set the location list title for window {nr}.
+               When {nr} is zero the current window is used.
+               Otherwise, same as |setqftitle()|.
+               Also see |location-list|.
+
 setmatches({list})                                     *setmatches()*
                Restores a list of matches saved by |getmatches()|.  Returns 0
                if successful, otherwise -1.  All current matches are cleared
@@ -5207,6 +5226,10 @@
                independent of the 'errorformat' setting.  Use a command like
                ":cc 1" to jump to the first position.
 
+setqftitle({title})                                    *setqftitle()*
+               Set the quickfix window title to be associated with the
+               current quickfix list.
+
 
                                                        *setreg()*
 setreg({regname}, {value} [,{options}])
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -313,9 +313,10 @@
                        the current window.  It is not possible to open a
                        second quickfix window. The window will have the
                        w:quickfix_title variable set which will indicate the
-                       command that produced the quickfix list. This can be
-                       used to compose a custom status line if the value of
-                       'statusline' is adjusted properly.
+                       command that produced the quickfix list (or if
+                       |setqftitle()| was called, the title supplied there).
+                       This can be used to compose a custom status line if
+                       the value of 'statusline' is adjusted properly.
 
                                                        *:lop* *:lopen*
 :lop[en] [height]      Open a window to show the location list for the
diff --git a/runtime/doc/tags b/runtime/doc/tags
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -5975,10 +5975,12 @@
 getlatestvimscripts-install    pi_getscript.txt        
/*getlatestvimscripts-install*
 getline()      eval.txt        /*getline()*
 getloclist()   eval.txt        /*getloclist()*
+getloctitle()  eval.txt        /*getloctitle()*
 getmatches()   eval.txt        /*getmatches()*
 getpid()       eval.txt        /*getpid()*
 getpos()       eval.txt        /*getpos()*
 getqflist()    eval.txt        /*getqflist()*
+getqftitle()   eval.txt        /*getqftitle()*
 getreg()       eval.txt        /*getreg()*
 getregtype()   eval.txt        /*getregtype()*
 getscript      pi_getscript.txt        /*getscript*
@@ -7469,9 +7471,11 @@
 setcmdpos()    eval.txt        /*setcmdpos()*
 setline()      eval.txt        /*setline()*
 setloclist()   eval.txt        /*setloclist()*
+setloctitle()  eval.txt        /*setloctitle()*
 setmatches()   eval.txt        /*setmatches()*
 setpos()       eval.txt        /*setpos()*
 setqflist()    eval.txt        /*setqflist()*
+setqftitle()   eval.txt        /*setqftitle()*
 setreg()       eval.txt        /*setreg()*
 settabvar()    eval.txt        /*settabvar()*
 settabwinvar() eval.txt        /*settabwinvar()*
diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim
--- a/runtime/syntax/vim.vim
+++ b/runtime/syntax/vim.vim
@@ -74,9 +74,9 @@
 syn case match
 
 " Function Names {{{2
-syn keyword vimFuncName contained      abs append argv atan2 bufexists bufname 
byte2line ceil cindent complete confirm cosh cursor did_filetype empty 
eventhandler exp extend filewritable findfile fmod foldclosed foldtext function 
getbufline getcharmod getcmdtype getfperm getftype getmatches getqflist 
gettabvar getwinposy globpath haslocaldir histdel hlexists iconv input 
inputrestore insert items len line localtime map match matchdelete matchstr min 
mode nextnonblank pathshorten prevnonblank pumvisible readfile reltimestr 
remote_foreground remote_read remove repeat reverse search searchpair searchpos 
serverlist setcmdpos setloclist setpos setreg settabwinvar shellescape sin sort 
spellbadword split str2float strchars strftime string strpart strtrans submatch 
synconcealed synIDattr synstack tabpagebuflist tabpagewinnr taglist tanh 
tolower tr type undotree virtcol winbufnr winheight winnr winrestview winwidth
-syn keyword vimFuncName contained      acos argc asin browse buflisted bufnr 
byteidx changenr clearmatches complete_add copy count deepcopy diff_filler 
escape executable expand feedkeys filter float2nr fnameescape foldclosedend 
foldtextresult garbagecollect getbufvar getcmdline getcwd getfsize getline 
getpid getreg gettabwinvar getwinvar has hasmapto histget hlID indent 
inputdialog inputsave isdirectory join libcall line2byte log maparg matchadd 
matchend max mkdir mzeval nr2char pow printf range reltime remote_expr 
remote_peek remote_send rename resolve round searchdecl searchpairpos 
server2client setbufvar setline setmatches setqflist settabvar setwinvar 
simplify sinh soundfold spellsuggest sqrt str2nr strdisplaywidth stridx strlen 
strridx strwidth substitute synID synIDtrans system tabpagenr tagfiles tan 
tempname toupper trunc undofile values visualmode wincol winline winrestcmd 
winsaveview writefile
-syn keyword vimFuncName contained      add argidx atan browsedir bufloaded 
bufwinnr call char2nr col complete_check cos cscope_connection delete diff_hlID 
eval exists expr8 filereadable finddir floor fnamemodify foldlevel foreground 
get getchar getcmdpos getfontname getftime getloclist getpos getregtype 
getwinposx glob has_key histadd histnr hostname index inputlist inputsecret 
islocked keys libcallnr lispindent log10 mapcheck matcharg matchlist
+syn keyword vimFuncName contained      abs append argv atan2 bufexists bufname 
byte2line ceil cindent complete confirm cosh cursor did_filetype empty 
eventhandler exp extend filewritable findfile fmod foldclosed foldtext function 
getbufline getcharmod getcmdtype getfperm getftype getmatches getqflist 
getqftitle gettabvar getwinposy globpath haslocaldir histdel hlexists iconv 
input inputrestore insert items len line localtime map match matchdelete 
matchstr min mode nextnonblank pathshorten prevnonblank pumvisible readfile 
reltimestr remote_foreground remote_read remove repeat reverse search 
searchpair searchpos serverlist setcmdpos setloclist setloctitle setpos setreg 
settabwinvar shellescape sin sort spellbadword split str2float strchars 
strftime string strpart strtrans submatch synconcealed synIDattr synstack 
tabpagebuflist tabpagewinnr taglist tanh tolower tr type undotree virtcol 
winbufnr winheight winnr winrestview winwidth
+syn keyword vimFuncName contained      acos argc asin browse buflisted bufnr 
byteidx changenr clearmatches complete_add copy count deepcopy diff_filler 
escape executable expand feedkeys filter float2nr fnameescape foldclosedend 
foldtextresult garbagecollect getbufvar getcmdline getcwd getfsize getline 
getpid getreg gettabwinvar getwinvar has hasmapto histget hlID indent 
inputdialog inputsave isdirectory join libcall line2byte log maparg matchadd 
matchend max mkdir mzeval nr2char pow printf range reltime remote_expr 
remote_peek remote_send rename resolve round searchdecl searchpairpos 
server2client setbufvar setline setmatches setqflist setqftitle settabvar 
setwinvar simplify sinh soundfold spellsuggest sqrt str2nr strdisplaywidth 
stridx strlen strridx strwidth substitute synID synIDtrans system tabpagenr 
tagfiles tan tempname toupper trunc undofile values visualmode wincol winline 
winrestcmd winsaveview writefile
+syn keyword vimFuncName contained      add argidx atan browsedir bufloaded 
bufwinnr call char2nr col complete_check cos cscope_connection delete diff_hlID 
eval exists expr8 filereadable finddir floor fnamemodify foldlevel foreground 
get getchar getcmdpos getfontname getftime getloclist getloctitle getpos 
getregtype getwinposx glob has_key histadd histnr hostname index inputlist 
inputsecret islocked keys libcallnr lispindent log10 mapcheck matcharg matchlist
 
 "--- syntax above generated by mkvimvim ---
 " Special Vim Highlighting (not automatic) {{{1
diff --git a/src/eval.c b/src/eval.c
--- a/src/eval.c
+++ b/src/eval.c
@@ -565,6 +565,7 @@
 static void f_getpid __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_getpos __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_getqflist __ARGS((typval_T *argvars, typval_T *rettv));
+static void f_getqftitle __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_getreg __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_getregtype __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_gettabvar __ARGS((typval_T *argvars, typval_T *rettv));
@@ -679,9 +680,11 @@
 static void f_setcmdpos __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_setline __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_setloclist __ARGS((typval_T *argvars, typval_T *rettv));
+static void f_setloctitle __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_setmatches __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_setpos __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_setqflist __ARGS((typval_T *argvars, typval_T *rettv));
+static void f_setqftitle __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_setreg __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_settabvar __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_settabwinvar __ARGS((typval_T *argvars, typval_T *rettv));
@@ -7903,10 +7906,12 @@
     {"getftype",       1, 1, f_getftype},
     {"getline",                1, 2, f_getline},
     {"getloclist",     1, 1, f_getqflist},
+    {"getloctitle",    1, 1, f_getqftitle},
     {"getmatches",     0, 0, f_getmatches},
     {"getpid",         0, 0, f_getpid},
     {"getpos",         1, 1, f_getpos},
     {"getqflist",      0, 0, f_getqflist},
+    {"getqftitle",     0, 0, f_getqftitle},
     {"getreg",         0, 2, f_getreg},
     {"getregtype",     0, 1, f_getregtype},
     {"gettabvar",      2, 2, f_gettabvar},
@@ -8023,9 +8028,11 @@
     {"setcmdpos",      1, 1, f_setcmdpos},
     {"setline",                2, 2, f_setline},
     {"setloclist",     2, 3, f_setloclist},
+    {"setloctitle",    2, 2, f_setloctitle},
     {"setmatches",     1, 1, f_setmatches},
     {"setpos",         2, 2, f_setpos},
     {"setqflist",      1, 2, f_setqflist},
+    {"setqftitle",     1, 1, f_setqftitle},
     {"setreg",         2, 3, f_setreg},
     {"settabvar",      3, 3, f_settabvar},
     {"settabwinvar",   4, 4, f_settabwinvar},
@@ -11627,6 +11634,32 @@
 }
 
 /*
+ * "getqftitle()" and "getloctitle()" functions
+ */
+    static void
+f_getqftitle(argvars, rettv)
+    typval_T   *argvars UNUSED;
+    typval_T   *rettv UNUSED;
+{
+#ifdef FEAT_QUICKFIX
+    win_T      *wp;
+#endif
+
+#ifdef FEAT_QUICKFIX
+    wp = NULL;
+    if (argvars[0].v_type != VAR_UNKNOWN)      /* getloctitle() */
+    {
+        wp = find_win_by_nr(&argvars[0], NULL);
+        if (wp == NULL)
+            return;
+    }
+
+    rettv->v_type = VAR_STRING;
+    rettv->vval.v_string = get_errortitle(wp);
+#endif
+}
+
+/*
  * "getreg()" function
  */
     static void
@@ -16246,6 +16279,33 @@
 #endif
 }
 
+static void set_qf_ll_title __ARGS((win_T *wp, typval_T *title_arg, typval_T 
*rettv));
+
+/*
+ * Used by "setqftitle()" and "setloctitle()" functions
+ */
+    static void
+set_qf_ll_title(wp, title_arg, rettv)
+    win_T      *wp UNUSED;
+    typval_T   *title_arg UNUSED;
+    typval_T   *rettv;
+{
+#ifdef FEAT_QUICKFIX
+    char_u     *title;
+#endif
+
+    rettv->vval.v_number = -1;
+
+#ifdef FEAT_QUICKFIX
+    title = get_tv_string_chk(title_arg);
+    if (title == NULL)
+        return;                /* type error; errmsg already given */
+
+    if (set_errortitle(wp, title) == OK)
+        rettv->vval.v_number = 0;
+#endif
+}
+
 /*
  * "setloclist()" function
  */
@@ -16264,6 +16324,23 @@
 }
 
 /*
+ * "setloctitle()" function
+ */
+    static void
+f_setloctitle(argvars, rettv)
+    typval_T   *argvars;
+    typval_T   *rettv;
+{
+    win_T      *win;
+
+    rettv->vval.v_number = -1;
+
+    win = find_win_by_nr(&argvars[0], NULL);
+    if (win != NULL)
+       set_qf_ll_title(win, &argvars[1], rettv);
+}
+
+/*
  * "setmatches()" function
  */
     static void
@@ -16379,6 +16456,17 @@
 }
 
 /*
+ * "setqftitle()" function
+ */
+    static void
+f_setqftitle(argvars, rettv)
+    typval_T   *argvars;
+    typval_T   *rettv;
+{
+    set_qf_ll_title(NULL, &argvars[0], rettv);
+}
+
+/*
  * "setreg()" function
  */
     static void
diff --git a/src/quickfix.c b/src/quickfix.c
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -882,6 +882,24 @@
 }
 
 /*
+ * Set the title for the current quickfix list.
+ */
+    static void
+qf_title_list(qi, qf_title)
+    qf_info_T  *qi;
+    char_u     *qf_title;
+{
+    if (qf_title != NULL)
+    {
+       char_u *p = alloc((int)STRLEN(qf_title) + 2);
+
+       qi->qf_lists[qi->qf_curlist].qf_title = p;
+       if (p != NULL)
+           sprintf((char *)p, ":%s", (char *)qf_title);
+    }
+}
+
+/*
  * Prepare for adding a new quickfix list.
  */
     static void
@@ -913,14 +931,7 @@
     else
        qi->qf_curlist = qi->qf_listcount++;
     vim_memset(&qi->qf_lists[qi->qf_curlist], 0, (size_t)(sizeof(qf_list_T)));
-    if (qf_title != NULL)
-    {
-       char_u *p = alloc((int)STRLEN(qf_title) + 2);
-
-       qi->qf_lists[qi->qf_curlist].qf_title = p;
-       if (p != NULL)
-           sprintf((char *)p, ":%s", (char *)qf_title);
-    }
+    qf_title_list(qi, qf_title);
 }
 
 /*
@@ -3715,6 +3726,29 @@
 }
 
 /*
+ * Get the quickfix title.
+ */
+    char_u *
+get_errortitle(wp)
+    win_T      *wp;
+{
+    qf_info_T  *qi = &ql_info;
+
+    if (wp != NULL)
+    {
+       qi = GET_LOC_LIST(wp);
+       if (qi == NULL)
+           return NULL;
+    }
+
+    if (qi->qf_curlist >= qi->qf_listcount
+           || qi->qf_lists[qi->qf_curlist].qf_count == 0)
+       return NULL;
+
+    return qi->qf_lists[qi->qf_curlist].qf_title;
+}
+
+/*
  * Populate the quickfix list with the items supplied in the list
  * of dictionaries. "title" will be copied to w:quickfix_title
  */
@@ -3833,6 +3867,37 @@
 
     return retval;
 }
+
+/*
+ * Set the quickfix title.
+ */
+    int
+set_errortitle(wp, title)
+    win_T      *wp;
+    char_u     *title;
+{
+    int                retval = OK;
+    qf_info_T  *qi = &ql_info;
+
+    if (wp != NULL)
+    {
+       qi = ll_get_or_alloc_list(wp);
+       if (qi == NULL)
+           return FAIL;
+    }
+
+    if (qi->qf_curlist == qi->qf_listcount)
+       /* make place for a new list */
+       qf_new_list(qi, title);
+    else
+       qf_title_list(qi, title);
+
+#ifdef FEAT_WINDOWS
+    qf_update_buffer(qi);
+#endif
+
+    return retval;
+}
 #endif
 
 /*

Raspunde prin e-mail lui