Loading ...
Sorry, an error occurred while loading the content.

Re: Patch to add the cbuffer command

Expand Messages
  • Yegappan Lakshmanan
    Hi, ... It is a small change to support ex ranges. The attached updated patch accepts an ex range (with line numbers, marks, etc) for the :cbuffer command.
    Message 1 of 10 , Oct 31, 2004
    • 0 Attachment
      Hi,

      --- Mikolaj Machowski <mikmach@...> wrote:

      > Dnia pi�tek, 29 pa�dziernika 2004 02:44, Yegappan Lakshmanan napisa�:
      > > Hi all,
      > >
      > > The attached patch (aginst the 6.3 sources) implements the
      > > ":cbuffer" command which feeds the contents of the current
      > > buffer to quickfix. This will allow us to copy and paste or
      > > read the output of any command into a Vim buffer and use
      > > the Vim quickfix feature to browse the output.
      > >
      > > Without this command, you have to save the output of the command
      > > to a file and use the ":cfile" or ":cgetfile" commands or the
      > > "-q" Vim argument to use the output.
      > >
      > > If there is some interest in this command, I will add the
      > > documentation.
      > >
      > Didn't test (no 6.3 sources) but:
      >
      > I like the idea but it would be even more useful if you could use it
      > with range, visual, etc. But maybe it is already possible? Or too much
      > bloat?
      >

      It is a small change to support ex ranges. The attached updated
      patch accepts an ex range (with line numbers, marks, etc) for
      the ":cbuffer" command.

      This command works only for the current buffer. Currently, it
      is not possible to specify a buffer name or buffer number to
      this command.

      - Yegappan
      -----------------------------------------------------------------
      *** ./ex_docmd.c.orig Thu Oct 28 20:24:57 2004
      --- ./ex_docmd.c Sun Oct 31 14:19:09 2004
      ***************
      *** 112,117 ****
      --- 112,118 ----
      static int getargopt __ARGS((exarg_T *eap));
      #ifndef FEAT_QUICKFIX
      # define ex_make ex_ni
      + # define ex_cbuffer ex_ni
      # define ex_cc ex_ni
      # define ex_cnext ex_ni
      # define ex_cfile ex_ni
      *** ./proto/quickfix.pro.orig Mon Jun 7 01:54:17 2004
      --- ./proto/quickfix.pro Sun Oct 31 14:00:44 2004
      ***************
      *** 14,19 ****
      --- 14,20 ----
      int bt_dontwrite_msg __ARGS((buf_T *buf));
      int buf_hide __ARGS((buf_T *buf));
      void ex_make __ARGS((exarg_T *eap));
      + void ex_cbuffer __ARGS((exarg_T *eap));
      void ex_cc __ARGS((exarg_T *eap));
      void ex_cnext __ARGS((exarg_T *eap));
      void ex_cfile __ARGS((exarg_T *eap));
      *** ./quickfix.c.orig Thu Oct 28 20:25:03 2004
      --- ./quickfix.c Sun Oct 31 14:17:59 2004
      ***************
      *** 2130,2135 ****
      --- 2130,2155 ----
      }

      /*
      + * ":cbuffer" command.
      + */
      + void
      + ex_cbuffer(eap)
      + exarg_T *eap;
      + {
      + FILE *f;
      +
      + char_u *tmp = vim_tempname('c');
      +
      + buf_write(curbuf, tmp, NULL, eap->line1, eap->line2,
      + NULL, FALSE, FALSE, FALSE, TRUE);
      +
      + qf_init(tmp, p_efm, TRUE);
      +
      + mch_remove(tmp);
      + vim_free(tmp);
      + }
      +
      + /*
      * ":helpgrep {pattern}"
      */
      void
      *** ./ex_cmds.h.orig Thu Oct 28 20:24:47 2004
      --- ./ex_cmds.h Sun Oct 31 14:18:54 2004
      ***************
      *** 190,195 ****
      --- 190,197 ----
      RANGE|NEEDARG|EXTRA|NOTRLCOM|SBOXOK|CMDWIN),
      EX(CMD_catch, "catch", ex_catch,
      EXTRA|SBOXOK|CMDWIN),
      + EX(CMD_cbuffer, "cbuffer", ex_cbuffer,
      + RANGE|DFLALL|TRLBAR),
      EX(CMD_cc, "cc", ex_cc,
      RANGE|NOTADR|COUNT|TRLBAR|BANG),
      EX(CMD_cclose, "cclose", ex_cclose,



      __________________________________
      Do you Yahoo!?
      Yahoo! Mail Address AutoComplete - You start. We finish.
      http://promotions.yahoo.com/new_mail
    • Mikolaj Machowski
      ... Thanks (not tested, alas - see above). ... I think it is too much (especially if patch would have to be much more sophisticated). Initially I thought
      Message 2 of 10 , Nov 1, 2004
      • 0 Attachment
        Dnia niedziela, 31 października 2004 23:23, Yegappan Lakshmanan napisał:
        > Hi,
        >
        > --- Mikolaj Machowski <mikmach@...> wrote:
        > > Dnia pi?tek, 29 pa?dziernika 2004 02:44, Yegappan Lakshmanan napisa?:
        > > > Hi all,
        > > >
        > > > The attached patch (aginst the 6.3 sources) implements the
        > > > ":cbuffer" command which feeds the contents of the current
        > > > buffer to quickfix. This will allow us to copy and paste or
        > > > read the output of any command into a Vim buffer and use
        > > > the Vim quickfix feature to browse the output.
        > > >
        > > > Without this command, you have to save the output of the command
        > > > to a file and use the ":cfile" or ":cgetfile" commands or the
        > > > "-q" Vim argument to use the output.
        > > >
        > > > If there is some interest in this command, I will add the
        > > > documentation.
        > >
        > > Didn't test (no 6.3 sources) but:
        > >
        > > I like the idea but it would be even more useful if you could use it
        > > with range, visual, etc. But maybe it is already possible? Or too much
        > > bloat?
        >
        > It is a small change to support ex ranges. The attached updated
        > patch accepts an ex range (with line numbers, marks, etc) for
        > the ":cbuffer" command.

        Thanks (not tested, alas - see above).

        > This command works only for the current buffer. Currently, it
        > is not possible to specify a buffer name or buffer number to
        > this command.
        >
        I think it is too much (especially if patch would have to be much more
        sophisticated). Initially I thought calling buffer by name/number would
        be cool, especially for scripts but that would be it - just kool-factor.
        For scripts it can be simulated by going to buffer and returning.

        Thanks again.

        m.

        --
        LaTeX + Vim = http://vim-latex.sourceforge.net/
        Vim-list(s) Users Map: (last change 6 Oct)
        http://skawina.eu.org/mikolaj/vimlist
        CLEWN - http://clewn.sf.net
      • Madhu Raghupatruni
        Yegappan, The reverse is pretty useful too. You have a quickfix window that you would want to save as file of errorlist, usually the result of a grep output.
        Message 3 of 10 , Nov 1, 2004
        • 0 Attachment
          Yegappan,

          The reverse is pretty useful too. You have a quickfix window that you
          would want to save as file of errorlist, usually the result of a grep
          output. I currently run it through a small script which converts it
          back to an error list (grep output) and save it into a file. Do you
          think there is a simpler way ?

          --
          Regards,
          Madhu

          * Yegappan Lakshmanan <yegappan@...> [10/28/2004 17:45]:
          > Hi all,
          >
          > The attached patch (aginst the 6.3 sources) implements the
          > ":cbuffer" command which feeds the contents of the current
          > buffer to quickfix. This will allow us to copy and paste or
          > read the output of any command into a Vim buffer and use
          > the Vim quickfix feature to browse the output.
          >
          > Without this command, you have to save the output of the command
          > to a file and use the ":cfile" or ":cgetfile" commands or the
          > "-q" Vim argument to use the output.
          >
          > If there is some interest in this command, I will add the
          > documentation.
          >
          > - Yegappan
          > -------------------------------------------------------------
          > *** ex_cmds.h.orig Tue Mar 30 10:20:53 2004
          > --- ex_cmds.h Thu Oct 28 17:24:59 2004
          > ***************
          > *** 190,195 ****
          > --- 190,197 ----
          > RANGE|NEEDARG|EXTRA|NOTRLCOM|SBOXOK|CMDWIN),
          > EX(CMD_catch, "catch", ex_catch,
          > EXTRA|SBOXOK|CMDWIN),
          > + EX(CMD_cbuffer, "cbuffer", ex_cbuffer,
          > + TRLBAR),
          > EX(CMD_cc, "cc", ex_cc,
          > RANGE|NOTADR|COUNT|TRLBAR|BANG),
          > EX(CMD_cclose, "cclose", ex_cclose,
          > *** ex_docmd.c.orig Sat Jul 17 09:45:47 2004
          > --- ex_docmd.c Thu Oct 28 16:21:50 2004
          > ***************
          > *** 112,117 ****
          > --- 112,118 ----
          > static int getargopt __ARGS((exarg_T *eap));
          > #ifndef FEAT_QUICKFIX
          > # define ex_make ex_ni
          > + # define ex_cbuffer ex_ni
          > # define ex_cc ex_ni
          > # define ex_cnext ex_ni
          > # define ex_cfile ex_ni
          > *** quickfix.c.orig Tue May 25 09:04:34 2004
          > --- quickfix.c Thu Oct 28 17:37:40 2004
          > ***************
          > *** 2130,2135 ****
          > --- 2130,2154 ----
          > }
          >
          > /*
          > + * ":cbuffer" command.
          > + */
          > + void
          > + ex_cbuffer(eap)
          > + exarg_T *eap;
          > + {
          > + FILE *f;
          > +
          > + char_u *tmp = vim_tempname('c');
          > +
          > + buf_write(curbuf, tmp, NULL, (linenr_T)1, curbuf->b_ml.ml_line_count,
          > + NULL, FALSE, FALSE, FALSE, TRUE);
          > + qf_init(tmp, p_efm, TRUE);
          > +
          > + mch_remove(tmp);
          > + vim_free(tmp);
          > + }
          > +
          > + /*
          > * ":helpgrep {pattern}"
          > */
          > void
          >
          >
          >
          >
          > __________________________________
          > Do you Yahoo!?
          > Yahoo! Mail - You care about security. So do we.
          > http://promotions.yahoo.com/new_mail
        • Yegappan Lakshmanan
          Hi, ... As Vim parses and processes the output from grep or any other command to fill the quickfix window, the original output is lost (unless it is already
          Message 4 of 10 , Nov 2, 2004
          • 0 Attachment
            Hi,

            --- Madhu Raghupatruni <rmadhu@...> wrote:
            > Yegappan,
            >
            > The reverse is pretty useful too. You have a quickfix window that you
            > would want to save as file of errorlist, usually the result of a grep
            > output. I currently run it through a small script which converts it
            > back to an error list (grep output) and save it into a file. Do you
            > think there is a simpler way ?
            >

            As Vim parses and processes the output from grep or any other
            command to fill the quickfix window, the original output is
            lost (unless it is already stored in a file). So, reconstructing
            the original output from the quickfix window contents might be
            difficult.

            - Yegappan



            __________________________________
            Do you Yahoo!?
            Check out the new Yahoo! Front Page.
            www.yahoo.com
          • Keith Roberts
            ... Probably a silly idea, but maybe adding |tee {filename} to grepprg could be made to work? [or instead of {filename} it could be {bufname}, where said
            Message 5 of 10 , Nov 2, 2004
            • 0 Attachment
              >-----Original Message-----
              >From: Yegappan Lakshmanan [mailto:yegappan@...]
              >Sent: Tuesday, November 02, 2004 3:12 PM
              >To: Madhu Raghupatruni
              >Cc: vim-dev@...
              >Subject: Re: Patch to add the cbuffer command
              >
              >Hi,
              >
              >--- Madhu Raghupatruni <rmadhu@...> wrote:
              >> Yegappan,
              >>
              >> The reverse is pretty useful too. You have a quickfix
              >window that you
              >> would want to save as file of errorlist, usually the result
              >of a grep
              >> output. I currently run it through a small script which converts it
              >> back to an error list (grep output) and save it into a file. Do you
              >> think there is a simpler way ?
              >>
              >
              >As Vim parses and processes the output from grep or any other
              >command to fill the quickfix window, the original output is
              >lost (unless it is already stored in a file). So,
              >reconstructing the original output from the quickfix window
              >contents might be difficult.
              >
              >- Yegappan

              Probably a silly idea, but maybe adding \|tee {filename} to 'grepprg'
              could be made to work? [or instead of {filename} it could be {bufname},
              where said buffer is created as "nofile" or the like]

              Or maybe something associated with quickfix that performs a tee before
              (as) the data is transformed for the quickfix window?

              Given some known association, that could be used to "get back" to the
              original data.

              -Keith
            • Madhu Raghupatruni
              ... Too many files or buffers generated unnecessarily. Typically you do many greps and you really want to store a few of these searches for later use. ... How
              Message 6 of 10 , Nov 2, 2004
              • 0 Attachment
                * Keith Roberts <kroberts@...> [11/02/2004 15:35]:
                > >-----Original Message-----
                > >From: Yegappan Lakshmanan [mailto:yegappan@...]
                > >Sent: Tuesday, November 02, 2004 3:12 PM
                > >To: Madhu Raghupatruni
                > >Cc: vim-dev@...
                > >Subject: Re: Patch to add the cbuffer command
                > >
                > >Hi,
                > >
                > >--- Madhu Raghupatruni <rmadhu@...> wrote:
                > >> Yegappan,
                > >>
                > >> The reverse is pretty useful too. You have a quickfix
                > >window that you
                > >> would want to save as file of errorlist, usually the result
                > >of a grep
                > >> output. I currently run it through a small script which converts it
                > >> back to an error list (grep output) and save it into a file. Do you
                > >> think there is a simpler way ?
                > >>
                > >
                > >As Vim parses and processes the output from grep or any other
                > >command to fill the quickfix window, the original output is
                > >lost (unless it is already stored in a file). So,
                > >reconstructing the original output from the quickfix window
                > >contents might be difficult.
                > >
                > >- Yegappan
                >
                > Probably a silly idea, but maybe adding \|tee {filename} to 'grepprg'
                > could be made to work? [or instead of {filename} it could be {bufname},
                > where said buffer is created as "nofile" or the like]

                Too many files or buffers generated unnecessarily. Typically you do
                many greps and you really want to store a few of these searches for
                later use.

                >
                > Or maybe something associated with quickfix that performs a tee before
                > (as) the data is transformed for the quickfix window?
                >
                > Given some known association, that could be used to "get back" to the
                > original data.

                How about storing the errorformat or grepformat that generated the
                quickfix with the vim quickfix datastructures and regenerating the
                original error buffer ?

                >
                > -Keith
                >
              • Dave Silvia
                Unless you re married to the idea of using quickfix, try Vimgrep. It has various commands that allow capture of grep-ed output to named buffers. There are the
                Message 7 of 10 , Nov 2, 2004
                • 0 Attachment
                  Unless you're married to the idea of using quickfix, try Vimgrep. It has
                  various commands that allow capture of grep-ed output to named buffers.
                  There are the bare bones commands and associated 'ToBuf' commands:

                  Vimgrep VimgrepToBuf search for pattern in files
                  VimgrepBufs VimgrepBufsToBuf search for pattern in open buffers
                  Vimfind VimfindToBuf search for files

                  And you don't need outside grep/find utilities. Everything is contained in
                  Vim.

                  See:

                  http://www.vim.org/account/profile.php?user_id=5397 vimgrep.vim vsutil.vim

                  FYI:

                  MfG,
                  Dave S.

                  -----Original Message-----
                  From: Keith Roberts [mailto:kroberts@...]
                  Sent: Tuesday, November 02, 2004 5:37 PM
                  To: Yegappan Lakshmanan; Madhu Raghupatruni
                  Cc: vim-dev@...
                  Subject: RE: Patch to add the cbuffer command

                  >-----Original Message-----
                  >From: Yegappan Lakshmanan [mailto:yegappan@...]
                  >Sent: Tuesday, November 02, 2004 3:12 PM
                  >To: Madhu Raghupatruni
                  >Cc: vim-dev@...
                  >Subject: Re: Patch to add the cbuffer command
                  >
                  >Hi,
                  >
                  >--- Madhu Raghupatruni <rmadhu@...> wrote:
                  >> Yegappan,
                  >>
                  >> The reverse is pretty useful too. You have a quickfix
                  >window that you
                  >> would want to save as file of errorlist, usually the result
                  >of a grep
                  >> output. I currently run it through a small script which converts it
                  >> back to an error list (grep output) and save it into a file. Do you
                  >> think there is a simpler way ?
                  >>
                  >
                  >As Vim parses and processes the output from grep or any other
                  >command to fill the quickfix window, the original output is
                  >lost (unless it is already stored in a file). So,
                  >reconstructing the original output from the quickfix window
                  >contents might be difficult.
                  >
                  >- Yegappan

                  Probably a silly idea, but maybe adding \|tee {filename} to 'grepprg'
                  could be made to work? [or instead of {filename} it could be {bufname},
                  where said buffer is created as "nofile" or the like]

                  Or maybe something associated with quickfix that performs a tee before
                  (as) the data is transformed for the quickfix window?

                  Given some known association, that could be used to "get back" to the
                  original data.

                  -Keith
                Your message has been successfully submitted and would be delivered to recipients shortly.