summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2016-02-14 12:42:03 -0500
committerKyle Meyer <kyle@kyleam.com>2016-02-14 12:42:03 -0500
commitfcc18caef01aed2173ad77845bcd0e3c56a7754d (patch)
tree8e58cf8393523a6c74eb47b890bdbd88716ab79c
parent2ff55eb5efb4f1a4116d92ff25cd1d71831d1c33 (diff)
downloademacs.d-fcc18caef01aed2173ad77845bcd0e3c56a7754d.tar.gz
diff: Add diff-with-other-window command
-rw-r--r--init.el3
-rw-r--r--lisp/km-diff.el20
2 files changed, 17 insertions, 6 deletions
diff --git a/init.el b/init.el
index e7d7e99..674783d 100644
--- a/init.el
+++ b/init.el
@@ -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