diff options
author | Stefan Monnier <[email protected]> | 2006-09-11 18:11:19 +0000 |
---|---|---|
committer | Stefan Monnier <[email protected]> | 2006-09-11 18:11:19 +0000 |
commit | cb9a30c8e11d907d002029e8b3bfc1bc846af1d5 (patch) | |
tree | eaacbd73af991fce5f12646fd0f73789b56bfa74 /lisp/diff-mode.el | |
parent | f489fc25190b6719dd28008b3ac85566cfc13e96 (diff) |
(diff-apply-hunk-to-backup-file): New var.
(diff-apply-hunk): Use it to ask for confirmation.
Diffstat (limited to 'lisp/diff-mode.el')
-rw-r--r-- | lisp/diff-mode.el | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lisp/diff-mode.el b/lisp/diff-mode.el index 16bdaf152f..01b3a5949f 100644 --- a/lisp/diff-mode.el +++ b/lisp/diff-mode.el @@ -1259,6 +1259,7 @@ SWITCHED is non-nil if the patch is already applied." (t "Hunk %s at offset %d lines")) msg line-offset))) +(defvar diff-apply-hunk-to-backup-file nil) (defun diff-apply-hunk (&optional reverse) "Apply the current hunk to the source file and go to the next. @@ -1275,6 +1276,17 @@ With a prefix argument, REVERSE the hunk." (cond ((null line-offset) (error "Can't find the text to patch")) + ((with-current-buffer buf + (and buffer-file-name + (backup-file-name-p buffer-file-name) + (not diff-apply-hunk-to-backup-file) + (not (set (make-local-variable 'diff-apply-hunk-to-backup-file) + (yes-or-no-p (format "Really apply this hunk to %s? " + (file-name-nondirectory + buffer-file-name))))))) + (error (substitute-command-keys + (format "Use %s\\[diff-apply-hunk] to apply it to the other file" + (if (not reverse) "\\[universal-argument] "))))) ((and switched ;; A reversed patch was detected, perhaps apply it in reverse. (not (save-window-excursion |