diff options
-rw-r--r-- | init.el | 3 | ||||
-rw-r--r-- | lisp/km-diff.el | 20 |
2 files changed, 17 insertions, 6 deletions
@@ -1444,7 +1444,8 @@ (use-package km-diff :defer t :init - (define-key km/external-map "o" #'km/ediff-with-other-window) + (define-key km/external-map "o" #'km/diff-with-other-window) + (define-key km/external-map "O" #'km/ediff-with-other-window) (after 'diff-mode (define-key diff-mode-map (kbd "C-c C-l") #'km/diff-lock-buffer))) diff --git a/lisp/km-diff.el b/lisp/km-diff.el index 05a8d0b..771cedf 100644 --- a/lisp/km-diff.el +++ b/lisp/km-diff.el @@ -21,6 +21,7 @@ ;;; Code: (require 'dash) +(require 'diff) (require 'ediff) ;;;###autoload @@ -32,10 +33,7 @@ (abbreviate-file-name (substring-no-properties (diff-find-file-name)))))) -;;;###autoload -(defun km/ediff-with-other-window () - "Run `ediff' on current window's file and other window's file." - (interactive) +(defun km/diff--with-other-window (diff-func) (let ((windows (window-list))) (unless (= (length windows) 2) (user-error "Function restricted to two-window frames")) @@ -43,8 +41,20 @@ (window-buffer (car windows)))) (file-b (buffer-file-name (window-buffer (cadr windows))))) - (ediff file-a file-b) + (funcall diff-func file-a file-b) (user-error "At least one buffer is not visiting a file")))) +;;;###autoload +(defun km/diff-with-other-window () + "Run `diff' on current window's file and other window's file." + (interactive) + (km/diff--with-other-window #'diff)) + +;;;###autoload +(defun km/ediff-with-other-window () + "Run `ediff' on current window's file and other window's file." + (interactive) + (km/diff--with-other-window #'ediff)) + (provide 'km-diff) ;;; km-diff.el ends here |