/[emacs]/emacs/lisp/smerge-mode.el
ViewVC logotype

Diff of /emacs/lisp/smerge-mode.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.16 by monnier, Thu Aug 15 00:24:56 2002 UTC revision 1.17 by monnier, Tue Sep 3 01:20:20 2002 UTC
# Line 54  Line 54 
54    :group 'tools    :group 'tools
55    :prefix "smerge-")    :prefix "smerge-")
56    
57  (defcustom smerge-diff-buffer-name "*smerge-diff*"  (defcustom smerge-diff-buffer-name "*vc-diff*"
58    "Buffer name to use for displaying diffs."    "Buffer name to use for displaying diffs."
59    :group 'smerge    :group 'smerge
60    :type '(choice    :type '(choice
# Line 183  Can be nil if the style is undecided, or Line 183  Can be nil if the style is undecided, or
183  ;; Compiler pacifiers  ;; Compiler pacifiers
184  (defvar font-lock-mode)  (defvar font-lock-mode)
185  (defvar font-lock-keywords)  (defvar font-lock-keywords)
 (eval-when-compile  
   (unless (fboundp 'font-lock-fontify-region)  
     (autoload 'font-lock-fontify-region "font-lock")))  
186    
187  ;;;;  ;;;;
188  ;;;; Actual code  ;;;; Actual code
# Line 218  Convenient for the kind of conflicts tha Line 215  Convenient for the kind of conflicts tha
215                   t t)                   t t)
216    (smerge-auto-leave))    (smerge-auto-leave))
217    
218    (defun smerge-combine-with-next ()
219      "Combine the current conflict with the next one."
220      (interactive)
221      (smerge-match-conflict)
222      (let ((ends nil))
223        (dolist (i '(3 2 1 0))
224          (push (if (match-end i) (copy-marker (match-end i) t)) ends))
225        (setq ends (apply 'vector ends))
226        (goto-char (aref ends 0))
227        (if (not (re-search-forward smerge-begin-re nil t))
228            (error "No next conflict")
229          (smerge-match-conflict)
230          (let ((match-data (mapcar (lambda (m) (if m (copy-marker m)))
231                                    (match-data))))
232            ;; First copy the in-between text in each alternative.
233            (dolist (i '(1 2 3))
234              (when (aref ends i)
235                (goto-char (aref ends i))
236                (insert-buffer-substring (current-buffer)
237                                         (aref ends 0) (car match-data))))
238            (delete-region (aref ends 0) (car match-data))
239            ;; Then move the second conflict's alternatives into the first.
240            (dolist (i '(1 2 3))
241              (set-match-data match-data)
242              (when (and (aref ends i) (match-end i))
243                (goto-char (aref ends i))
244                (insert-buffer-substring (current-buffer)
245                                         (match-beginning i) (match-end i))))
246            (delete-region (car match-data) (cadr match-data))
247            ;; Free the markers.
248            (dolist (m match-data) (if m (move-marker m nil)))
249            (mapc (lambda (m) (if m (move-marker m nil))) ends)))))
250    
251  (defun smerge-keep-base ()  (defun smerge-keep-base ()
252    "Revert to the base version."    "Revert to the base version."
253    (interactive)    (interactive)
# Line 360  The point is moved to the end of the con Line 390  The point is moved to the end of the con
390          (dir default-directory)          (dir default-directory)
391          (file (file-relative-name buffer-file-name))          (file (file-relative-name buffer-file-name))
392          (coding-system-for-read buffer-file-coding-system))          (coding-system-for-read buffer-file-coding-system))
393      (write-region beg1 end1 file1)      (write-region beg1 end1 file1 nil 'nomessage)
394      (write-region beg2 end2 file2)      (write-region beg2 end2 file2 nil 'nomessage)
395      (unwind-protect      (unwind-protect
396          (with-current-buffer (get-buffer-create smerge-diff-buffer-name)          (with-current-buffer (get-buffer-create smerge-diff-buffer-name)
397            (setq default-directory dir)            (setq default-directory dir)
398            (let ((inhibit-read-only t))            (let ((inhibit-read-only t))
399              (erase-buffer)              (erase-buffer)
400              (apply 'call-process diff-command nil t nil              (let ((status
401                     (append smerge-diff-switches                     (apply 'call-process diff-command nil t nil
402                             (list "-L" (concat name1 "/" file)                            (append smerge-diff-switches
403                                   "-L" (concat name2 "/" file)                                    (list "-L" (concat name1 "/" file)
404                                   file1 file2))))                                          "-L" (concat name2 "/" file)
405                                            file1 file2)))))
406                  (if (eq status 0) (insert "No differences found.\n"))))
407            (goto-char (point-min))            (goto-char (point-min))
408            (diff-mode)            (diff-mode)
409            (display-buffer (current-buffer) t))            (display-buffer (current-buffer) t))
410        (delete-file file1)        (delete-file file1)
411        (delete-file file2))))        (delete-file file2))))
412    
413  (eval-when-compile  ;; compiler pacifiers
414    ;; compiler pacifiers  (defvar smerge-ediff-windows)
415    (defvar smerge-ediff-windows)  (defvar smerge-ediff-buf)
416    (defvar smerge-ediff-buf)  (defvar ediff-buffer-A)
417    (defvar ediff-buffer-A)  (defvar ediff-buffer-B)
418    (defvar ediff-buffer-B)  (defvar ediff-buffer-C)
   (defvar ediff-buffer-C)  
   (unless (fboundp 'ediff-cleanup-mess)  
     (autoload 'ediff-cleanup-mess "ediff-util")))  
419    
420  (defun smerge-ediff ()  (defun smerge-ediff ()
421    "Invoke ediff to resolve the conflicts."    "Invoke ediff to resolve the conflicts."

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26