]> gitweb.michael.orlitzky.com - emacs.d.git/commitdiff
.emacs: replace diff-buffer-against-file
authorMichael Orlitzky <michael@orlitzky.com>
Sun, 8 Mar 2026 16:59:29 +0000 (12:59 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Sun, 8 Mar 2026 16:59:29 +0000 (12:59 -0400)
Newer versions of emacs essentially have diff-buffer-against-file
built in. There's a "diff-buffer-with-file" function, and its default
argument is the file name that corresponds to the buffer. So let's
just wrap that.

.emacs

diff --git a/.emacs b/.emacs
index 6f097721f2ea7f85dc30d2bb215e0e7d4ca20881..2b4762df1e865b78de5a3c954005370905b17abe 100644 (file)
--- a/.emacs
+++ b/.emacs
 ;; Never ask me anything, emacs.
 (setq save-abbrevs nil)
 
-(load-library "diff-buffer-against-file")
-(global-set-key "\C-cd" 'diff-buffer-against-file)
+;; Easily diff the current buffer against the file it arose from.
+;; Simply invokes diff-buffer-with-file with the default argument.
+(global-set-key "\C-cd" (
+  lambda()
+  (interactive)
+  (diff-buffer-with-file nil)
+))
+
 
 (load-library "latex-query-replace-regexp-math")