Searching on Google, I found this website: https://www.dcode.fr/differences-2-texts. It allows "visually" comparing two text strings at the character level,
returning a result like this:
My question is: is there any function or package that allows doing the same thing directly in Emacs?
The function should take the two strings as arguments and return the "fontified" comparison string or show the result in a dedicated buffer.
I would need to use the function something like this:
(emacs-text-compare-bla-bla "String1" "String2" 'character-level)
without the need to manually select the strings to compare.
Note. I would really prefer to have a fontified string as output, like in the example, so that I can easily view/insert it without the need for additional buffers. If I were to have the output in a buffer, it should be a single window, not two as in the case of *diff*
functions.
I thought that perhaps I could use a function used internally by some tool used for diffing... but since I don't use Emacs for this type of operation, I have no idea where to start.
display-buffer-pop-up-frame
to justdisplay-buffer
. There should be a way to wedge in some word diff, too. – Martin R. Albrecht Feb 28 '24 at 16:43(buffer-string)
to get the content of theoutput-buffer
as a fontified string, then display that however you wish. – db48x Feb 28 '24 at 16:45diff
is that thediff-mode
does do refinement to a character–based diff. DoM-x customize-variable
and enterdiff-refine
to see the setting and the values it can have. – db48x Feb 28 '24 at 16:48(buffer-string)
but the function uses overlays so I lose the fontification. – Gabriele Feb 28 '24 at 18:12