aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/diff-mode.el
diff options
context:
space:
mode:
authorMiles Bader2000-10-02 06:50:45 +0000
committerMiles Bader2000-10-02 06:50:45 +0000
commit4eaa6852c9b55d05daf0a2f3ecc37c05121adf03 (patch)
tree7611b45c5523ab66247a323064919bcf25bbb2cb /lisp/diff-mode.el
parent00df919edec1fc3617ce8e92625a19c9a57d52e2 (diff)
downloademacs-4eaa6852c9b55d05daf0a2f3ecc37c05121adf03.tar.gz
emacs-4eaa6852c9b55d05daf0a2f3ecc37c05121adf03.zip
(diff-test-hunk): Backout previous change. Fix doc string.
(diff-apply-hunk): Don't return a value.
Diffstat (limited to 'lisp/diff-mode.el')
-rw-r--r--lisp/diff-mode.el43
1 files changed, 17 insertions, 26 deletions
diff --git a/lisp/diff-mode.el b/lisp/diff-mode.el
index a0293d0b3ff..f55536a98a3 100644
--- a/lisp/diff-mode.el
+++ b/lisp/diff-mode.el
@@ -4,7 +4,7 @@
4 4
5;; Author: Stefan Monnier <monnier@cs.yale.edu> 5;; Author: Stefan Monnier <monnier@cs.yale.edu>
6;; Keywords: patch diff 6;; Keywords: patch diff
7;; Revision: $Id: diff-mode.el,v 1.24 2000/09/29 18:05:27 monnier Exp $ 7;; Revision: $Id: diff-mode.el,v 1.25 2000/10/02 03:46:26 miles Exp $
8 8
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10 10
@@ -1019,15 +1019,13 @@ By default, the new source file is patched, but if the variable
1019patched instead (some commands, such as `diff-goto-source' can change 1019patched instead (some commands, such as `diff-goto-source' can change
1020the value of this variable when given an appropriate prefix argument). 1020the value of this variable when given an appropriate prefix argument).
1021 1021
1022With a prefix argument, REVERSE the hunk. 1022With a prefix argument, REVERSE the hunk."
1023
1024Return value is t if the hunk was sucessfully applied, `reversed' if the
1025hunk was applied backwards and nil if the hunk wasn't applied."
1026 (interactive "P") 1023 (interactive "P")
1027 (destructuring-bind (buf line-offset pos old new &optional switched) 1024 (destructuring-bind (buf line-offset pos old new &optional switched)
1028 (diff-find-source-location nil reverse) 1025 (diff-find-source-location nil reverse)
1029 (cond 1026 (cond
1030 ((null line-offset) (error "Can't find the text to patch")) 1027 ((null line-offset)
1028 (error "Can't find the text to patch"))
1031 ((and switched 1029 ((and switched
1032 ;; A reversed patch was detected, perhaps apply it in reverse 1030 ;; A reversed patch was detected, perhaps apply it in reverse
1033 (not (save-window-excursion 1031 (not (save-window-excursion
@@ -1037,36 +1035,29 @@ hunk was applied backwards and nil if the hunk wasn't applied."
1037 (if reverse 1035 (if reverse
1038 "Hunk hasn't been applied yet; apply it now? " 1036 "Hunk hasn't been applied yet; apply it now? "
1039 "Hunk has already been applied; undo it? "))))) 1037 "Hunk has already been applied; undo it? ")))))
1040 (message "(Nothing done)") 1038 (message "(Nothing done)"))
1041 nil)
1042 (t 1039 (t
1043 (let ((reversed (diff-xor switched reverse))) 1040 ;; Apply the hunk
1044 ;; Apply the hunk 1041 (with-current-buffer buf
1045 (with-current-buffer buf 1042 (goto-char pos)
1046 (goto-char pos) 1043 (delete-char (length (car old)))
1047 (delete-char (length (car old))) 1044 (insert (car new)))
1048 (insert (car new))) 1045 ;; Display BUF in a window
1049 ;; Display BUF in a window 1046 (set-window-point (display-buffer buf) (+ pos (cdr new)))
1050 (set-window-point (display-buffer buf) (+ pos (cdr new))) 1047 (diff-hunk-status-msg line-offset (diff-xor switched reverse) nil)
1051 (diff-hunk-status-msg line-offset reversed nil) 1048 (when diff-advance-after-apply-hunk
1052 (when diff-advance-after-apply-hunk 1049 (diff-hunk-next))))))
1053 (diff-hunk-next))
1054 (if reversed 'reversed t))))))
1055 1050
1056 1051
1057(defun diff-test-hunk (&optional reverse) 1052(defun diff-test-hunk (&optional reverse)
1058 ;; FIXME: is `reverse' ever useful ??? 1053 ;; FIXME: is `reverse' ever useful ???
1059 "See whether it's possible to apply the current hunk. 1054 "See whether it's possible to apply the current hunk.
1060With a prefix argument, try to REVERSE the hunk. 1055With a prefix argument, try to REVERSE the hunk."
1061Returns t if the hunk can be applied, `reversed' if it's already
1062applied and nil if it can't be found."
1063 (interactive "P") 1056 (interactive "P")
1064 (destructuring-bind (buf line-offset pos src dst &optional switched) 1057 (destructuring-bind (buf line-offset pos src dst &optional switched)
1065 (diff-find-source-location nil reverse) 1058 (diff-find-source-location nil reverse)
1066 (set-window-point (display-buffer buf) (+ pos (cdr src))) 1059 (set-window-point (display-buffer buf) (+ pos (cdr src)))
1067 (let ((reversed (diff-xor switched reverse))) 1060 (diff-hunk-status-msg line-offset (diff-xor reverse switched) t)))
1068 (diff-hunk-status-msg line-offset (diff-xor reverse switched) t)
1069 (if reversed 'reversed t))))
1070 1061
1071 1062
1072(defun diff-goto-source (&optional other-file) 1063(defun diff-goto-source (&optional other-file)