summaryrefslogtreecommitdiff
path: root/text-conf.el
diff options
context:
space:
mode:
Diffstat (limited to 'text-conf.el')
-rw-r--r--text-conf.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/text-conf.el b/text-conf.el
index c25a2bf..a035593 100644
--- a/text-conf.el
+++ b/text-conf.el
@@ -124,5 +124,26 @@ If ARG is non-nil, use a more verbose format."
(define-key global-map (vector ?\H-=) #'durand-insert-timestamp)
+;; a diff-dwim
+
+;;;###autoload
+(defun durand-diff-dwim (&optional arg)
+ "Run `diff-buffer-with-file' or `vc-diff'."
+ (interactive "P")
+ (cond
+ ((and (or (not (buffer-modified-p))
+ (equal arg (list 16)))
+ (vc-registered (buffer-file-name)))
+ (vc-diff arg t))
+ ((buffer-modified-p)
+ (diff-buffer-with-file
+ (cond
+ (arg (read-buffer "Choose a buffer to diff: "
+ (current-buffer) t))
+ ((current-buffer)))))
+ ((user-error "No reasonable way to diff"))))
+
+(define-key global-map (vector ?\C-\M-=) #'durand-diff-dwim)
+
(provide 'text-conf)
;;; text-conf.el ends here.