'lazyredraw' not working

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

'lazyredraw' not working

Hari Krishna Dara

If I have a map that executes a :tselect command, and if I am executing
this map as a normal command in my script, I see the output of :tselect.
This is expected, but I want to hide it. If I use silent to execute the
map, :tselect command fails for some unknown reason, so I thought
setting 'lazyredraw' will prevent the output from appearing on the
screen, but vim seems to totally ignore it. Here is a sample of what I
am doing (jump to a tag before executing them):

" This will always select the second item in the taglist.
:nnoremap <F12> :set nomore<CR> \| :tselect<CR>2<CR> \| :set more<CR>
" This works, but shows the output.
:exec "normal \<F12>"
" This doesn't show the output, but doesn't work either.
:silent exec "normal \<F12>"
" This works, but lazyredraw has no effect
:set lazyredraw
:exec "normal \<F12>"
:set nolazyredraw

Does anyone know why 'lazyredraw' wouldn't work in this case? Is there
another way I can avoid showing the output of :tselect?

--
Thanks a lot,
Hari


               
__________________________________
Discover Yahoo!
Find restaurants, movies, travel and more fun for the weekend. Check it out!
http://discover.yahoo.com/weekend.html 

Reply | Threaded
Open this post in threaded view
|

Re: 'lazyredraw' not working

Eric Arnold


--- Hari Krishna Dara <[hidden email]> wrote:

>
> If I have a map that executes a :tselect command, and if I am executing
> this map as a normal command in my script, I see the output of :tselect.
> This is expected, but I want to hide it. If I use silent to execute the
> map, :tselect command fails for some unknown reason, so I thought
> setting 'lazyredraw' will prevent the output from appearing on the
> screen, but vim seems to totally ignore it. Here is a sample of what I

I can't quite tell but "lazyredraw" might be working as advertised,
if not as desired.  My understanding is that it defers updates until
the control is returned to the user, or some other condition that the
user is seeing the screen.  Thus, according to the help page:

        When this option is set, the screen will not be redrawn while
        executing macros, registers and other commands that have not been
        typed. Also, updating the window title is postponed.  To force an
        update use |:redraw|.

means, according to my best guess from what I've seen, is that it
will not redraw "while executing macros, registers and other commands"
as long as they all occur contiguously before the next
"user-sees-the-screen" condition.  So, I don't think it is intended
to not redraw between entering two   :ex   lines typed by the user,
regardless if they are "macros, registers ..." .

I've only seen the effect of "redraw" and "lazyredraw" inside the
execution of scripts.



> am doing (jump to a tag before executing them):
>
> " This will always select the second item in the taglist.
> :nnoremap <F12> :set nomore<CR> \| :tselect<CR>2<CR> \| :set more<CR>
.................................^^^^
This doesn't look right.  You could do something like:

        :nnoremap <F12> :set nomore \| tselect \| set more<CR>

or
        :nnoremap <F12> :set nomore<CR>:tselect<CR>2<CR>:set more<CR>

but not both the <CR>'s and the \| together like that.

> " This works, but shows the output.
> :exec "normal \<F12>"
> " This doesn't show the output, but doesn't work either.
> :silent exec "normal \<F12>"


This works for me, meaning it calls my function key, which is
a simple "echoerr":

        :map <F1> :echoerr "F1 pressed" \| echoerr "...more"<CR>
        :silent exec "normal \<F1>"

Note:  it does suppress the output from "echo" and "echomsg" but
not "echoerr", as you'd expect from "silent".  



> " This works, but lazyredraw has no effect
> :set lazyredraw
> :exec "normal \<F12>"
> :set nolazyredraw
>
> Does anyone know why 'lazyredraw' wouldn't work in this case? Is there
> another way I can avoid showing the output of :tselect?

See previous.

>
> --
> Thanks a lot,
> Hari
>
>
>
> __________________________________
> Discover Yahoo!
> Find restaurants, movies, travel and more fun for the weekend. Check it out!
> http://discover.yahoo.com/weekend.html 
>
>


Reply | Threaded
Open this post in threaded view
|

Re: 'lazyredraw' not working

Hari Krishna Dara
In reply to this post by Hari Krishna Dara

On Wed, 8 Jun 2005 at 7:57pm, Eric Arnold wrote:

[snip]

>
> I've only seen the effect of "redraw" and "lazyredraw" inside the
> execution of scripts.

I am indeed executing the map from inside a script. See below for a
modified version of the sample.

>
> > am doing (jump to a tag before executing them):
> >
> > " This will always select the second item in the taglist.
> > :nnoremap <F12> :set nomore<CR> \| :tselect<CR>2<CR> \| :set more<CR>
> .................................^^^^
> This doesn't look right.  You could do something like:
>
> :nnoremap <F12> :set nomore \| tselect \| set more<CR>
>
> or
> :nnoremap <F12> :set nomore<CR>:tselect<CR>2<CR>:set more<CR>
>
> but not both the <CR>'s and the \| together like that.

You are right I don't need the command separator, so it should be:

nnoremap <F12> :set nomore<CR>:tselect<CR>2<CR>:set more<CR>

But, for some reason the original still works (which is why I didn't
observe this mistake). In any case, this is just to demonstrate the
prboblem, in my script, I control more outside the map.

>
> > " This works, but shows the output.
> > :exec "normal \<F12>"
> > " This doesn't show the output, but doesn't work either.
> > :silent exec "normal \<F12>"
>
>
> This works for me, meaning it calls my function key, which is
> a simple "echoerr":
>
> :map <F1> :echoerr "F1 pressed" \| echoerr "...more"<CR>
> :silent exec "normal \<F1>"
>
> Note:  it does suppress the output from "echo" and "echomsg" but
> not "echoerr", as you'd expect from "silent".

Right, and I have several such usages. In fact, if I redirect the output
along with silent, I can actually see the :tagselect output, but it
ignores the input coming after the command ("2<CR>") if executed in the
silent mode.

> > " This works, but lazyredraw has no effect
> > :set lazyredraw
> > :exec "normal \<F12>"
> > :set nolazyredraw
> >
> > Does anyone know why 'lazyredraw' wouldn't work in this case? Is there
> > another way I can avoid showing the output of :tselect?
>
> See previous.

I am using 'lazyredraw' in a script, but it was an oversight on my part
that my sample doesn't do the same. Here it is again:

function! T()
set lazyredraw
exec "normal \<F12>"
set nolazyredraw
endfunction

:call T()

While executing the function T, I wouldn't expect to see the output of
:tselect scrolling on my screen (very clear if you pick a tag with lots
of hits). From what I understand, turning on 'lazyredraw' will result in
seeing the final effect of the script (or after the 'lazyredraw' is
turned off, or :redraw is explicitly done), instead of the intermediate
ones (something like an animation). I don't consider messaged echoed
onto the screen (which is what :tselect is doing) as part of the final
screen state, but I am ok even if the last screen of the :tselect shows
up. But the problem is when there are 500 matches to the :tselect
command and all the 500 matches scroll infront of me when the map
executed.

--
Thank you,
Hari


               
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail 
Reply | Threaded
Open this post in threaded view
|

Re: 'lazyredraw' not working

Eric Arnold


--- Hari Krishna Dara <[hidden email]> wrote:

>
> On Wed, 8 Jun 2005 at 7:57pm, Eric Arnold wrote:
>
> [snip]
>
> >
> > I've only seen the effect of "redraw" and "lazyredraw" inside the
> > execution of scripts.
>
> I am indeed executing the map from inside a script. See below for a
> modified version of the sample.
>
> >
> > > am doing (jump to a tag before executing them):
> > >
> > > " This will always select the second item in the taglist.
> > > :nnoremap <F12> :set nomore<CR> \| :tselect<CR>2<CR> \| :set more<CR>
> > .................................^^^^
> > This doesn't look right.  You could do something like:
> >
> > :nnoremap <F12> :set nomore \| tselect \| set more<CR>
> >
> > or
> > :nnoremap <F12> :set nomore<CR>:tselect<CR>2<CR>:set more<CR>
> >
> > but not both the <CR>'s and the \| together like that.
>
> You are right I don't need the command separator, so it should be:
>
> nnoremap <F12> :set nomore<CR>:tselect<CR>2<CR>:set more<CR>
>
> But, for some reason the original still works (which is why I didn't


It worked because it was sending more or less harmless characters as
user input (" ", "\", and "|").


> observe this mistake). In any case, this is just to demonstrate the
> prboblem, in my script, I control more outside the map.
>
>[...]
>
> While executing the function T, I wouldn't expect to see the output of
> :tselect scrolling on my screen (very clear if you pick a tag with lots
> of hits). From what I understand, turning on 'lazyredraw' will result in
> seeing the final effect of the script (or after the 'lazyredraw' is
> turned off, or :redraw is explicitly done), instead of the intermediate
> ones (something like an animation). I don't consider messaged echoed
> onto the screen (which is what :tselect is doing) as part of the final
> screen state, but I am ok even if the last screen of the :tselect shows
> up. But the problem is when there are 500 matches to the :tselect
> command and all the 500 matches scroll infront of me when the map
> executed.

First of all, if the scrolling you're seeing is in the command window,
all bets are off as to whether   &lazyredraw   operates down there
(nothing else is the same, anyway).  I doubt it does.  It's a lot more
primitive than the regular buffer windows.

The only way of capturing stuff from the command window that I know of
is  :redir @a  , which can't be used with   :silent   if you want any
output.  I've been wondering whether I'm missing some way of getting :ex
stuff directly into a buffer like   :.!   does.  I don't see a way of
entering Vim/ex syntax after the "!".  If there was a way to redirect
   :ex   output to a file, then that would be another way.  I'm
thinking Vim7 will solve all these problems.

If you're writing directly into a buffer, and you are seeing scrolling,
that's not happened for me.  Otherwise, if you're not writing to a
buffer, consider restructuring so that it can do   echo @a   and/or
$put @a   depending on what's needed.


Reply | Threaded
Open this post in threaded view
|

Re: 'lazyredraw' not working

Hari Krishna Dara
In reply to this post by Hari Krishna Dara

On Wed, 8 Jun 2005 at 10:06pm, Eric Arnold wrote:

[snip]

> >
> > While executing the function T, I wouldn't expect to see the output of
> > :tselect scrolling on my screen (very clear if you pick a tag with lots
> > of hits). From what I understand, turning on 'lazyredraw' will result in
> > seeing the final effect of the script (or after the 'lazyredraw' is
> > turned off, or :redraw is explicitly done), instead of the intermediate
> > ones (something like an animation). I don't consider messaged echoed
> > onto the screen (which is what :tselect is doing) as part of the final
> > screen state, but I am ok even if the last screen of the :tselect shows
> > up. But the problem is when there are 500 matches to the :tselect
> > command and all the 500 matches scroll infront of me when the map
> > executed.
>
> First of all, if the scrolling you're seeing is in the command window,
> all bets are off as to whether   &lazyredraw   operates down there
> (nothing else is the same, anyway).  I doubt it does.  It's a lot more
> primitive than the regular buffer windows.

That must be the distinguishing factor here. The 'lazyredraw' setting
must be taking effect only for screen updates in the regular windows.
Since the output of :tselect comes on to the command-line (which is
distinguishable from command-window, which is also more or less a
regular buffer/window), the redraw's are not being delayed.

>
> The only way of capturing stuff from the command window that I know of
> is  :redir @a  , which can't be used with   :silent   if you want any
> output.  I've been wondering whether I'm missing some way of getting :ex
> stuff directly into a buffer like   :.!   does.  I don't see a way of
> entering Vim/ex syntax after the "!".  If there was a way to redirect
>    :ex   output to a file, then that would be another way.  I'm
> thinking Vim7 will solve all these problems.

I don't really want to "capture" the output, I just want to hide it. I
just tried :redir just to prove that even with silent, the :tselect is
getting exected giving the required output, and the problem is only with
accepting the input.

If have a function which captures the output of the ex command and
return it, you can use it along with an expression register to get the
output directly into a buffer. Something like this:

iabbr \LS\ <C-R>=GetVimCmdOutput('ls')<CR>

The GetVimCmdOutput function (which is an actual function from
genutils.vim) would return the output of :ls command. I have an
abbreviation that uses the same technique to capture the output of ":ta
<tag>" and extract some part and insert it in place (I think, vim7 has
some functions to access tag information directly, so this would be much
simpler to do).

>
> If you're writing directly into a buffer, and you are seeing scrolling,
> that's not happened for me.  Otherwise, if you're not writing to a
> buffer, consider restructuring so that it can do   echo @a   and/or
> $put @a   depending on what's needed.

Yes I said before, I am just trying to hide the output, I don't need to
process the output, so don't need to capture it.

--
Thanks,
Hari


               
__________________________________
Discover Yahoo!
Get on-the-go sports scores, stock quotes, news and more. Check it out!
http://discover.yahoo.com/mobile.html