diff options
-rw-r--r-- | .emacs.d/init.el | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el index fb31801b..ad2c90d5 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -3577,15 +3577,21 @@ mutt's review view, after exiting EDITOR." (spw/feature-define-keys ((esh-mode eshell-mode-map)) "\C-z\C-c" spw/eshell-git-continue "\C-z\C-v" spw/eshell-git-abort) -;; C-z C-v to discard changes, though without saving the modified buffer. +;; C-z C-v to discard changes. +;; Save only buffers that weren't already modified. (defun spw/diff-discard-hunk () (interactive) - (let ((beg (point)) - (diff-advance-after-apply-hunk t)) + (let* ((beg (point)) + (diff-advance-after-apply-hunk t) + (buffer (car (diff-find-source-location))) + (to-save (and (not (buffer-modified-p buffer)) buffer))) (diff-apply-hunk t) (unless (= beg (point)) (diff-hunk-next -1) - (diff-hunk-kill)))) + (diff-hunk-kill)) + (when to-save + (with-current-buffer to-save + (basic-save-buffer))))) (spw/feature-define-keys diff-mode "\C-z\C-v" spw/diff-discard-hunk) (defun spw/vc-next-action-for-git-fixup () |