One thing that I find very tiring when I read the Mesa3D mailing list for my work at Igalia , is to read the patches that arrive as emails: they are too many and the mail clients do not highlight them. So far, I was using the thunderbird mail-client with the colored-diffs plugin that made them more readable, but it was quite slow and was breaking the appearance of the e-mails that were replies to a patch. Since, I never was a big fan of thunderbird (the list of the things I disliked about it was always longer than the list of the features I liked) I wanted to find a way to have the colored-diffs and the lightning plugins functionalities to a more lightweight gui-mail-client: the claws-mail.
Yesterday, I found this trick to make the claws-mail sync with my calendars and my contacts (so I don’t need the lightening plugin anymore \m/) so, today I was even more obsessed to improve the patches appearance: I wanted to find a trick to read them quickly in a more readable format and switch back to claws.
So, here’s the hack I finally did:
Claws-mail allows the users to create custom actions and run them on the e-mails. I created one that executes a perlscript that takes the e-mail file as input:
~/.claws-mail/my-custom-scripts/side-by-side-diff.pl %f &
The script can be found here. What it does is to split the patch file into two other files: one containing the additions and one the deletions in order to show them side-by-side with the icdiff. Since splitting a diff to see it with a diff viewer might sound funny to some people, if you aren’t obsessed with the side-by-side view you can just replace the script in the action with something like (g)vim -c "set syntax=diff" %f
or similar to have a unified highlighted diff view…
Now, each time I receive an e-mail and I see that it is a git patch, I open it and select: Tools->Action->side-by-side-diff. This is what happens:
The side-by-side view might look a bit weird with the highlight options I’ve passed to icdiff (you can modify them in the script) but I can see all the code changes immediately!
[Edited] Note: to use the side-by-side-diffs.pl as it is you need this vim plugin: https://www.vim.org/scripts/script.php?script_id=4979 otherwise you won’t be able to see the icdiff colors correctly. (Alternatively, you can modify the script to execute something like: xterm -l -hold -<other params you like> -e "icdiff -H $deletions $additions"
)