diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/custom-buffer-file.el | 22 | ||||
| -rw-r--r-- | modules/vc-config.el | 15 |
2 files changed, 21 insertions, 16 deletions
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 -------------------------- diff --git a/modules/vc-config.el b/modules/vc-config.el index 21a4380c..b9b61c29 100644 --- a/modules/vc-config.el +++ b/modules/vc-config.el @@ -123,6 +123,21 @@ interactive selection to jump to any changed line in the buffer." (require 'git-gutter) (consult-line "^[+\\-]")) +;; -------------------------------- Difftastic --------------------------------- +;; Structural diffs for better git change visualization + +(use-package difftastic + :demand t + :after magit + :bind (:map magit-blame-read-only-mode-map + ("D" . difftastic-magit-show) + ("S" . difftastic-magit-show)) + :config + (eval-after-load 'magit-diff + '(transient-append-suffix 'magit-diff '(-1 -1) + [("D" "Difftastic diff (dwim)" difftastic-magit-diff) + ("S" "Difftastic show" difftastic-magit-show)]))) + ;; --------------------------------- VC Keymap --------------------------------- ;; Ordering & sorting prefix and keymap |
