Created
June 4, 2024 13:37
-
-
Save unhammer/f53f56a656da9489e5caffa389b18afb to your computer and use it in GitHub Desktop.
Hit C-x =, mark a region, C-M-c to confirm, mark a second region, C-M-c to confirm and you have an ediff of regions of the same buffer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun ediff--regions-samebuffer (ediff-regions &optional startup-hooks) | |
(let ((cloned-buffer (clone-indirect-buffer-other-window nil t))) | |
(unwind-protect | |
(funcall ediff-regions (current-buffer) cloned-buffer startup-hooks) | |
(kill-buffer cloned-buffer)))) | |
(defun ediff-regions-samebuffer (&optional wordwise startup-hooks) | |
"Ediff two regions of the same buffer, automating the clone-and-narrow dance. | |
Optional interactive argument WORDWISE to do a word-diff instead of line-by-line." | |
(interactive "P") | |
(if wordwise | |
(ediff--regions-samebuffer #'ediff-regions-wordwise startup-hooks) | |
(ediff--regions-samebuffer #'ediff-regions-linewise startup-hooks))) | |
(global-set-key (kbd "C-x =") #'ediff-regions-samebuffer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment