Commits

Anonymous committed d8514db

* ediff*el: replaced old-style backquotes.

* ediff-merge
(ediff-looks-like-combined-merge,ediff-get-combined-region):
changed to support the new format for ediff-combination-pattern.

* ediff-diff (ediff-set-fine-overlays-in-one-buffer):
changed to support the new format for ediff-combination-pattern.

* ediff.texi: Describe the new format for
ediff-combination-pattern.

Comments (0)

Files changed (9)

+1999-11-24  Michael Kifer  <kifer@cs.sunysb.edu>
+	
+	* ediff*el: replaced old-style backquotes.
+	
+	* ediff-merge
+	(ediff-looks-like-combined-merge,ediff-get-combined-region):
+	changed to support the new format for ediff-combination-pattern.
+	
+	* ediff-diff (ediff-set-fine-overlays-in-one-buffer):
+	changed to support the new format for ediff-combination-pattern.
+	
+	* ediff.texi: Describe the new format for
+	ediff-combination-pattern.
+		
 1999-11-01  Michael Kifer  <kifer@cs.sunysb.edu> 
 	
 	* ediff-diff.el (ediff-cmp-options): new var.
 	(ediff-same-file-contents): use ediff-cmp-options.
 	
-	* ediff-patch.el (ediff-prompt-for-patch-buffer,
+	* ediff-ptch.el (ediff-prompt-for-patch-buffer,
 	ediff-get-patch-buffer): use current buffer if it appears to be a
 	patch.
 	
 	      (ediff-overlay-put overl 'priority priority))
 	    fine-diff-vector)))
      
-;; This assumes buffer C and that the region looks like a combination of
-;; regions in buffer A and C.
+;; Set overlays over the regions that denote delimiters
 (defun ediff-set-fine-overlays-for-combined-merge (diff-list reg-num)
-  (let (overlay1 overlay2 overlay3)
-    (setq overlay1 (ediff-make-bullet-proof-overlay (nth 0 diff-list)
-						    (nth 1 diff-list)
-						    ediff-buffer-C)
-	  overlay2 (ediff-make-bullet-proof-overlay (nth 2 diff-list)
-						    (nth 3 diff-list)
-						    ediff-buffer-C)
-	  overlay3 (ediff-make-bullet-proof-overlay (nth 4 diff-list)
-						    (nth 5 diff-list)
-						    ediff-buffer-C))
-    (ediff-set-fine-diff-vector reg-num 'C (vector overlay1 overlay2 overlay3))
+  (let (overlay overlay-list)
+    (while diff-list
+      (condition-case nil
+	  (setq overlay
+		(ediff-make-bullet-proof-overlay
+		 (nth 0 diff-list) (nth 1 diff-list) ediff-buffer-C))
+	(error ""))
+      (setq overlay-list (cons overlay overlay-list))
+      (if (> (length diff-list) 1)
+	  (setq diff-list (cdr (cdr diff-list)))
+	(error "ediff-set-fine-overlays-for-combined-merge: corrupt list of
+delimiter regions"))
+      )
+    (setq overlay-list (reverse overlay-list))
+    (ediff-set-fine-diff-vector
+     reg-num 'C (apply 'vector overlay-list))
     ))
 	
     
 ;; 
 ;; Plagiarised from `emerge-defvar-local' for XEmacs.
 (defmacro ediff-defvar-local (var value doc) 
-  (` (progn
-       (defvar (, var) (, value) (, doc))
-       (make-variable-buffer-local '(, var))
-       (put '(, var) 'permanent-local t))))
+  `(progn
+     (defvar ,var ,value ,doc)
+     (make-variable-buffer-local ',var)
+     (put ',var 'permanent-local t)))
     
 
 
 
 ;;; Macros
 (defmacro ediff-odd-p (arg)
-  (` (eq (logand (, arg) 1) 1)))
+  `(eq (logand ,arg 1) 1))
 
 (defmacro ediff-buffer-live-p (buf)
-  (` (and (, buf) (get-buffer (, buf)) (buffer-name (get-buffer (, buf))))))
+  `(and ,buf (get-buffer ,buf) (buffer-name (get-buffer ,buf))))
 
 (defmacro ediff-get-buffer (arg)
-  (` (cond ((eq (, arg) 'A) ediff-buffer-A)
-	   ((eq (, arg) 'B) ediff-buffer-B)
-	   ((eq (, arg) 'C) ediff-buffer-C)
-	   ((eq (, arg) 'Ancestor) ediff-ancestor-buffer)
-	   )
-  ))
+  `(cond ((eq ,arg 'A) ediff-buffer-A)
+	 ((eq ,arg 'B) ediff-buffer-B)
+	 ((eq ,arg 'C) ediff-buffer-C)
+	 ((eq ,arg 'Ancestor) ediff-ancestor-buffer)
+	 ))
   
 (defmacro ediff-get-value-according-to-buffer-type (buf-type list)
-  (` (cond ((eq (, buf-type) 'A) (nth 0 (, list)))
-	   ((eq (, buf-type) 'B) (nth 1 (, list)))
-	   ((eq (, buf-type) 'C) (nth 2 (, list))))))
+  `(cond ((eq ,buf-type 'A) (nth 0 ,list))
+	 ((eq ,buf-type 'B) (nth 1 ,list))
+	 ((eq ,buf-type 'C) (nth 2 ,list))
+	 ))
 	   
 (defmacro ediff-char-to-buftype (arg)
-  (` (cond ((memq (, arg) '(?a ?A)) 'A)
-	   ((memq (, arg) '(?b ?B)) 'B)
-	   ((memq (, arg) '(?c ?C)) 'C)
-	   )
-  ))
+  `(cond ((memq ,arg '(?a ?A)) 'A)
+	 ((memq ,arg '(?b ?B)) 'B)
+	 ((memq ,arg '(?c ?C)) 'C)
+	 ))
 
 
 ;; A-list is supposed to be of the form (A . symb) (B . symb)...)
     (Ancestor . ediff-difference-vector-Ancestor)))
 
 (defmacro ediff-get-difference (n buf-type)
-  (` (aref
-      (symbol-value
-       (ediff-get-symbol-from-alist
-	(, buf-type) ediff-difference-vector-alist))
-      (, n))))
+  `(aref
+    (symbol-value
+     (ediff-get-symbol-from-alist
+      ,buf-type ediff-difference-vector-alist))
+    ,n))
   
 ;; Tell if it has been previously determined that the region has
 ;; no diffs other than the white space and newlines
 ;; state-of-difference is A, B, C, or nil, indicating which buffer is
 ;; 	different from the other two (used only in 3-way jobs).
 (defmacro ediff-no-fine-diffs-p (n)
-  (` (aref (ediff-get-difference (, n) 'A) 2)))
+  `(aref (ediff-get-difference ,n 'A) 2))
   
 (defmacro ediff-get-diff-overlay-from-diff-record (diff-rec)
-  (` (aref (, diff-rec) 0)))
+  `(aref ,diff-rec 0))
   
 (defmacro ediff-get-diff-overlay (n buf-type)  
-  (` (ediff-get-diff-overlay-from-diff-record
-      (ediff-get-difference (, n) (, buf-type)))))
+  `(ediff-get-diff-overlay-from-diff-record
+    (ediff-get-difference ,n ,buf-type)))
 
 (defmacro ediff-get-fine-diff-vector-from-diff-record (diff-rec)
-  (` (aref (, diff-rec) 1)))
+  `(aref ,diff-rec 1))
       
 (defmacro ediff-set-fine-diff-vector (n buf-type fine-vec)
-  (` (aset (ediff-get-difference (, n) (, buf-type)) 1 (, fine-vec))))
+  `(aset (ediff-get-difference ,n ,buf-type) 1 ,fine-vec))
   
 (defmacro ediff-get-state-of-diff (n buf-type)
-  (` (if (ediff-buffer-live-p ediff-buffer-C)
-	 (aref (ediff-get-difference (, n) (, buf-type)) 3))))
+  `(if (ediff-buffer-live-p ediff-buffer-C)
+       (aref (ediff-get-difference ,n ,buf-type) 3)))
 (defmacro ediff-set-state-of-diff (n buf-type val)
-  (` (aset (ediff-get-difference (, n) (, buf-type)) 3 (, val))))
+  `(aset (ediff-get-difference ,n ,buf-type) 3 ,val))
 
 (defmacro ediff-get-state-of-merge (n)
-  (` (if ediff-state-of-merge
-	 (aref (aref ediff-state-of-merge (, n)) 0))))
+  `(if ediff-state-of-merge
+       (aref (aref ediff-state-of-merge ,n) 0)))
 (defmacro ediff-set-state-of-merge (n val)
-  (` (if ediff-state-of-merge
-	 (aset (aref ediff-state-of-merge (, n)) 0 (, val)))))
+  `(if ediff-state-of-merge
+       (aset (aref ediff-state-of-merge ,n) 0 ,val)))
 
 (defmacro ediff-get-state-of-ancestor (n)
-  (` (if ediff-state-of-merge
-	 (aref (aref ediff-state-of-merge (, n)) 1))))
+  `(if ediff-state-of-merge
+       (aref (aref ediff-state-of-merge ,n) 1)))
 
 ;; if flag is t, puts a mark on diff region saying that 
 ;; the differences are in white space only.  If flag is nil,
 ;; the region is marked as essential (i.e., differences are
 ;; not just in the white space and newlines.)
 (defmacro ediff-mark-diff-as-space-only (n flag)
-  (` (aset (ediff-get-difference (, n) 'A) 2 (, flag))))
+  `(aset (ediff-get-difference ,n 'A) 2 ,flag))
   
 (defmacro ediff-get-fine-diff-vector (n buf-type)
-  (` (ediff-get-fine-diff-vector-from-diff-record
-      (ediff-get-difference (, n) (, buf-type)))))
+  `(ediff-get-fine-diff-vector-from-diff-record
+    (ediff-get-difference ,n ,buf-type)))
   
 ;; Macro to switch to BUFFER, evaluate BODY, returns to original buffer.
 ;; Doesn't save the point and mark.
 ;; This is `with-current-buffer' with the added test for live buffers."
 (defmacro ediff-with-current-buffer (buffer &rest body)
-  (` (if (ediff-buffer-live-p (, buffer))
+  `(if (ediff-buffer-live-p ,buffer)
        (save-current-buffer
-	 (set-buffer (, buffer))
-	 (,@ body))
+	 (set-buffer ,buffer)
+	 ,@body)
      (or (eq this-command 'ediff-quit)
 	 (error ediff-KILLED-VITAL-BUFFER))
-     )))
+     ))
      
 
 (defsubst ediff-multiframe-setup-p ()
   (and (ediff-window-display-p) ediff-multiframe))
 			 
 (defmacro ediff-narrow-control-frame-p ()
-  (` (and (ediff-multiframe-setup-p)
-	  (equal ediff-help-message ediff-brief-message-string))))
+  `(and (ediff-multiframe-setup-p)
+	(equal ediff-help-message ediff-brief-message-string)))
 	  
 (defmacro ediff-3way-comparison-job ()
-  (` (memq
-      ediff-job-name
-      '(ediff-files3 ediff-buffers3))))
+  `(memq
+    ediff-job-name
+    '(ediff-files3 ediff-buffers3)))
 (ediff-defvar-local ediff-3way-comparison-job nil "")
       
 (defmacro ediff-merge-job ()
-  (` (memq
-      ediff-job-name
-      '(ediff-merge-files
-	ediff-merge-buffers
-	ediff-merge-files-with-ancestor
-	ediff-merge-buffers-with-ancestor
-	ediff-merge-revisions
-	ediff-merge-revisions-with-ancestor))))
+  `(memq
+    ediff-job-name
+    '(ediff-merge-files
+      ediff-merge-buffers
+      ediff-merge-files-with-ancestor
+      ediff-merge-buffers-with-ancestor
+      ediff-merge-revisions
+      ediff-merge-revisions-with-ancestor)))
 (ediff-defvar-local ediff-merge-job nil "")
 
 (defmacro ediff-merge-with-ancestor-job ()
-  (` (memq
-      ediff-job-name
-      '(ediff-merge-files-with-ancestor
-	ediff-merge-buffers-with-ancestor
-	ediff-merge-revisions-with-ancestor))))
+  `(memq
+    ediff-job-name
+    '(ediff-merge-files-with-ancestor
+      ediff-merge-buffers-with-ancestor
+      ediff-merge-revisions-with-ancestor)))
 (ediff-defvar-local ediff-merge-with-ancestor-job nil "")
 
 (defmacro ediff-3way-job ()
-  (` (or ediff-3way-comparison-job ediff-merge-job)))
+  `(or ediff-3way-comparison-job ediff-merge-job))
 (ediff-defvar-local ediff-3way-job nil "")
 
 ;; A diff3 job is like a 3way job, but ediff-merge doesn't require the use
 ;; of diff3.
 (defmacro ediff-diff3-job ()
-  (` (or ediff-3way-comparison-job
-	 ediff-merge-with-ancestor-job)))
+  `(or ediff-3way-comparison-job
+       ediff-merge-with-ancestor-job))
 (ediff-defvar-local ediff-diff3-job nil "")
 	 
 (defmacro ediff-windows-job ()
-  (` (memq ediff-job-name '(ediff-windows-wordwise ediff-windows-linewise))))
+  `(memq ediff-job-name '(ediff-windows-wordwise ediff-windows-linewise)))
 (ediff-defvar-local ediff-windows-job nil "")
 
 (defmacro ediff-word-mode-job ()
-  (` (memq ediff-job-name '(ediff-windows-wordwise  ediff-regions-wordwise))))
+  `(memq ediff-job-name '(ediff-windows-wordwise ediff-regions-wordwise)))
 (ediff-defvar-local ediff-word-mode-job nil "")
 
 (defmacro ediff-narrow-job ()
-  (` (memq ediff-job-name '(ediff-windows-wordwise
-			    ediff-regions-wordwise
-			    ediff-windows-linewise
-			    ediff-regions-linewise))))
+  `(memq ediff-job-name '(ediff-windows-wordwise
+			  ediff-regions-wordwise
+			  ediff-windows-linewise
+			  ediff-regions-linewise)))
 (ediff-defvar-local ediff-narrow-job nil "")
 
 ;; Note: ediff-merge-directory-revisions-with-ancestor is not treated as an
 
 ;; Some installs don't have stipple or Stipple. So, try them in turn.
 (defvar stipple-pixmap
-  (cond ((not (ediff-has-face-support-p)))
+  (cond ((not (ediff-has-face-support-p)) nil)
 	((and (boundp 'x-bitmap-file-path)
 	      (locate-library "stipple" t x-bitmap-file-path)) "stipple")
 	((and (boundp 'mswindowsx-bitmap-file-path)
 	(t "Stipple")))
 
 (defface ediff-even-diff-face-A
-  (` ((((class color)) (:foreground "Black" :background "light grey"))
-      (t (:italic t :stipple (, stipple-pixmap)))))
+  `((((class color)) (:foreground "Black" :background "light grey"))
+    (t (:italic t :stipple ,stipple-pixmap)))
   "Face for highlighting even-numbered non-current differences in buffer A."
   :group 'ediff-highlighting)
 ;; An internal variable.  Ediff takes the face from here.  When unhighlighting,
 (ediff-hide-face 'ediff-even-diff-face-A)
 
 (defface ediff-even-diff-face-B
-  (` ((((class color)) (:foreground "White" :background "Grey"))
-      (t (:italic t :stipple (, stipple-pixmap)))))
+  `((((class color)) (:foreground "White" :background "Grey"))
+    (t (:italic t :stipple ,stipple-pixmap)))
   "Face for highlighting even-numbered non-current differences in buffer B."
   :group 'ediff-highlighting)
 ;; An internal variable.  Ediff takes the face from here.  When unhighlighting,
 (ediff-hide-face 'ediff-even-diff-face-B)
 
 (defface ediff-even-diff-face-C
-  (` ((((class color)) (:foreground "Black" :background "light grey"))
-      (t (:italic t :stipple (, stipple-pixmap)))))
+  `((((class color)) (:foreground "Black" :background "light grey"))
+    (t (:italic t :stipple ,stipple-pixmap)))
   "Face for highlighting even-numbered non-current differences in buffer C."
   :group 'ediff-highlighting)
 ;; An internal variable.  Ediff takes the face from here.  When unhighlighting,
 (ediff-hide-face 'ediff-even-diff-face-C)
 
 (defface ediff-even-diff-face-Ancestor
-  (` ((((class color)) (:foreground "White" :background "Grey"))
-      (t (:italic t :stipple (, stipple-pixmap)))))
+  `((((class color)) (:foreground "White" :background "Grey"))
+    (t (:italic t :stipple ,stipple-pixmap)))
   "Face for highlighting even-numbered non-current differences in the ancestor buffer."
   :group 'ediff-highlighting)
 ;; An internal variable.  Ediff takes the face from here.  When unhighlighting,
   :group 'ediff-merge)
 
 (defcustom ediff-combination-pattern 
-  '("<<<<<<<<<<<<<< variant A" ">>>>>>>>>>>>>> variant B" "======= end of combination")
+  '("<<<<<<< variant A" A ">>>>>>> variant B" B  "####### Ancestor" Ancestor "======= end")
   "*Pattern to be used for combining difference regions in buffers A and B.
-The value is (STRING1 STRING2 STRING3).  The combined text will look like this:
+The value must be a list of the form 
+(STRING1 bufspec1  STRING2 bufspec2 STRING3 bufspec3 STRING4)
+where bufspec is the symbol A, B, or Ancestor. For instance, if the value is
+'(STRING1 A  STRING2 Ancestor STRING3 B STRING4) then the
+combined text will look like this:
 
 STRING1
 diff region from variant A
 STRING2
+diff region from the ancestor
+STRING3
 diff region from variant B
-STRING3
+STRING4
 "
-  :type '(list string string string)
+  :type '(choice (list string symbol string symbol string)
+		 (list string symbol string symbol string symbol string))
   :group 'ediff-merge)
 
 (defcustom ediff-show-clashes-only nil
        (ediff-merge-changed-from-default-p n 'prefers-too)))
 
 
-	
-(defsubst ediff-get-combined-region (n)
-  (concat (nth 0 ediff-combination-pattern) "\n"
-	  (ediff-get-region-contents n 'A ediff-control-buffer)
-	  (nth 1 ediff-combination-pattern) "\n"
-	  (ediff-get-region-contents n 'B ediff-control-buffer)
-	  (nth 2 ediff-combination-pattern) "\n"))
+(defun ediff-get-combined-region (n)
+  (let ((pattern-list ediff-combination-pattern)
+	(combo-region "")
+	(err-msg
+	 "ediff-combination-pattern: Invalid format. Please consult the documentation")
+	diff-region region-delim region-spec)
 
-(defsubst ediff-make-combined-diff (regA regB)
-  (concat (nth 0 ediff-combination-pattern) "\n"
-	  regA
-	  (nth 1 ediff-combination-pattern) "\n"
-	  regB
-	  (nth 2 ediff-combination-pattern) "\n"))
+    (if (< (length pattern-list) 5)
+	(error err-msg))
+
+    (while (> (length pattern-list) 2)
+      (setq region-delim (nth 0 pattern-list)
+	    region-spec (nth 1 pattern-list))
+      (or (and (stringp region-delim) (memq region-spec '(A B Ancestor)))
+	  (error err-msg))
+
+      (condition-case err
+	  (setq combo-region
+		(concat combo-region
+			region-delim "\n"
+			(ediff-get-region-contents 
+			 n region-spec ediff-control-buffer)))
+	(error ""))
+      (setq pattern-list (cdr (cdr pattern-list)))
+      )
+
+    (setq region-delim (nth 0 pattern-list))
+    (or (stringp region-delim)
+	(error err-msg))
+    (setq combo-region (concat combo-region region-delim "\n"))
+  ))
+
+;;(defsubst ediff-make-combined-diff (regA regB)
+;;  (concat (nth 0 ediff-combination-pattern) "\n"
+;;	  regA
+;;	  (nth 1 ediff-combination-pattern) "\n"
+;;	  regB
+;;	  (nth 2 ediff-combination-pattern) "\n"))
 
 (defsubst ediff-set-state-of-all-diffs-in-all-buffers (ctl-buf)
   (let ((n 0))
   (setq n (if (numberp n) (1- n) ediff-current-difference))
   
   (let (regA regB reg-combined)
-    (setq regA (ediff-get-region-contents n 'A ediff-control-buffer)
-	  regB (ediff-get-region-contents n 'B ediff-control-buffer))
-    
-    (setq reg-combined (ediff-make-combined-diff regA regB))
+    ;;(setq regA (ediff-get-region-contents n 'A ediff-control-buffer)
+    ;;	  regB (ediff-get-region-contents n 'B ediff-control-buffer))
+    ;;(setq reg-combined (ediff-make-combined-diff regA regB))
+    (setq reg-combined (ediff-get-combined-region n))
     
     (ediff-copy-diff n nil 'C batch-invocation reg-combined))
     (or batch-invocation (ediff-jump-to-difference (1+ n))))
 
 ;; Checks if the region in buff C looks like a combination of the regions
 ;; in buffers A and B.  Return a list (reg-a-beg reg-a-end reg-b-beg reg-b-end)
-;; These refer to where the copies of region A and B start and end in buffer C
+;; These refer to where the delimiters for region A, B, Ancestor start and end
+;; in buffer C
 (defun ediff-looks-like-combined-merge (region-num)
   (if ediff-merge-job
       (let ((combined (string-match (regexp-quote "(A+B)")
 				    (or (ediff-get-state-of-diff region-num 'C)
 					"")))
-	    (reg-beg (ediff-get-diff-posn 'C 'beg region-num))
-	    (reg-end (ediff-get-diff-posn 'C 'end region-num))
-	    (pat1 (nth 0 ediff-combination-pattern))
-	    (pat2 (nth 1 ediff-combination-pattern))
-	    (pat3 (nth 2 ediff-combination-pattern))
-	    reg-a-beg reg-a-end reg-b-beg reg-b-end reg-c-beg reg-c-end)
+	    (mrgreg-beg (ediff-get-diff-posn 'C 'beg region-num))
+	    (mrgreg-end (ediff-get-diff-posn 'C 'end region-num))
+	    (pattern-list ediff-combination-pattern)
+	    delim reg-beg reg-end delim-regs-list)
 	
 	(if combined
 	    (ediff-with-current-buffer ediff-buffer-C
-	      (goto-char reg-beg)
-	      (search-forward pat1 reg-end 'noerror)
-	      (setq reg-a-beg (match-beginning 0))
-	      (setq reg-a-end (match-end 0))
-	      (search-forward pat2 reg-end 'noerror)
-	      (setq reg-b-beg (match-beginning 0))
-	      (setq reg-b-end (match-end 0))
-	      (search-forward pat3 reg-end 'noerror)
-	      (setq reg-c-beg (match-beginning 0))
-	      (setq reg-c-end (match-end 0))))
+	      (while pattern-list
+		(goto-char mrgreg-beg)
+		(setq delim (nth 0 pattern-list))
+		(search-forward delim mrgreg-end 'noerror)
+		(setq reg-beg (match-beginning 0))
+		(setq reg-end (match-end 0))
+		(if (and reg-beg reg-end)
+		    (setq delim-regs-list
+			  ;; in reverse
+			  (cons reg-end (cons reg-beg delim-regs-list))))
+		(if (> (length pattern-list) 1)
+		    (setq pattern-list (cdr (cdr pattern-list)))
+		  (setq pattern-list nil))
+		)))
+
+	(reverse delim-regs-list)
+	)))
 	
-	(if (and reg-a-beg reg-a-end reg-b-beg reg-b-end)
-	    (list reg-a-beg reg-a-end reg-b-beg reg-b-end reg-c-beg reg-c-end))
-	)))
-
 
 ;; Check if the non-preferred merge has been modified since originally set.
 ;; This affects only the regions that are marked as default-A/B or combined.
 	(and (string= state-of-merge "default-B")
 	     (not (string= reg-B reg-C)))
 	(and (string= state-of-merge "combined")
-	     (not (string= (ediff-make-combined-diff reg-A reg-B) reg-C)))
+	     ;;(not (string= (ediff-make-combined-diff reg-A reg-B) reg-C)))
+	     (not (string= (ediff-get-combined-region diff-num) reg-C)))
 	(and prefers-too
 	     (string= state-of-merge "prefer-A")
 	     (not (string= reg-A reg-C)))
 		ediff-session-action-function
 		ediff-metajob-name 
 		;; make it update (car info) after startup
-		(` (list (lambda () 
-			   ;; child session group should know its parent
-			   (setq ediff-parent-meta-buffer
-				 (quote (, ediff-meta-buffer))
-				 ediff-meta-session-number
-				 (, session-number))
-			   ;; and parent will know its child
-			   (setcar (quote (, info)) ediff-meta-buffer)))))))
+		`(list (lambda () 
+			 ;; child session group should know its parent
+			 (setq ediff-parent-meta-buffer
+			       (quote ,ediff-meta-buffer)
+			       ediff-meta-session-number
+			       ,session-number)
+			 ;; and parent will know its child
+			 (setcar (quote ,info) ediff-meta-buffer))))))
 
 	    ;; Do ediff-revision on a subdirectory
 	    ((and (ediff-one-filegroup-metajob)
 		file1 regexp
 		ediff-session-action-function ediff-metajob-name
 		;; make it update (car info) after startup
-		(` (list (lambda () 
-			   ;; child session group should know its parent and
-			   ;; its number
-			   (setq ediff-parent-meta-buffer
-				 (quote (, ediff-meta-buffer))
-				 ediff-meta-session-number
-				 (, session-number))
-			   ;; and parent will know its child
-			   (setcar (quote (, info)) ediff-meta-buffer)))))))
+		`(list (lambda () 
+			 ;; child session group should know its parent and
+			 ;; its number
+			 (setq ediff-parent-meta-buffer
+			       (quote ,ediff-meta-buffer)
+			       ediff-meta-session-number
+			       ,session-number)
+			 ;; and parent will know its child
+			 (setcar (quote ,info) ediff-meta-buffer))))))
 
 	    ;; From here on---only individual session handlers
 
 		 (ediff-merge-files
 		  file1 file2
 		  ;; provide startup hooks 
-		  (` (list (lambda () 
+		  `(list (lambda () 
 			     (add-hook
 			      'ediff-after-quit-hook-internal
 			      (lambda ()
-				(if (ediff-buffer-live-p (, (current-buffer)))
+				(if (ediff-buffer-live-p ,(current-buffer))
 				    (ediff-show-meta-buffer
-				     (, (current-buffer)) (, session-number))))
+				     ,(current-buffer) ,session-number)))
 			      nil 'local)
-			     (setq ediff-meta-buffer (, (current-buffer))
+			     (setq ediff-meta-buffer ,(current-buffer)
 				   ediff-meta-session-number
-				   (, session-number))
+				   ,session-number)
 			     (setq ediff-merge-store-file
-				   (, (if (ediff-nonempty-string-p
-					   merge-autostore-dir)
-					  (concat
-					   merge-autostore-dir
-					   "merge_"
-					   (file-name-nondirectory file1)))
+				   ,(if (ediff-nonempty-string-p
+					 merge-autostore-dir)
+					(concat
+					 merge-autostore-dir
+					 "merge_"
+					 (file-name-nondirectory file1))
 				      ))
 			     ;; make ediff-startup pass
 			     ;; ediff-control-buffer back to the meta
 			     ;; level; see below
 			     (setcar
-			      (quote (, info)) ediff-control-buffer)))))
+			      (quote ,info) ediff-control-buffer))))
 	       (error "Aborted")))
 	    ((ediff-one-filegroup-metajob) 	; needs 1 file arg
 	     (funcall ediff-session-action-function
 		      file1
 		      ;; provide startup hooks 
-		      (` (list (lambda () 
-				 (add-hook
-				  'ediff-after-quit-hook-internal
-				  (lambda ()
-				    (if (ediff-buffer-live-p
-					 (, (current-buffer)))
-					(ediff-show-meta-buffer
-					 (, (current-buffer))
-					 (, session-number))))
-				  nil 'local)
-				 (setq ediff-meta-buffer (, (current-buffer))
-				       ediff-meta-session-number
-				       (, session-number))
-				 (setq ediff-merge-store-file
-				       (, (if (ediff-nonempty-string-p
-					       merge-autostore-dir)
-					      (concat
-					       merge-autostore-dir
-					       "merge_"
-					       (file-name-nondirectory file1)))
-					  ))
-				 ;; make ediff-startup pass
-				 ;; ediff-control-buffer back to the meta
-				 ;; level; see below
-				 (setcar
-				  (quote (, info)) ediff-control-buffer))))))
+		      `(list (lambda () 
+			       (add-hook
+				'ediff-after-quit-hook-internal
+				(lambda ()
+				  (if (ediff-buffer-live-p
+				       ,(current-buffer))
+				      (ediff-show-meta-buffer
+				       ,(current-buffer)
+				       ,session-number)))
+				nil 'local)
+			       (setq ediff-meta-buffer ,(current-buffer)
+				     ediff-meta-session-number
+				     ,session-number)
+			       (setq ediff-merge-store-file
+				     ,(if (ediff-nonempty-string-p
+					   merge-autostore-dir)
+					  (concat
+					   merge-autostore-dir
+					   "merge_"
+					   (file-name-nondirectory file1))) )
+			       ;; make ediff-startup pass
+			       ;; ediff-control-buffer back to the meta
+			       ;; level; see below
+			       (setcar
+				(quote ,info) ediff-control-buffer)))))
 	    ((not (ediff-metajob3))      ; need 2 file args
 	     (funcall ediff-session-action-function
 		      file1 file2
 		      ;; provide startup hooks 
-		      (` (list (lambda () 
-				 (add-hook
-				  'ediff-after-quit-hook-internal
-				  (lambda ()
-				    (if (ediff-buffer-live-p
-					 (, (current-buffer)))
-					(ediff-show-meta-buffer
-					 (, (current-buffer))
-					 (, session-number))))
-				  nil 'local)
-				 (setq ediff-meta-buffer (, (current-buffer))
-				       ediff-meta-session-number
-				       (, session-number))
-				 (setq ediff-merge-store-file
-				       (, (if (ediff-nonempty-string-p
-					       merge-autostore-dir)
-					      (concat
-					       merge-autostore-dir
-					       "merge_"
-					       (file-name-nondirectory file1)))
-					  ))
-				 ;; make ediff-startup pass
-				 ;; ediff-control-buffer back to the meta
-				 ;; level; see below
-				 (setcar
-				  (quote (, info)) ediff-control-buffer))))))
+		      `(list (lambda () 
+			       (add-hook
+				'ediff-after-quit-hook-internal
+				(lambda ()
+				  (if (ediff-buffer-live-p
+				       ,(current-buffer))
+				      (ediff-show-meta-buffer
+				       ,(current-buffer)
+				       ,session-number)))
+				nil 'local)
+			       (setq ediff-meta-buffer ,(current-buffer)
+				     ediff-meta-session-number
+				     ,session-number)
+			       (setq ediff-merge-store-file
+				     ,(if (ediff-nonempty-string-p
+					   merge-autostore-dir)
+					  (concat
+					   merge-autostore-dir
+					   "merge_"
+					   (file-name-nondirectory file1))) )
+			       ;; make ediff-startup pass
+			       ;; ediff-control-buffer back to the meta
+			       ;; level; see below
+			       (setcar
+				(quote ,info) ediff-control-buffer)))))
 	    ((ediff-metajob3)      ; need 3 file args
 	     (funcall ediff-session-action-function
 		      file1 file2 file3
 		      ;; arrange startup hooks 
-		      (` (list (lambda () 
-				 (add-hook
-				  'ediff-after-quit-hook-internal
-				  (lambda ()
-				    (if (ediff-buffer-live-p
-					 (, (current-buffer)))
-					(ediff-show-meta-buffer
-					 (, (current-buffer))
-					 (, session-number))))
-				  nil 'local)
-				 (setq ediff-merge-store-file
-				       (, (if (ediff-nonempty-string-p
-					       merge-autostore-dir)
-					      (concat
-					       merge-autostore-dir
-					       "merge_"
-					       (file-name-nondirectory file1)))
-					  ))
-				 (setq ediff-meta-buffer (, (current-buffer))
-				       ediff-meta-session-number
-				       (, session-number))
-				 ;; this arranges that ediff-startup will pass
-				 ;; the value of ediff-control-buffer back to
-				 ;; the meta level, to the record in the meta
-				 ;; list containing the information about the
-				 ;; session associated with that
-				 ;; ediff-control-buffer
-				 (setcar
-				  (quote (, info)) ediff-control-buffer))))))
+		      `(list (lambda () 
+			       (add-hook
+				'ediff-after-quit-hook-internal
+				(lambda ()
+				  (if (ediff-buffer-live-p
+				       ,(current-buffer))
+				      (ediff-show-meta-buffer
+				       ,(current-buffer)
+				       ,session-number)))
+				nil 'local)
+			       (setq ediff-merge-store-file
+				     ,(if (ediff-nonempty-string-p
+					   merge-autostore-dir)
+					  (concat
+					   merge-autostore-dir
+					   "merge_"
+					   (file-name-nondirectory file1))) )
+			       (setq ediff-meta-buffer , (current-buffer)
+				     ediff-meta-session-number
+				     ,session-number)
+			       ;; this arranges that ediff-startup will pass
+			       ;; the value of ediff-control-buffer back to
+			       ;; the meta level, to the record in the meta
+			       ;; list containing the information about the
+			       ;; session associated with that
+			       ;; ediff-control-buffer
+			       (setcar
+				(quote ,info) ediff-control-buffer)))))
 	    ) ; cond
       ) ; eval in meta-buf
     ))
     (setq startup-hooks
 	  ;; this sets various vars in the meta buffer inside
 	  ;; ediff-prepare-meta-buffer
-	  (cons (` (lambda ()
-		     ;; tell what to do if the user clicks on a session record
-		     (setq ediff-session-action-function
-			   'ediff-patch-file-form-meta
-			   ediff-meta-patchbufer patch-buf)
-		     ))
+	  (cons `(lambda ()
+		   ;; tell what to do if the user clicks on a session record
+		   (setq ediff-session-action-function
+			 'ediff-patch-file-form-meta
+			 ediff-meta-patchbufer patch-buf) )
 		startup-hooks))
     (setq meta-buf (ediff-prepare-meta-buffer 
 		    'ediff-filegroup-action
       (setq rev2buf (current-buffer)
 	    file2 (buffer-file-name)))
     (setq startup-hooks
-	  (cons (` (lambda ()
-		     (delete-file (, file1))
-		     (or (, (string= rev2 "")) (delete-file (, file2)))
-		     ))
+	  (cons `(lambda ()
+		   (delete-file ,file1)
+		   (or ,(string= rev2 "") (delete-file ,file2)))
 		startup-hooks))
     (ediff-buffers
      rev1buf rev2buf
 	  (setq ancestor-buf (current-buffer))))
     (setq startup-hooks 
 	  (cons 
-	   (` (lambda () 
-		(delete-file (, (buffer-file-name buf1)))
-		(or (, (string= rev2 ""))
-		    (delete-file (, (buffer-file-name buf2))))
-		(or (, (string= ancestor-rev ""))
-		    (, (not ancestor-rev))
-		    (delete-file (, (buffer-file-name ancestor-buf))))
-		))
+	   `(lambda () 
+	      (delete-file ,(buffer-file-name buf1))
+	      (or ,(string= rev2 "")
+		  (delete-file ,(buffer-file-name buf2)))
+	      (or ,(string= ancestor-rev "")
+		  ,(not ancestor-rev)
+		  (delete-file ,(buffer-file-name ancestor-buf)))
+	      )
 	   startup-hooks))
     (if ancestor-rev
 	(ediff-merge-buffers-with-ancestor
 	     (setq file
 		   (ediff-make-temp-file
 		    (current-buffer) temp-file-name-prefix))
-	     (set hooks-var (cons (` (lambda () (delete-file (, file))))
+	     (set hooks-var (cons `(lambda () (delete-file ,file))
 				  (symbol-value hooks-var))))
 	    ;; file processed via auto-mode-alist, a la uncompress.el
 	    ((not (equal (file-truename file)
 	     (setq file
 		   (ediff-make-temp-file
 		    (current-buffer) temp-file-name-prefix))
-	     (set hooks-var (cons (` (lambda () (delete-file (, file))))
+	     (set hooks-var (cons `(lambda () (delete-file ,file))
 				  (symbol-value hooks-var))))
 	    (t ;; plain file---just check that the file matches the buffer
 	     (ediff-verify-file-buffer))))
 		 (get-buffer buf-B) file-B
 		 (if buf-C-is-alive (get-buffer buf-C))
 		 file-C
-		 (cons (` (lambda ()
-			    (delete-file (, file-A))
-			    (delete-file (, file-B))
-			    (if (stringp (, file-C)) (delete-file (, file-C)))
-			    ))
+		 (cons `(lambda ()
+			  (delete-file ,file-A)
+			  (delete-file ,file-B)
+			  (if (stringp ,file-C) (delete-file ,file-C)))
 		       startup-hooks)
 		 (list (cons 'ediff-job-name job-name))
 		 merge-buffer-file)))
     (setq startup-hooks
 	  ;; this sets various vars in the meta buffer inside
 	  ;; ediff-prepare-meta-buffer
-	  (cons (` (lambda ()
-		     ;; tell what to do if the user clicks on a session record
-		     (setq ediff-session-action-function (quote (, action)))
-		     ;; set ediff-dir-difference-list 
-		     (setq ediff-dir-difference-list (quote (, diffs)))))
+	  (cons `(lambda ()
+		   ;; tell what to do if the user clicks on a session record
+		   (setq ediff-session-action-function (quote ,action))
+		   ;; set ediff-dir-difference-list 
+		   (setq ediff-dir-difference-list (quote ,diffs)))
 		startup-hooks))
     (setq meta-buf (ediff-prepare-meta-buffer 
 		    'ediff-filegroup-action
     (setq startup-hooks
 	  ;; this sets various vars in the meta buffer inside
 	  ;; ediff-prepare-meta-buffer
-	  (cons (` (lambda ()
-		     ;; tell what to do if the user clicks on a session record
-		     (setq ediff-session-action-function (quote (, action)))
-		     ))
+	  (cons `(lambda ()
+		   ;; tell what to do if the user clicks on a session record
+		   (setq ediff-session-action-function (quote ,action)))
 		startup-hooks))
     (setq meta-buf (ediff-prepare-meta-buffer 
 		    'ediff-filegroup-action
     (ediff-setup buffer-A file-A
 		 buffer-B file-B
 		 nil nil	    ; buffer & file C
-		 (cons (` (lambda ()
-			    (delete-file (, file-A))
-			    (delete-file (, file-B))))
+		 (cons `(lambda ()
+			    (delete-file ,file-A)
+			    (delete-file ,file-B))
 		       startup-hooks)
 		 (append
 		  (list (cons 'ediff-word-mode  word-mode)
 this:
 
 @example
-#ifdef NEW  /* variant A */
-difference region from buffer A
-#else  /* variant B */
-difference region from buffer B
-#endif  /* NEW */
+<<<<<<< variant A
+the difference region from buffer A
+>>>>>>> variant B
+the difference region from buffer B
+####### Ancestor
+the difference region from the ancestor buffer, if available
+======= end
 @end example
 
+The above is the default template for the combined region. The user can
+customize this template using the variable
+@code{ediff-combination-pattern}.
+
 @vindex ediff-combination-pattern
-The actual strings that separate the regions copied from buffer A and B
-are controlled by the variable @code{ediff-combination-pattern}.  Its
-value should be a list of three strings.  The first is inserted before
-the difference region of buffer A; the second string goes between the
-regions; the third goes after region B, as shown in the above example.
+The variable @code{ediff-combination-pattern} specifies the template that
+determines how the combined merged region looks like.  The template is
+represented as a list of the form @code{(STRING1 Symbol1 STRING2 Symbol2
+STRING3 Symbol3 STRING4)}. The symbols here must be atoms of the form
+@code{A}, @code{B}, or @code{Ancestor}. They determine the order in which
+the corresponding difference regions (from buffers A, B, and the ancestor
+buffer) are displayed in the merged region of buffer C.  The strings in the
+template determine the text that separates the aforesaid regions. The
+default template is
+
+@example
+("<<<<<<< variant A" A ">>>>>>> variant B" B  "####### Ancestor" Ancestor "======= end")
+@end example
+
+and the corresponding combined region is shown above. The order in which 
+the regions are shown (and the separator strings) can be changed by
+changing the above template. It is even possible to add or delete region
+specifiers in this template (although the only possibly useful such
+modification seems to be the deletion of the ancestor).
 
 In addition to the state of the difference, Ediff displays the state of the
 merge for each region.  If a difference came from buffer A by default