Commit 086171bf authored by Michael Kifer's avatar Michael Kifer
Browse files

*** empty log message ***

parent ba7394fe
......@@ -799,20 +799,24 @@ one optional arguments, diff-number to refine.")
(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))
))
......
......@@ -84,10 +84,10 @@ that Ediff doesn't know about.")
;;
;; 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)))
......@@ -114,30 +114,29 @@ that Ediff doesn't know about.")
;;; 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)...)
......@@ -154,11 +153,11 @@ that Ediff doesn't know about.")
(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
......@@ -182,118 +181,118 @@ that Ediff doesn't know about.")
;; 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
......@@ -995,7 +994,7 @@ this variable represents.")
;; 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)
......@@ -1003,8 +1002,8 @@ this variable represents.")
(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,
......@@ -1017,8 +1016,8 @@ this variable represents.")
(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,
......@@ -1031,8 +1030,8 @@ this variable represents.")
(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,
......@@ -1045,8 +1044,8 @@ this variable represents.")
(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,
......
......@@ -57,17 +57,24 @@ Valid values are the symbols `default-A', `default-B', and `combined'."
: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 variant B
diff region from the ancestor
STRING3
diff region from variant B
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
......@@ -108,20 +115,44 @@ Buffer B."
(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"))
(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"))
(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)
(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))
......@@ -275,10 +306,10 @@ Combining is done according to the specifications in variable
(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))))
......@@ -286,36 +317,38 @@ Combining is done according to the specifications in variable
;; 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))))
(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))
(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)
)))
;; 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.
......@@ -334,7 +367,8 @@ Combining is done according to the specifications in variable
(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)))
......
......@@ -1525,14 +1525,14 @@ all marked sessions must be active."
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)
......@@ -1546,15 +1546,15 @@ all marked sessions must be active."
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
......@@ -1571,124 +1571,121 @@ all marked sessions must be active."
(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)