diff options set to late to use autocommands in diffsplit

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

diff options set to late to use autocommands in diffsplit

Mikołaj Machowski
Hello,

Looks almost like a bug.

When doing :diffsplit diff option is set too late to make an influence
of autocommands like BufRead, BufReadPost, BufWinEnter.

'if &diff' hint from diff.txt is useful only when starting vimdiff.

m.

Reply | Threaded
Open this post in threaded view
|

Re: diff options set to late to use autocommands in diffsplit

Bram Moolenaar

Mikolaj Machowski wrote:

> Looks almost like a bug.
>
> When doing :diffsplit diff option is set too late to make an influence
> of autocommands like BufRead, BufReadPost, BufWinEnter.
>
> 'if &diff' hint from diff.txt is useful only when starting vimdiff.

Try this patch, is it sufficient?

*** src/diff.c~ Sat Jun 25 23:20:31 2005
--- src/diff.c Fri Jul 29 20:28:10 2005
***************
*** 1009,1014 ****
--- 1009,1015 ----
      {
  /* Pretend it was a ":split fname" command */
  eap->cmdidx = CMD_split;
+ curwin->w_p_diff = TRUE;
  do_exedit(eap, old_curwin);
 
  if (curwin != old_curwin) /* split must have worked */

--
DENNIS: Look,  strange women lying on their backs in ponds handing out
        swords ... that's no basis for a system of government.  Supreme
        executive power derives from a mandate from the masses, not from some
        farcical aquatic ceremony.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

Re: diff options set to late to use autocommands in diffsplit

Gary Johnson
In reply to this post by Mikołaj Machowski
On 2005-07-29, Mikolaj Machowski <[hidden email]> wrote:

> When doing :diffsplit diff option is set too late to make an influence
> of autocommands like BufRead, BufReadPost, BufWinEnter.
>
> 'if &diff' hint from diff.txt is useful only when starting vimdiff.

I'm not saying that it wouldn't be helpful if &diff was set a little
earlier than it is now, but there is a workaround:  you can use the
FilterWritePre event like this:

    au FilterWritePre * if &diff | set virtualedit=all | endif

This works for me whether I'm running vimdiff or executing
diffsplit.

HTH,
Gary

--
Gary Johnson                 | Agilent Technologies
[hidden email]     | Wireless Division
                             | Spokane, Washington, USA
Reply | Threaded
Open this post in threaded view
|

Re: diff options set to late to use autocommands in diffsplit

Mikołaj Machowski
In reply to this post by Bram Moolenaar
Dnia pi?tek 29 lipiec 2005 21:15, Bram Moolenaar napisa?:
> Mikolaj Machowski wrote:
> > Looks almost like a bug.
> >
> > When doing :diffsplit diff option is set too late to make an influence
> > of autocommands like BufRead, BufReadPost, BufWinEnter.
> >
> > 'if &diff' hint from diff.txt is useful only when starting vimdiff.
>
> Try this patch, is it sufficient?

No.

m.

Reply | Threaded
Open this post in threaded view
|

Re: diff options set to late to use autocommands in diffsplit

Bram Moolenaar

Mikolaj Machowski wrote:

> > > Looks almost like a bug.
> > >
> > > When doing :diffsplit diff option is set too late to make an influence
> > > of autocommands like BufRead, BufReadPost, BufWinEnter.
> > >
> > > 'if &diff' hint from diff.txt is useful only when starting vimdiff.
> >
> > Try this patch, is it sufficient?
>
> No.

Well, then you need to explain what you are doing.

Remember that one buffer is already loaded when you do ":diffsplit",
thus a BufRead autocommand for that buffer won't be triggered.  Only for
the newly opened buffer.

--
Mrs Abbott: I'm a paediatrician.
     Basil: Feet?
Mrs Abbott: Children.
     Sybil: Oh, Basil!
     Basil: Well, children have feet, don't they? That's how they move
            around, my dear. You must take a look next time, it's most
            interesting.                               (Fawlty Towers)

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

Re: diff options set to late to use autocommands in diffsplit

Mikołaj Machowski
Dnia sobota 30 lipiec 2005 12:52, Bram Moolenaar napisa?:
> Well, then you need to explain what you are doing.

OK. Gary Johnson's trick works for me.

m.