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

Re: Capture output of command line completion in script

Expand Messages
  • Christian Brabandt
    ... Bram, here is a patch, that enables redirecting when using for commandline completion: diff --git a/src/ex_getln.c b/src/ex_getln.c ... +++
    Message 1 of 7 , Dec 25, 2012
    • 0 Attachment
      On Di, 25 Dez 2012, Luca Pette wrote:

      > On Saturday, 26 March 2011 00:10:52 UTC+1, Rickard Lindberg wrote:
      > > Hi,
      > >
      > >
      > >
      > > If I type CTRL-D on the command line it will show a list of possible
      > >
      > > matches (:e foo<CTRL-D>).
      > >
      > >
      > >
      > > Is it possible to capture this result list in a vim script?
      >
      > I was searching for this too. Any new suggestion? It would be awesome if it would be possible to capture the output of command line completion with vimscript/

      Bram,
      here is a patch, that enables redirecting when using <ctrl-d> for
      commandline completion:

      diff --git a/src/ex_getln.c b/src/ex_getln.c
      --- a/src/ex_getln.c
      +++ b/src/ex_getln.c
      @@ -1189,10 +1189,15 @@
      goto cmdline_changed;

      case Ctrl_D:
      + redir_off = FALSE;
      if (showmatches(&xpc, FALSE) == EXPAND_NOTHING)
      + {
      + redir_off = TRUE;
      break; /* Use ^D as normal char instead */
      + }

      redrawcmd();
      + redir_off = TRUE;
      continue; /* don't do incremental search now */

      case K_RIGHT:



      regards,
      Christian
      --

      --
      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
    • Bram Moolenaar
      ... Hmm, I wonder why this request was made. Wouldn t it be more useful to add a Vim script function to access the completions? -- Some of the well known
      Message 2 of 7 , Dec 25, 2012
      • 0 Attachment
        Christian Brabandt wrote:

        > On Di, 25 Dez 2012, Luca Pette wrote:
        >
        > > On Saturday, 26 March 2011 00:10:52 UTC+1, Rickard Lindberg wrote:
        > > > Hi,
        > > >
        > > >
        > > >
        > > > If I type CTRL-D on the command line it will show a list of possible
        > > >
        > > > matches (:e foo<CTRL-D>).
        > > >
        > > >
        > > >
        > > > Is it possible to capture this result list in a vim script?
        > >
        > > I was searching for this too. Any new suggestion? It would be
        > > awesome if it would be possible to capture the output of command
        > > line completion with vimscript/
        >
        > Bram,
        > here is a patch, that enables redirecting when using <ctrl-d> for
        > commandline completion:

        Hmm, I wonder why this request was made. Wouldn't it be more useful to
        add a Vim script function to access the completions?

        --
        Some of the well known MS-Windows errors:
        EHUH Unexpected error
        EUSER User error, not our fault!
        EGOD Horrible problem, god knows what has happened
        EERR Errornous error: nothing wrong

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ an exciting new programming language -- http://www.Zimbu.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

        --
        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
      • Christian Brabandt
        Hi Bram! ... Right. But shouldn t :redir also be useable to capture all available completions? We can still think about adding another completion vimscript
        Message 3 of 7 , Dec 26, 2012
        • 0 Attachment
          Hi Bram!

          On Mi, 26 Dez 2012, Bram Moolenaar wrote:

          >
          > Christian Brabandt wrote:
          >
          > > On Di, 25 Dez 2012, Luca Pette wrote:
          > >
          > > > On Saturday, 26 March 2011 00:10:52 UTC+1, Rickard Lindberg wrote:
          > > > > Hi,
          > > > >
          > > > >
          > > > >
          > > > > If I type CTRL-D on the command line it will show a list of possible
          > > > >
          > > > > matches (:e foo<CTRL-D>).
          > > > >
          > > > >
          > > > >
          > > > > Is it possible to capture this result list in a vim script?
          > > >
          > > > I was searching for this too. Any new suggestion? It would be
          > > > awesome if it would be possible to capture the output of command
          > > > line completion with vimscript/
          > >
          > > Bram,
          > > here is a patch, that enables redirecting when using <ctrl-d> for
          > > commandline completion:
          >
          > Hmm, I wonder why this request was made. Wouldn't it be more useful to
          > add a Vim script function to access the completions?

          Right. But shouldn't :redir also be useable to capture all available
          completions? We can still think about adding another completion
          vimscript function for returning all matches.

          regards,
          Christian
          --
          Gegner bedürfen einander oft mehr als Freunde, denn ohne Wind gehen
          keine Mühlen.
          -- Hermann Hesse

          --
          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
        • ZyX
          ... There is already a workaround: https://github.com/paradigm/SkyBison/blob/eda32bb644fd0651679121dca11e41088dafc94b/plugin/skybison.vim#L141-L152 . Why do we
          Message 4 of 7 , Dec 26, 2012
          • 0 Attachment
            > Right. But shouldn't :redir also be useable to capture all available
            > completions? We can still think about adding another completion
            > vimscript function for returning all matches.

            There is already a workaround:
            https://github.com/paradigm/SkyBison/blob/eda32bb644fd0651679121dca11e41088dafc94b/plugin/skybison.vim#L141-L152
            . Why do we need :redir? If a function for capturing completions is added :redir support becomes more pointless then now when workaround exists.

            I would really like a function anywhere I have to use :redir now and purge out :redir from my and others’ people code: parsing back data that was structured and could be output as a complex structure instead of text by some function is already bad. But with “no nested redirections” rule you never know when you will have a problem with :redir and encouraging people to use it by adding support for this is just bad.

            Completion scripts may and some in fact *will* use :redir: I see no other way to get the list of functions and thus had to use this workaround. Using :redir to capture completion variants may result in these functions being broken and *will* result in the outer function requesting completion variants being broken.

            --
            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
          • Christian Brabandt
            Hi ZyX! ... This just looks like another ugly workaround, not better then using ... Mit freundlichen Grüßen Christian -- Dies ist die Probe, wie hoch man
            Message 5 of 7 , Dec 26, 2012
            • 0 Attachment
              Hi ZyX!

              On Mi, 26 Dez 2012, ZyX wrote:

              > > Right. But shouldn't :redir also be useable to capture all available
              > > completions? We can still think about adding another completion
              > > vimscript function for returning all matches.
              >
              > There is already a workaround:
              > https://github.com/paradigm/SkyBison/blob/eda32bb644fd0651679121dca11e41088dafc94b/plugin/skybison.vim#L141-L152
              > . Why do we need :redir? If a function for capturing completions is added :redir support becomes more pointless then now when workaround exists.
              >
              > I would really like a function anywhere I have to use :redir now and purge out :redir from my and others’ people code: parsing back data that was structured and could be output as a complex structure instead of text by some function is already bad. But with “no nested redirections” rule you never know when you will have a problem with :redir and encouraging people to use it by adding support for this is just bad.
              >
              > Completion scripts may and some in fact *will* use :redir: I see no other way to get the list of functions and thus had to use this workaround. Using :redir to capture completion variants may result in these functions being broken and *will* result in the outer function requesting completion variants being broken.

              This just looks like another ugly workaround, not better then using
              :redir


              Mit freundlichen Grüßen
              Christian
              --
              Dies ist die Probe, wie hoch man einen andern Menschen stelle und
              liebe, inwieweit man von ihm in Rücksicht der Glücksgüter abhängig
              sein will. Nur dies Gefühl entscheidet über die Ansicht fremden
              Gehalts.
              -- Jean Paul

              --
              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
            • ZyX
              ... I never said it is not a workaround. But it is still better then using :redir for the reasons explained in the last paragraph. I am arguing here that
              Message 6 of 7 , Dec 26, 2012
              • 0 Attachment
                > This just looks like another ugly workaround, not better then using
                > :redir

                I never said it is not a workaround. But it is still better then using :redir for the reasons explained in the last paragraph.

                I am arguing here that adding :redir support is not needed at all. Bram suggested to have function, you suggested to have function *and* :redir, I argue that *only* function should be supported. There were the reasons behind having *only* function. What are the reasons for

                > But shouldn't :redir also be useable to capture all available completions?

                ? If somebody needs a working solution for capturing completion variants it is linked above, meaning that it is not a reason for adding :redir support.

                --
                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
              • Bram Moolenaar
                ... That depends. If someone uses :redir to capture the result of a command, then the list of completions just gets in the way. Generally, redirection is to
                Message 7 of 7 , Dec 29, 2012
                • 0 Attachment
                  Christian Brabandt wrote:

                  > On Mi, 26 Dez 2012, Bram Moolenaar wrote:
                  >
                  > >
                  > > Christian Brabandt wrote:
                  > >
                  > > > On Di, 25 Dez 2012, Luca Pette wrote:
                  > > >
                  > > > > On Saturday, 26 March 2011 00:10:52 UTC+1, Rickard Lindberg wrote:
                  > > > > > Hi,
                  > > > > >
                  > > > > >
                  > > > > >
                  > > > > > If I type CTRL-D on the command line it will show a list of possible
                  > > > > >
                  > > > > > matches (:e foo<CTRL-D>).
                  > > > > >
                  > > > > >
                  > > > > >
                  > > > > > Is it possible to capture this result list in a vim script?
                  > > > >
                  > > > > I was searching for this too. Any new suggestion? It would be
                  > > > > awesome if it would be possible to capture the output of command
                  > > > > line completion with vimscript/
                  > > >
                  > > > Bram,
                  > > > here is a patch, that enables redirecting when using <ctrl-d> for
                  > > > commandline completion:
                  > >
                  > > Hmm, I wonder why this request was made. Wouldn't it be more useful to
                  > > add a Vim script function to access the completions?
                  >
                  > Right. But shouldn't :redir also be useable to capture all available
                  > completions? We can still think about adding another completion
                  > vimscript function for returning all matches.

                  That depends. If someone uses :redir to capture the result of a
                  command, then the list of completions just gets in the way. Generally,
                  redirection is to capture the output of the command, not what was done
                  to edit it. We could perhaps add a flag to :redir to also capture
                  everything that was typed and displayed, but that's getting complicated.
                  With a Vim funtion it should be a lot easier and straightforward to get
                  what you want.

                  --
                  hundred-and-one symptoms of being an internet addict:
                  206. You religiously respond immediately to e-mail, while ignoring
                  your growing pile of snail mail.

                  /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                  /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                  \\\ an exciting new programming language -- http://www.Zimbu.org ///
                  \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

                  --
                  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
                Your message has been successfully submitted and would be delivered to recipients shortly.