From aea61b34693f164ced731cf3b0f0e8ee798c342c Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 3 Nov 2025 16:10:13 -0600 Subject: feat: Upgrade diff-buffer-with-file to ediff and add difftastic for git MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two improvements for better diff experience: 1. **Upgraded cj/diff-buffer-with-file to use ediff** (custom-buffer-file.el) - Replaced basic unified diff with ediff-current-file - Now uses existing ediff config (horizontal split, j/k navigation) - C-; b D now launches interactive ediff instead of text diff - Simplified from 17 lines to 5 lines - Removed TODO comment about difftastic integration 2. **Added difftastic for git diffs** (vc-config.el) - Installed binary: difftastic 0.64.0 via pacman - Added difftastic.el package integrated with magit - Keybindings in magit-diff: - D → difftastic-magit-diff (dwim) - S → difftastic-magit-show - Provides structural, language-aware diffs for git changes - Better visualization of code structure changes **Result:** - Buffer vs file: Interactive ediff (can navigate, merge, revert) - Git history: Structural difftastic (language-aware visualization) - Right tool for each job Serves Method 3: "Make Fixing Emacs Frictionless" - Better diffs = easier debugging and code review Updated todo.org: Method 1 progress 7/13 (was 5/13) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- modules/custom-buffer-file.el | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'modules/custom-buffer-file.el') diff --git a/modules/custom-buffer-file.el b/modules/custom-buffer-file.el index 007fbe1a..105ed4ff 100644 --- a/modules/custom-buffer-file.el +++ b/modules/custom-buffer-file.el @@ -252,23 +252,13 @@ Do not save the deleted text in the kill ring." (message "Copied: %s" (buffer-name))) (defun cj/diff-buffer-with-file () - "Compare the current modified buffer with the saved version. -Uses unified diff format (-u) for better readability. -Signal an error if the buffer is not visiting a file. - -TODO: Future integration with difftastic for structural diffs (Method 3)." + "Compare the current modified buffer with the saved version using ediff. +Uses the same ediff configuration from diff-config.el (horizontal split, j/k navigation). +Signal an error if the buffer is not visiting a file." (interactive) - (let ((file-path (buffer-file-name))) - (cond - ((not file-path) - (user-error "Current buffer is not visiting a file")) - ((not (file-exists-p file-path)) - (user-error "File %s does not exist on disk" file-path)) - ((not (buffer-modified-p)) - (message "Buffer has no unsaved changes")) - (t - (let ((diff-switches "-u")) ; unified diff format - (diff-buffer-with-file (current-buffer))))))) + (if (buffer-file-name) + (ediff-current-file) + (user-error "Current buffer is not visiting a file"))) ;; --------------------------- Buffer And File Keymap -------------------------- -- cgit v1.2.3