On 09-Jan-16, Bram Moolenaar wrote:
> 
> Christian Brabandt wrote:
> 
> > On Fr, 08 Jan 2016, Charles E Campbell wrote:
> > 
> > > Ben Fritz wrote:
> > > > On Friday, January 8, 2016 at 2:33:04 AM UTC-6, Christian Brabandt 
> > > > wrote:
> > > >> Having said that, I personally don't like the <restore> argument as 
> > > >> well. Perhaps we could use a new command modifier like
> > > >> :keeppos windo ...
> > > >>
> > > >> That could be useful for other commands as well.
> > > >>
> > > > I like that idea better as well.
> > > >
> > > I, too, like the "keeppos" (short for keepposn?) command modifier.
> > > 
> > > I agree that one shouldn't change the default behavior due to backwards
> > > compatability considerations.   My own plugins typically do a
> > > save&restore position and so wouldn't be affected by whether or not that
> > > default behavior changed.
> > > 
> > > One thing about keepposn, though: a lot of the save&restore position
> > > commands currently available keep the cursor in the same place in the
> > > text, but don't keep the text in the same position on the screen. 
> > > Consequently using these causes the text to bounce around, which IMHO is
> > > unacceptable.  For example,
> > > 
> > > :set ve=all
> > > :help getcurpos()
> > > :let scp= getcurpos()
> > > :norm! 4k4zl
> > > :call setpos('.',scp)
> > > 
> > > This set of operations restores the cursor position in the text, but
> > > does not restore the text position relative to the window.
> > 
> > Yes, that is the idea and that is what the <restore> argument already 
> > does. I believe however, that the :keeppos modifier is a lot more 
> > effort. I'll check this within the next week.
> 
> We could use either the <restore> argument or a :keeppos modifier.
> Both have advantages and disadvantages.  I think the problem with
> :keeppos is that this gives the idea that it works for all commands,
> while only a few commands will actually support it.
> On the other hand, for a command like :s, a <restore> argument isn't
> really possible, would need to use a flag, which means different
> commands have different ways to keep the position.

Then why not make the :keeppos modifier work for everything called with
it?

It could just be a shorthand for the equivalent of a winsaveview() /
winrestview() bracket around the command and everything it calls.  This
needs to be done for each window that is modified while :keeppos is in
effect.  The view information is saved internally in the window
structure.  And when a buffer is switched, the saved view is kept
associated with it (buf->b_wininfo) and the view of the switched-to
buffer is saved as well, and restored before switching away.

And the active window in each tab is marked and restored later.

Actually, the "last active window" could be determined with timestamps,
one for each window, updated when entering or leaving the window, and
locked against changes when :keeppos is in effect.

So when the command closes the active window, the previously active
window becomes the active window.

This could also be useful in scripts: get_mru_time(tabnr, winnr).

-- 
Olaf Dabrunz (oda <at> fctrace.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

--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui