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

71338Re: capture() function to get output of command

Expand Messages
  • Shougo
    Jun 16, 2013
      2013年6月17日月曜日 11時49分10秒 UTC+9 mattn:
      > On Tuesday, May 14, 2013 5:46:25 AM UTC+9, ZyX wrote:
      > > > I cannot think of a plugin that depends on having a nested :redir throw
      > > > an error.
      > >
      > > Refer to my message. Nested :redir throws an error only when context is switched, it is possible to have
      > >
      > > redir => commands
      > > command
      > > redir => mappings
      > > map
      > > redir => imappings
      > > imap
      > > " and so on
      > > redir END
      > >
      > > > That's just bad coding practice, and it could easily be
      > > > corrected in the plugin.
      > >
      > > I completely agree there. Also refer to my message, I explained there how this situation may easily be worked around (just making it always write to target when any :redir is issued is enough for plugins to work; finishing redirections to local variables after function finishes will delete stale redirs in all cases that make sense to write from my point of view and even not finishing should be rare enough and not result in much harm: at maximum vim killed by OOM killer or a few MiBs long file). I have never actually seen plugins with the above code though.
      > >
      > > > Do you have an actual example? As I've shown,
      > > > contrarily there are plugins that (when working together) are indeed
      > > > broken due to what I would call an implementation deficiency.
      > I'm thinking capture() is not replacement of redir. So I'm thinking this issue should be separated with redir's issue.
      > 1. The redir have a problem currently, But capture() doesn't.
      > 2. Reasonable to implement.
      > 3. Easy to use. Possible to write per one line.
      > 4. I know there are some users who want capture().
      > I'm thinking it's good idea to solve some problem.
      > Thanks.

      Yes. I think so, too.

      1. I can use capture() easily than :redir.

      let foo = capture(":mes")

      redir => foo
      redir END

      Which is the easy to understand?

      2. And, the capture() is used for function arguments.

      echo remote_expr("GVIM1", "capture(':mes')")

      I think function is better than command to use it in Vim script.

      3. I think the patch works well(because I tested it).
      But to fix redir is no patches, it is too far to use it in my plugins.

      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+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Show all 26 messages in this topic