69486Re: capture() function to get output of command
- May 10 4:18 AMпятница, 10 мая 2013 г., 6:09:15 UTC+4 пользователь mattn написал:
> On Thursday, May 9, 2013 7:54:38 AM UTC+9, ZyX wrote:Show me them then. It breaks only with nested redirections and it breaks only in the fashion that you get more expected output in place of error and empty string in variable. There is only one case when nested :redir breaks in other fashion: a sequence of :redir's in one function without :redir ENDs except for last one. I have never seen such a strange thing, but there is a way to fix this case: make :redir update variable immediately each time new :redir is called without waiting for :redir END (in any case you need something to store text redirected at this level, why not make it store in variable/register/file? I do not think anybody benefits from "The variable will remain empty until redirection ends."). Unneeded :redirs will likely be GCed when function ends (third suggestion).
> I don't hope that capture() contains highlight attributes. It should be plain text. And I guess fixing redir nesting has problems.
> 1. There are plugins that depend on original behavior. This break compatible.
> 2. If skipped 'redir END' with exceptions, we can't close the nesting.This is why I have 3-rd suggestion. Most of the time :redir is used to redirect to variables.
>You don't need :redir! END. Just don't leave all redirection options to user besides for redirection to variable inside a function. Or use :try..:finally.
> For about 2, one of solution is adding bang like 'redir! END'. but this will close all of redir nesting. So it's become un-expected behavior.
If somebody has left stale redirections currently you will see unexpected behavior (error) with regular :redir, refer to the link in my first message. In addition to the text logged somewhere (but only to one place) until next :redir is called.
If somebody has left stale redirections with new proposal you will just have text logged somewhere (but only to one place as well) until session ends. It is very rare to see stale redirections: I have never seen them so far and never written something that leaves such redirections; and logging to some place with usual amount of messages is not too harmful. Thus advantages are greater then disadvantages.
To diagnose the issue :redir (without arguments) should print the stack of places where redirected text will go in order; it will only be actually written to the one last position.
> - Yasuhiro Matsumoto
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.
- << Previous post in topic Next post in topic >>