]> git.eshelyaron.com Git - emacs.git/commitdiff
(diff-apply-hunk-to-backup-file): New var.
authorStefan Monnier <monnier@iro.umontreal.ca>
Mon, 11 Sep 2006 18:11:19 +0000 (18:11 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Mon, 11 Sep 2006 18:11:19 +0000 (18:11 +0000)
(diff-apply-hunk): Use it to ask for confirmation.

lisp/ChangeLog
lisp/diff-mode.el

index 5f3405576b785c2598e4f975ac255f2e9b1e87c8..ddada13d17b9d99e47dcf7fd8065ed89d1cf7e22 100644 (file)
@@ -1,3 +1,8 @@
+2006-09-11  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * diff-mode.el (diff-apply-hunk-to-backup-file): New var.
+       (diff-apply-hunk): Use it to ask for confirmation.
+
 2006-09-11  Reiner Steib  <Reiner.Steib@gmx.de>
 
        * emacs-lisp/cl.el (pushnew): Add missing `,'.
index 16bdaf152f735aaafe87ab043c968a4777492a59..01b3a5949f24dda611b703a76fbfc02e1185df96 100644 (file)
@@ -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