]> granicus.if.org Git - vim/commitdiff
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
authorBram Moolenaar <Bram@vim.org>
Sun, 25 Jul 2010 14:58:46 +0000 (16:58 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 25 Jul 2010 14:58:46 +0000 (16:58 +0200)
runtime/doc/options.txt
runtime/doc/quickfix.txt
runtime/doc/todo.txt
runtime/ftplugin/quickfix.vim [new file with mode: 0644]
src/buffer.c
src/if_cscope.c
src/main.c
src/option.h
src/proto/quickfix.pro
src/quickfix.c

index 17c6a46ec8a81bbd06c0c5baa8028187c4a0ab2c..8e2b5e07248f6de7dd9007b26500b4fd3be8af46 100644 (file)
@@ -6523,6 +6523,7 @@ A jump table for the options with a short description can be found at |Q_op|.
        y F   Type of file in the buffer, e.g., "[vim]".  See 'filetype'.
        Y F   Type of file in the buffer, e.g., ",VIM".  See 'filetype'.
              {not available when compiled without |+autocmd| feature}
+       q S   "[Quickfix List]", "[Location List]" or empty.
        k S   Value of "b:keymap_name" or 'keymap' when |:lmap| mappings are
              being used: "<keymap>"
        n N   Buffer number.
index d710e97a5f13dfff58753f2675dfb7731ecdfe21..972ebd89d455dc1378760565ff835d104f6dc26c 100644 (file)
@@ -301,7 +301,7 @@ use this code: >
 =============================================================================
 2. The error window                                    *quickfix-window*
 
-                                                       *:cope* *:copen*
+                                           *:cope* *:copen* *w:quickfix_title*
 :cope[n] [height]      Open a window to show the current list of errors.
                        When [height] is given, the window becomes that high
                        (if there is room).  Otherwise the window is made ten
@@ -310,7 +310,11 @@ use this code: >
                        'buftype' equal to "quickfix".  Don't change this!
                        If there already is a quickfix window, it will be made
                        the current window.  It is not possible to open a
-                       second quickfix window.
+                       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.
 
                                                        *:lop* *:lopen*
 :lop[en] [height]      Open a window to show the location list for the
index a7c9aaf34fa8b95e9eb8c16a678bc17aea2e31e9..b89c25fab857e25cb8c65e24cf15f81f75a43443 100644 (file)
@@ -30,9 +30,6 @@ be worked on, but only if you sponsor Vim development.  See |sponsor|.
                                                        *known-bugs*
 -------------------- Known bugs and current work -----------------------
 
-Include patch for horizontal scoll wheel? (Bjorn Winckler, 2010 Jul 20)
-Additional patch Jul 21.
-
 6   In the quickfix window statusline add the command used to get the list of
     errors, e.g. ":make foo", ":grep something *.c".
     New patch 2010 Jul 24
diff --git a/runtime/ftplugin/quickfix.vim b/runtime/ftplugin/quickfix.vim
new file mode 100644 (file)
index 0000000..f1d0922
--- /dev/null
@@ -0,0 +1,16 @@
+" Vim filetype plugin file
+" Language:     Vim's quickfix window
+" Maintainer:   Lech Lorens <Lech.Lorens@gmail.com>
+" Last Changed: 22 Jul 2010
+
+if exists("b:did_ftplugin")
+  finish
+endif
+
+" Don't load another plugin for this buffer
+let b:did_ftplugin = 1
+
+let b:undo_ftplugin = "setl stl<"
+
+" Display the command that produced the list in the quickfix window:
+setlocal stl=%q%{exists('w:quickfix_title')?\ '\ '.w:quickfix_title\ :\ ''}
index 22fa136168855c7167e72eedd5cba8117d4d17aa..0b3742b309ff11c2880dd264053f244483c6c9b7 100644 (file)
@@ -60,6 +60,11 @@ static void insert_sign __ARGS((buf_T *buf, signlist_T *prev, signlist_T *next,
 static void buf_delete_signs __ARGS((buf_T *buf));
 #endif
 
+#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
+static char *msg_loclist = N_("[Location List]");
+static char *msg_qflist = N_("[Quickfix List]");
+#endif
+
 /*
  * Open current buffer, that is: open the memfile and read the file into
  * memory.
@@ -3878,6 +3883,13 @@ build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hltab, t
                str = (char_u *)((opt == STL_PREVIEWFLAG_ALT) ? ",PRV"
                                                            : _("[Preview]"));
            break;
+
+       case STL_QUICKFIX:
+           if (bt_quickfix(wp->w_buffer))
+               str = (char_u *)(wp->w_llist_ref
+                           ? _(msg_loclist)
+                           : _(msg_qflist));
+           break;
 #endif
 
        case STL_MODIFIED:
@@ -5124,9 +5136,9 @@ buf_spname(buf)
                goto win_found;
 win_found:
        if (win != NULL && win->w_llist_ref != NULL)
-           return _("[Location List]");
+           return _(msg_loclist);
        else
-           return _("[Quickfix List]");
+           return _(msg_qflist);
     }
 #endif
 #ifdef FEAT_QUICKFIX
index 8eaa037699339fe025e0f934bec361412a0fd21c..3ee7183211d6955b512b077b5766505af9cc6779 100644 (file)
@@ -44,7 +44,7 @@ static void       cs_file_results __ARGS((FILE *, int *));
 static void        cs_fill_results __ARGS((char *, int , int *, char ***,
                        char ***, int *));
 static int         cs_find __ARGS((exarg_T *eap));
-static int         cs_find_common __ARGS((char *opt, char *pat, int, int, int));
+static int         cs_find_common __ARGS((char *opt, char *pat, int, int, int, char_u *cmdline));
 static int         cs_help __ARGS((exarg_T *eap));
 static void        clear_csinfo __ARGS((int i));
 static int         cs_insert_filelist __ARGS((char *, char *, char *,
@@ -294,7 +294,7 @@ do_cstag(eap)
        if (cs_check_for_connections())
        {
            ret = cs_find_common("g", (char *)(eap->arg), eap->forceit, FALSE,
-                                FALSE);
+                                                      FALSE, *eap->cmdlinep);
            if (ret == FALSE)
            {
                cs_free_tags();
@@ -322,7 +322,7 @@ do_cstag(eap)
                if (cs_check_for_connections())
                {
                    ret = cs_find_common("g", (char *)(eap->arg), eap->forceit,
-                                        FALSE, FALSE);
+                                               FALSE, FALSE, *eap->cmdlinep);
                    if (ret == FALSE)
                        cs_free_tags();
                }
@@ -331,7 +331,7 @@ do_cstag(eap)
        else if (cs_check_for_connections())
        {
            ret = cs_find_common("g", (char *)(eap->arg), eap->forceit, FALSE,
-                                FALSE);
+                                                      FALSE, *eap->cmdlinep);
            if (ret == FALSE)
                cs_free_tags();
        }
@@ -1068,6 +1068,7 @@ cs_find(eap)
     exarg_T *eap;
 {
     char *opt, *pat;
+    int i;
 
     if (cs_check_for_connections() == FALSE)
     {
@@ -1088,8 +1089,16 @@ cs_find(eap)
        return FALSE;
     }
 
+    /*
+     * Let's replace the NULs written by strtok() with spaces - we need the
+     * spaces to correctly display the quickfix/location list window's title.
+     */
+    for (i = 0; i < eap_arg_len; ++i)
+       if (NUL == eap->arg[i])
+           eap->arg[i] = ' ';
+
     return cs_find_common(opt, pat, eap->forceit, TRUE,
-                         eap->cmdidx == CMD_lcscope);
+                                 eap->cmdidx == CMD_lcscope, *eap->cmdlinep);
 } /* cs_find */
 
 
@@ -1099,12 +1108,13 @@ cs_find(eap)
  * common code for cscope find, shared by cs_find() and do_cstag()
  */
     static int
-cs_find_common(opt, pat, forceit, verbose, use_ll)
+cs_find_common(opt, pat, forceit, verbose, use_ll, cmdline)
     char *opt;
     char *pat;
     int forceit;
     int verbose;
     int        use_ll;
+    char_u *cmdline;
 {
     int i;
     char *cmd;
@@ -1257,7 +1267,7 @@ cs_find_common(opt, pat, forceit, verbose, use_ll)
                wp = curwin;
            /* '-' starts a new error list */
            if (qf_init(wp, tmp, (char_u *)"%f%*\\t%l%*\\t%m",
-                                                          *qfpos == '-') > 0)
+                                                 *qfpos == '-', cmdline) > 0)
            {
 # ifdef FEAT_WINDOWS
                if (postponed_split != 0)
index 4ccf3562865d2e22018aa24fed52f0dd1e287b24..cadc2efd28065cbcbdc901e96269e37c913173db 100644 (file)
@@ -670,7 +670,8 @@ main
        if (params.use_ef != NULL)
            set_string_option_direct((char_u *)"ef", -1,
                                           params.use_ef, OPT_FREE, SID_CARG);
-       if (qf_init(NULL, p_ef, p_efm, TRUE) < 0)
+       vim_snprintf((char *)IObuff, IOSIZE, "cfile %s", p_ef);
+       if (qf_init(NULL, p_ef, p_efm, TRUE, IObuff) < 0)
        {
            out_char('\n');
            mch_exit(3);
index 78560c697987303ce9fe503f704e8b823aa27c95..0f697c2e4f3c412ad442af3a5eec6b7e83426c73 100644 (file)
 #define STL_PREVIEWFLAG_ALT 'W'                /* - other display */
 #define STL_MODIFIED   'm'             /* modified flag */
 #define STL_MODIFIED_ALT 'M'           /* - other display */
+#define STL_QUICKFIX   'q'             /* quickfix window description */
 #define STL_PERCENTAGE 'p'             /* percentage through file */
 #define STL_ALTPERCENT 'P'             /* percentage as TOP BOT ALL or NN% */
 #define STL_ARGLISTSTAT        'a'             /* argument list status as (x of y) */
 #define STL_HIGHLIGHT  '#'             /* highlight name */
 #define STL_TABPAGENR  'T'             /* tab page label nr */
 #define STL_TABCLOSENR 'X'             /* tab page close nr */
-#define STL_ALL                ((char_u *) "fFtcvVlLknoObBrRhHmYyWwMpPaN{#")
+#define STL_ALL                ((char_u *) "fFtcvVlLknoObBrRhHmYyWwMqpPaN{#")
 
 /* flags used for parsed 'wildmode' */
 #define WIM_FULL       1
index 408bf6decb3c49b9a878cffe94a9658de2b95261..65ef438db44db48bed493fbae7663afdc2cb5b62 100644 (file)
@@ -1,5 +1,5 @@
 /* quickfix.c */
-int qf_init __ARGS((win_T *wp, char_u *efile, char_u *errorformat, int newlist));
+int qf_init __ARGS((win_T *wp, char_u *efile, char_u *errorformat, int newlist, char_u *qf_title));
 void qf_free_all __ARGS((win_T *wp));
 void copy_loclist __ARGS((win_T *from, win_T *to));
 void qf_jump __ARGS((qf_info_T *qi, int dir, int errornr, int forceit));
index c2543a124278776c370416bbaac3915e8c3ca112..883de8c7253e8bd3c475a2c9fe10653d6e239a60 100644 (file)
@@ -56,6 +56,8 @@ typedef struct qf_list_S
     int                qf_count;       /* number of errors (0 means no error list) */
     int                qf_index;       /* current index in the error list */
     int                qf_nonevalid;   /* TRUE if not a single valid entry found */
+    char_u     *qf_title;      /* title derived from the command that created
+                                * the error list */
 } qf_list_T;
 
 struct qf_info_S
@@ -104,8 +106,8 @@ struct efm_S
     int                    conthere;   /* %> used */
 };
 
-static int     qf_init_ext __ARGS((qf_info_T *qi, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast));
-static void    qf_new_list __ARGS((qf_info_T *qi));
+static int     qf_init_ext __ARGS((qf_info_T *qi, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast, char_u *qf_title));
+static void    qf_new_list __ARGS((qf_info_T *qi, char_u *qf_title));
 static void    ll_free_all __ARGS((qf_info_T **pqi));
 static int     qf_add_entry __ARGS((qf_info_T *qi, qfline_T **prevp, char_u *dir, char_u *fname, int bufnum, char_u *mesg, long lnum, int col, int vis_col, char_u *pattern, int nr, int type, int valid));
 static qf_info_T *ll_new_list __ARGS((void));
@@ -144,15 +146,16 @@ static qf_info_T *ll_get_or_alloc_list __ARGS((win_T *));
 
 /*
  * Read the errorfile "efile" into memory, line by line, building the error
- * list.
+ * list. Set the error list's title to qf_title.
  * Return -1 for error, number of errors for success.
  */
     int
-qf_init(wp, efile, errorformat, newlist)
+qf_init(wp, efile, errorformat, newlist, qf_title)
     win_T          *wp;
     char_u         *efile;
     char_u         *errorformat;
     int                    newlist;            /* TRUE: start a new error list */
+    char_u         *qf_title;
 {
     qf_info_T      *qi = &ql_info;
 
@@ -167,7 +170,8 @@ qf_init(wp, efile, errorformat, newlist)
     }
 
     return qf_init_ext(qi, efile, curbuf, NULL, errorformat, newlist,
-                                                   (linenr_T)0, (linenr_T)0);
+                                                   (linenr_T)0, (linenr_T)0,
+                                                   qf_title);
 }
 
 /*
@@ -175,11 +179,13 @@ qf_init(wp, efile, errorformat, newlist)
  * list.
  * Alternative: when "efile" is null read errors from buffer "buf".
  * Always use 'errorformat' from "buf" if there is a local value.
- * Then lnumfirst and lnumlast specify the range of lines to use.
+ * Then "lnumfirst" and "lnumlast" specify the range of lines to use.
+ * Set the title of the list to "qf_title".
  * Return -1 for error, number of errors for success.
  */
     static int
-qf_init_ext(qi, efile, buf, tv, errorformat, newlist, lnumfirst, lnumlast)
+qf_init_ext(qi, efile, buf, tv, errorformat, newlist, lnumfirst, lnumlast,
+                                                                    qf_title)
     qf_info_T      *qi;
     char_u         *efile;
     buf_T          *buf;
@@ -188,6 +194,7 @@ qf_init_ext(qi, efile, buf, tv, errorformat, newlist, lnumfirst, lnumlast)
     int                    newlist;            /* TRUE: start a new error list */
     linenr_T       lnumfirst;          /* first line number to use */
     linenr_T       lnumlast;           /* last line number to use */
+    char_u         *qf_title;
 {
     char_u         *namebuf;
     char_u         *errmsg;
@@ -257,11 +264,11 @@ qf_init_ext(qi, efile, buf, tv, errorformat, newlist, lnumfirst, lnumlast)
 
     if (newlist || qi->qf_curlist == qi->qf_listcount)
        /* make place for a new list */
-       qf_new_list(qi);
+       qf_new_list(qi, qf_title);
     else if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
        /* Adding to existing list, find last entry. */
        for (qfprev = qi->qf_lists[qi->qf_curlist].qf_start;
-                           qfprev->qf_next != qfprev; qfprev = qfprev->qf_next)
+                         qfprev->qf_next != qfprev; qfprev = qfprev->qf_next)
            ;
 
 /*
@@ -860,8 +867,9 @@ qf_init_end:
  * Prepare for adding a new quickfix list.
  */
     static void
-qf_new_list(qi)
+qf_new_list(qi, qf_title)
     qf_info_T  *qi;
+    char_u     *qf_title;
 {
     int                i;
 
@@ -888,6 +896,16 @@ qf_new_list(qi)
        qi->qf_curlist = qi->qf_listcount++;
     qi->qf_lists[qi->qf_curlist].qf_index = 0;
     qi->qf_lists[qi->qf_curlist].qf_count = 0;
+    if (qf_title != NULL)
+    {
+       char_u *p = alloc(STRLEN(qf_title) + 2);
+
+       qi->qf_lists[qi->qf_curlist].qf_title = p;
+       if (p != NULL)
+           sprintf((char *)p, ":%s", (char *)qf_title);
+    }
+    else
+       qi->qf_lists[qi->qf_curlist].qf_title = NULL;
 }
 
 /*
@@ -1100,6 +1118,10 @@ copy_loclist(from, to)
        to_qfl->qf_index = 0;
        to_qfl->qf_start = NULL;
        to_qfl->qf_ptr = NULL;
+       if (from_qfl->qf_title != NULL)
+           to_qfl->qf_title = vim_strsave(from_qfl->qf_title);
+       else
+           to_qfl->qf_title = NULL;
 
        if (from_qfl->qf_count)
        {
@@ -2102,6 +2124,7 @@ qf_free(qi, idx)
        qi->qf_lists[idx].qf_start = qfp;
        --qi->qf_lists[idx].qf_count;
     }
+    vim_free(qi->qf_lists[idx].qf_title);
 }
 
 /*
@@ -2366,6 +2389,10 @@ ex_copen(eap)
      */
     qf_fill_buffer(qi);
 
+    if (qi->qf_lists[qi->qf_curlist].qf_title != NULL)
+       set_internal_string_var((char_u *)"w:quickfix_title",
+                                      qi->qf_lists[qi->qf_curlist].qf_title);
+
     curwin->w_cursor.lnum = qi->qf_lists[qi->qf_curlist].qf_index;
     curwin->w_cursor.col = 0;
     check_cursor();
@@ -2790,7 +2817,8 @@ ex_make(eap)
     res = qf_init(wp, fname, (eap->cmdidx != CMD_make
                            && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm,
                                           (eap->cmdidx != CMD_grepadd
-                                           && eap->cmdidx != CMD_lgrepadd));
+                                           && eap->cmdidx != CMD_lgrepadd),
+                                          *eap->cmdlinep);
 #ifdef FEAT_AUTOCMD
     if (au_name != NULL)
        apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
@@ -2977,7 +3005,8 @@ ex_cfile(eap)
      * quickfix list then a new list is created.
      */
     if (qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile
-                                 && eap->cmdidx != CMD_laddfile)) > 0
+                                 && eap->cmdidx != CMD_laddfile),
+                                                          *eap->cmdlinep) > 0
                                  && (eap->cmdidx == CMD_cfile
                                             || eap->cmdidx == CMD_lfile))
     {
@@ -3085,7 +3114,7 @@ ex_vimgrep(eap)
         eap->cmdidx != CMD_vimgrepadd && eap->cmdidx != CMD_lvimgrepadd)
                                        || qi->qf_curlist == qi->qf_listcount)
        /* make place for a new list */
-       qf_new_list(qi);
+       qf_new_list(qi, *eap->cmdlinep);
     else if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
        /* Adding to existing list, find last entry. */
        for (prevp = qi->qf_lists[qi->qf_curlist].qf_start;
@@ -3594,7 +3623,7 @@ set_errorlist(wp, list, action)
 
     if (action == ' ' || qi->qf_curlist == qi->qf_listcount)
        /* make place for a new list */
-       qf_new_list(qi);
+       qf_new_list(qi, NULL);
     else if (action == 'a' && qi->qf_lists[qi->qf_curlist].qf_count > 0)
        /* Adding to existing list, find last entry. */
        for (prevp = qi->qf_lists[qi->qf_curlist].qf_start;
@@ -3725,10 +3754,20 @@ ex_cbuffer(eap)
            EMSG(_(e_invrange));
        else
        {
+           char_u *qf_title = *eap->cmdlinep;
+
+           if (buf->b_sfname)
+           {
+               vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)",
+                                    (char *)qf_title, (char *)buf->b_sfname);
+               qf_title = IObuff;
+           }
+
            if (qf_init_ext(qi, NULL, buf, NULL, p_efm,
                            (eap->cmdidx != CMD_caddbuffer
                             && eap->cmdidx != CMD_laddbuffer),
-                                                  eap->line1, eap->line2) > 0
+                                                  eap->line1, eap->line2,
+                                                  qf_title) > 0
                    && (eap->cmdidx == CMD_cbuffer
                        || eap->cmdidx == CMD_lbuffer))
                qf_jump(qi, 0, 0, eap->forceit);  /* display first error */
@@ -3767,7 +3806,7 @@ ex_cexpr(eap)
            if (qf_init_ext(qi, NULL, NULL, tv, p_efm,
                            (eap->cmdidx != CMD_caddexpr
                             && eap->cmdidx != CMD_laddexpr),
-                                                (linenr_T)0, (linenr_T)0) > 0
+                                (linenr_T)0, (linenr_T)0, *eap->cmdlinep) > 0
                    && (eap->cmdidx == CMD_cexpr
                        || eap->cmdidx == CMD_lexpr))
                qf_jump(qi, 0, 0, eap->forceit);  /* display first error */
@@ -3837,7 +3876,7 @@ ex_helpgrep(eap)
     if (regmatch.regprog != NULL)
     {
        /* create a new quickfix list */
-       qf_new_list(qi);
+       qf_new_list(qi, *eap->cmdlinep);
 
        /* Go through all directories in 'runtimepath' */
        p = p_rtp;