[PLUGIN] Lessdiff -> colourised diffs via less
John Arbash Meinel
john at arbash-meinel.com
Sat Dec 10 02:24:10 GMT 2005
Wouter van Heyst wrote:
> On Fri, Dec 09, 2005 at 04:51:28PM -0600, Michael Ellerman wrote:
> <snip>
>
>>>And a small hack on that to run it through 'vim -c "set syntax=diff" -'
>>>instead of PAGER. Next, trying to figure out why vim doesn't recognise
>>>bzr diff output currently.
>>
>>Could it be the colour cruft that colourdiff adds? Less barfs on that gear
>>unless you specifiy -R.
>
>
> No, it does the exact same thing with plain 'bzr diff'. I believe it is
> the format of the diff output being subtly different.
I thought the first line of a recursive diff was typically
diff FOO_STUFF
Having the first 4 characters of the file be "diff" seems to make it
pretty easy to autodetect the file type.
The other possibility is that the lines are:
--- <filename> Timestamp
This is what I found in /usr/share/vim/vim63/scripts.vim
elseif s:line1 =~ '^\(diff\>\|Only in \|\d\+\(,\d\+\)\=[cda]\d\+\>\|#
It was generated by makepatch \|Index:\s\+\f\+$\|===== \f\+ \d\+\.\d\+
vs edited\|==== //\f\+#\d\+\)'
\ || (s:line1 =~ '^--- ' && s:line2 =~ '^+++ ')
\ || (s:line1 =~ '^\*\*\* ' && s:line2 =~ '^--- ')
set ft=diff
And for some reason:
if getline(lnum) =~ '^Index:\s\+\f\+$'
set ft=diff
So it looks like if we want autodetect, you can have the first line
start with '--- ' and the second start with '+++ ', or the first with
'*** ', and the second '--- '
Or you can have the first line start with:
'diff'
'Only in '
'# It was generated by makepatch '
And a few others.
So back when we used to use "*** modified foo" instead of "=== modified
foo" vim did automatically detect the filetype.
I believe the reason we switched was because *** was used by context diffs.
John
=:->
>
>
>>Let me know if you get it working, we could come up with something less hacky,
>>and environment variable or something to choose vim.
>
>
> Will do.
>
> Wouter van Heyst
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051209/d6fdd7f9/attachment.pgp
More information about the bazaar
mailing list