Christian wrote:

> On So, 08 Jun 2014, Bram Moolenaar wrote:
> 
> > Christian wrote:
> > 
> > > On So, 01 Jun 2014, Bram Moolenaar wrote:
> > > > When restoring clip_unnamed, it's not too dificult to set the
> > > > clipboard then.  Would require checking that it would have been set
> > > > (default register changed). Then the remarks about "doesn't work for
> > > > some commands" can be changed to "for some commands disabled until the
> > > > end". I'm sure this avoids surprises for users.
> > > 
> > > I am not sure how to do it.
> > 
> > This would require a flag, e.g. "did_set_selection".  When resetting
> > clip_unnamed before doing a global operation, this flag would be reset.
> > Then when text is deleted or yanked, clip_own_selection() will be
> > called, and if the register used matches the register that would be
> > associated with clip_unnamed, then set the "did_set_selection" flag.
> > When restoring clip_unnamed, check if "did_set_selection" was set, and
> > if it is call clip_own_selection() to get the current unnamed register
> > into the clipboard.
> > 
> > It's a bit sketchy, there are probably a few more details to work out,
> > but basically it would work to avoid putting text on the clipboard many
> > times and still end up with the correct clipboard contents in the end.
> > If we can make this work properly we can avoid users having to be aware
> > of this and just enjoy the much faster operation.
> 
> Okay, I think I understood. Here is a patch.

Almost.  This code now uses clip_did_set_selection for two purposes.  I
would reset clip_unnamed before calling global_exe(), where you set
clip_did_set_selection to FALSE.  Simlarly in ex_listdo().

Oh, and move the calls to clip_own_selection() to a function, instead of
copying this code to three places.  That function would then also
restore clip_unnamed.

For consistency the code to "start a sequence of global changes" would
be in one function, and that function containing clip_own_selection()
would be callend the "end" function.

So, something like:

        start_global_changes()
                clip_unnamed_saved = clip_unnamed;
                if (clip_unnamed)
                {
                    clip_unnamed = FALSE;
                    clip-did_set_selection = FALSE;
                }

        end_global_changes()
                if (clip_unnamed_saved)
                {
                    clip_unnamed = TRUE;
                    if (clip_did_set_selection)
                    {
                        if (clip_unnamed & CLIP_UNNAMED)
                            clip_own_selection(&clip_star);
                        else if (clip_unnamed & CLIP_UNNAMED_PLUS)
                            clip_own_selection(&clip_plus);
                    }
                }

Still sketchy.

For :global I think we can do this always, not only when ndone is large.

-- 
Microsoft: "Windows NT 4.0 now has the same user-interface as Windows 95"
    Windows 95: "Press CTRL-ALT-DEL to reboot"
Windows NT 4.0: "Press CTRL-ALT-DEL to login"

 /// Bram Moolenaar -- b...@moolenaar.net -- 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

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui