aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2007-07-20 20:41:58 +0000
committerStefan Monnier2007-07-20 20:41:58 +0000
commit74dea9e1c1ca344e0542cfbd751707641d69375e (patch)
tree73b7324475f4999526e05b1fb786fb33a10713ac
parentbb042dc6fab52bd691b520b03ee61be7718664c0 (diff)
downloademacs-74dea9e1c1ca344e0542cfbd751707641d69375e.tar.gz
emacs-74dea9e1c1ca344e0542cfbd751707641d69375e.zip
(change-log-resolve-conflict): Don't lose data if the merge fails.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/add-log.el37
2 files changed, 31 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index bf5b5da1be2..81e89689913 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12007-07-20 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * add-log.el (change-log-resolve-conflict): Don't lose data if the
4 merge fails.
5
12007-07-20 Dan Nicolaescu <dann@ics.uci.edu> 62007-07-20 Dan Nicolaescu <dann@ics.uci.edu>
2 7
3 * progmodes/compile.el (compilation-auto-jump-to-first-error): 8 * progmodes/compile.el (compilation-auto-jump-to-first-error):
diff --git a/lisp/add-log.el b/lisp/add-log.el
index 63212a75dc8..caea921d25f 100644
--- a/lisp/add-log.el
+++ b/lisp/add-log.el
@@ -1043,17 +1043,32 @@ Point is assumed to be at the start of the entry."
1043 1043
1044(defun change-log-resolve-conflict () 1044(defun change-log-resolve-conflict ()
1045 "Function to be used in `smerge-resolve-function'." 1045 "Function to be used in `smerge-resolve-function'."
1046 (let ((buf (current-buffer))) 1046 (save-excursion
1047 (with-temp-buffer 1047 (save-restriction
1048 (insert-buffer-substring buf (match-beginning 1) (match-end 1)) 1048 (narrow-to-region (match-beginning 0) (match-end 0))
1049 (save-match-data (change-log-mode)) 1049 (let ((mb1 (match-beginning 1))
1050 (let ((other-buf (current-buffer))) 1050 (me1 (match-end 1))
1051 (with-current-buffer buf 1051 (mb3 (match-beginning 3))
1052 (save-excursion 1052 (me3 (match-end 3))
1053 (save-restriction 1053 (tmp1 (generate-new-buffer " *changelog-resolve-1*"))
1054 (narrow-to-region (match-beginning 0) (match-end 0)) 1054 (tmp2 (generate-new-buffer " *changelog-resolve-2*")))
1055 (replace-match (match-string 3) t t) 1055 (unwind-protect
1056 (change-log-merge other-buf)))))))) 1056 (let ((buf (current-buffer)))
1057 (with-current-buffer tmp1
1058 (change-log-mode)
1059 (insert-buffer-substring buf mb1 me1))
1060 (with-current-buffer tmp2
1061 (change-log-mode)
1062 (insert-buffer-substring buf mb3 me3)
1063 ;; Do the merge here instead of inside `buf' so as to be
1064 ;; more robust in case change-log-merge fails.
1065 (change-log-merge tmp1))
1066 (goto-char (point-max))
1067 (delete-region (point-min)
1068 (prog1 (point)
1069 (insert-buffer-substring tmp2))))
1070 (kill-buffer tmp1)
1071 (kill-buffer tmp2))))))
1057 1072
1058;;;###autoload 1073;;;###autoload
1059(defun change-log-merge (other-log) 1074(defun change-log-merge (other-log)