Emacs, the editor that never ceases to amaze me, has a feature that may be useful to everyone using diff(1) implementations that don’t have all the features of modern, featureful diff(1) utilities (i.e. GNU diff).
One of the usual grievances of having to use the diff(1) utility on Solaris is that it doesn’t support recursively diffing two directories, and it doesn’t support “unified” diffs. The first one can probably be solved with hackery around find(1), but the second is not so easy to hack around.
Fortunately, Emacs has a “
diff-mode” that is automatically enabled when you edit a file whose extension is “
.diff“. After you create a patch file with Solaris diff(1), you can easily toggle between “unified” and “context” diff mode in an Emacs buffer using the commands:
These are bound to the keys
M-C respectively (or, equivalently,
ESC-C in some environments), so they are only a couple of keystrokes away when you are editing patch files with Emacs. Maximum coolness :-)
This tip is one of the many useful Emacs tricks I have learned from watching the emacs-devel mailing list. It was posted there in message:
by Stefan Monnier. Thanks, Stefan!