ediff is one of my favourite tools in Emacs and I have recently found myself not only using ediff-buffers and vc-ediff often but also now having the need to compare two regions.
For example, when developing new Elisp functions, I generally modify the bottom of my tangled init file and then evaluate/edit as necessary, or sometimes through the scratch buffer.
However, for something more complex, for example, at the moment, I am trying to generate an RSS feed from my Hugo-based blog's Org file through org-publish. In this case, I prefer creating a separate directory where I can experiment with example files, generated files, and temporarily manage everything under version control.
At the end of development, I could simply paste my function(s) back into my main configuration, however, as a software engineer, I am accustomed to using merging tools, so what better way to handle this than with ediff
Given my development functions and my init file, I can't compare entire files to copy/merge the changes across, and VC in this case is not helpful. So, how do I compare two regions? In fact, is it even possible in Emacs?
Well, yes, yes it is! (of course)
ediff-regions-linewise
Run Ediff on a pair of regions in specified buffers. BUFFER-A and BUFFER-B are the buffers to be compared. Regions (i.e., point and mark) can be set in advance or marked interactively. Each region is enlarged to contain full lines.