Commit ddc90f39 authored by Michael Kifer's avatar Michael Kifer
Browse files

new version

parent 70bc91bc
;;; ediff-diff.el --- diff-related utilities
;; Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
;; Author: Michael Kifer <kifer@cs.sunysb.edu>
......@@ -23,10 +23,29 @@
;;; Code:
(provide 'ediff-diff)
;; compiler pacifier
(defvar ediff-default-variant)
(eval-when-compile
(let ((load-path (cons (expand-file-name ".") load-path)))
(or (featurep 'ediff-init)
(load "ediff-init.el" nil nil 'nosuffix))
(or (featurep 'ediff-util)
(load "ediff-util.el" nil nil 'nosuffix))
))
;; end pacifier
(require 'ediff-init)
(defgroup ediff-diff nil
"Diff related utilities"
:prefix "ediff-"
:group 'ediff)
(defvar ediff-shell
(defcustom ediff-shell
(cond ((eq system-type 'emx) "cmd") ; OS/2
((memq system-type '(ms-dos windows-nt windows-95))
shell-file-name) ; no standard name on MS-DOS
......@@ -36,37 +55,53 @@
.cshrc files are set up correctly, any shell will do. However, some people
set $prompt or other things incorrectly, which leads to undesirable output
messages. These may cause Ediff to fail. In such a case, set ediff-shell
to a shell that you are not using or, better, fix your shell's startup file.")
to a shell that you are not using or, better, fix your shell's startup file."
:type 'string
:group 'ediff-diff)
(defvar ediff-diff-program "diff"
"*Program to use for generating the differential of the two files.")
(defvar ediff-diff-options ""
(defcustom ediff-diff-program "diff"
"*Program to use for generating the differential of the two files."
:type 'string
:group 'ediff-diff)
(defcustom ediff-diff-options ""
"*Options to pass to `ediff-diff-program'.
If diff\(1\) is used as `ediff-diff-program', then the most useful options are
`-w', to ignore space, and `-i', to ignore case of letters.
At present, the option `-c' is ignored, since Ediff doesn't understand this
type of output.")
type of output."
:type 'string
:group 'ediff-diff)
(defvar ediff-custom-diff-program ediff-diff-program
(defcustom ediff-custom-diff-program ediff-diff-program
"*Program to use for generating custom diff output for saving it in a file.
This output is not used by Ediff internally.")
(defvar ediff-custom-diff-options "-c"
"*Options to pass to `ediff-custom-diff-program'.")
This output is not used by Ediff internally."
:type 'string
:group 'ediff-diff)
(defcustom ediff-custom-diff-options "-c"
"*Options to pass to `ediff-custom-diff-program'."
:type 'string
:group 'ediff-diff)
;;; Support for diff3
(defvar ediff-match-diff3-line "^====\\(.?\\)$"
"Pattern to match lines produced by diff3 that describe differences.")
(defvar ediff-diff3-program "diff3"
(defcustom ediff-diff3-program "diff3"
"*Program to be used for three-way comparison.
Must produce output compatible with Unix's diff3 program.")
(defvar ediff-diff3-options ""
"*Options to pass to `ediff-diff3-program'.")
(defvar ediff-diff3-ok-lines-regexp
Must produce output compatible with Unix's diff3 program."
:type 'string
:group 'ediff-diff)
(defcustom ediff-diff3-options ""
"*Options to pass to `ediff-diff3-program'."
:type 'string
:group 'ediff-diff)
(defcustom ediff-diff3-ok-lines-regexp
"^\\([1-3]:\\|====\\| \\|.*Warning *:\\|.*No newline\\|.*missing newline\\|^\C-m$\\)"
"*Regexp that matches normal output lines from `ediff-diff3-program'.
Lines that do not match are assumed to be error messages.")
Lines that do not match are assumed to be error messages."
:type 'regexp
:group 'ediff-diff)
;; keeps the status of the current diff in 3-way jobs.
;; the status can be =diff(A), =diff(B), or =diff(A+B)
......@@ -551,13 +586,7 @@ one optional arguments, diff-number to refine.")
(whitespace-C (ediff-whitespace-diff-region-p n 'C))
cumulative-fine-diff-length)
(cond ((and (eq flag 'noforce) (ediff-get-fine-diff-vector n 'A))
;; don't compute fine diffs if diff vector exists
(if (ediff-no-fine-diffs-p n)
;;(ediff-message-if-verbose
(message
"Only white-space differences in region %d" (1+ n))))
;; If one of the regions is empty (or 2 in 3way comparison)
(cond ;; If one of the regions is empty (or 2 in 3way comparison)
;; then don't refine.
;; If the region happens to be entirely whitespace or empty then
;; mark as such.
......@@ -586,6 +615,20 @@ one optional arguments, diff-number to refine.")
;; if some regions are white and others don't, then mark as
;; non-white-space-only
(ediff-mark-diff-as-space-only n nil)))
;; don't compute fine diffs if diff vector exists
((and (eq flag 'noforce) (ediff-get-fine-diff-vector n 'A))
(if (ediff-no-fine-diffs-p n)
(message
"Only white-space differences in region %d %s"
(1+ n)
(cond ((eq (ediff-no-fine-diffs-p n) 'A)
"in buffers B & C")
((eq (ediff-no-fine-diffs-p n) 'B)
"in buffers A & C")
((eq (ediff-no-fine-diffs-p n) 'C)
"in buffers A & B")
(t "")))))
;; don't compute fine diffs for this region
((eq flag 'skip)
(or (ediff-get-fine-diff-vector n 'A)
......@@ -666,13 +709,15 @@ one optional arguments, diff-number to refine.")
(ediff-message-if-verbose
"Only white-space differences in region %d" (1+ n)))
((eq cumulative-fine-diff-length 0)
(ediff-mark-diff-as-space-only n t)
(ediff-message-if-verbose
"Only white-space differences in region %d %s"
(1+ n)
(cond (whitespace-A "in buffers B & C")
(whitespace-B "in buffers A & C")
(whitespace-C "in buffers A & B"))))
(cond (whitespace-A (ediff-mark-diff-as-space-only n 'A)
"in buffers B & C")
(whitespace-B (ediff-mark-diff-as-space-only n 'B)
"in buffers A & C")
(whitespace-C (ediff-mark-diff-as-space-only n 'C)
"in buffers A & B"))))
(t
(ediff-mark-diff-as-space-only n nil)))
)
......@@ -1204,7 +1249,5 @@ argument to `skip-chars-forward'."
;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body))
;;; End:
(provide 'ediff-diff)
;; ediff-diff.el ends here
;;; ediff-help.el --- Code related to the contents of Ediff help buffers
;; Copyright (C) 1996 Free Software Foundation, Inc.
;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
;; Author: Michael Kifer <kifer@cs.sunysb.edu>
......@@ -22,17 +22,21 @@
;; Boston, MA 02111-1307, USA.
;;; Code:
(require 'ediff-init)
(provide 'ediff-help)
;; Compiler pacifier start
(defvar ediff-multiframe)
(and noninteractive
(eval-when-compile
(let ((load-path (cons (expand-file-name ".") load-path)))
(load-file "ediff-init.el"))))
(eval-when-compile
(let ((load-path (cons (expand-file-name ".") load-path)))
(or (featurep 'ediff-init)
(load "ediff-init.el" nil nil 'nosuffix))
))
;; end pacifier
(require 'ediff-init)
;; Help messages
(defconst ediff-long-help-message-head
......@@ -178,8 +182,7 @@ the value of this variable and the variables `ediff-help-message-*' in
"Explain Ediff commands in more detail."
(interactive)
(ediff-barf-if-not-control-buffer)
(let ((ctl-buf (current-buffer))
(pos (ediff-event-point last-command-event))
(let ((pos (ediff-event-point last-command-event))
overl cmd)
(if ediff-xemacs-p
......@@ -306,6 +309,5 @@ the value of this variable and the variables `ediff-help-message-*' in
ediff-brief-help-message))
(run-hooks 'ediff-display-help-hook))
(provide 'ediff-help)
;;; ediff-help.el ends here
;;; ediff-hook.el --- setup for Ediff's menus and autoloads
;; Copyright (C) 1995, 1996 Free Software Foundation, Inc.
;; Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
;; Author: Michael Kifer <kifer@cs.sunysb.edu>
......@@ -25,6 +25,8 @@
;;; These must be placed in menu-bar.el in Emacs
;;
;; (define-key menu-bar-tools-menu [ediff-misc]
;; '("Ediff Miscellanea" . menu-bar-ediff-misc-menu))
;; (define-key menu-bar-tools-menu [epatch]
;; '("Apply Patch" . menu-bar-epatch-menu))
;; (define-key menu-bar-tools-menu [ediff-merge]
......@@ -36,32 +38,24 @@
(defvar ediff-menu)
(defvar ediff-merge-menu)
(defvar epatch-menu)
(defvar ediff-misc-menu)
;; end pacifier
;; allow menus to be set up without ediff-wind.el being loaded
(defvar ediff-window-setup-function)
(defun ediff-xemacs-init-menus ()
(if (featurep 'menubar)
(progn
(add-menu-button
'("Tools")
["Use separate frame for Ediff control buffer"
ediff-toggle-multiframe
:style toggle
:selected (eq ediff-window-setup-function 'ediff-setup-windows-multiframe)]
"00-Browser...")
(add-menu-button
'("Tools")
["Use a toolbar with Ediff control buffer"
ediff-menu-toggle-use-toolbar
:style toggle
:selected (ediff-use-toolbar-p)]
"00-Browser...")
(add-submenu
'("Tools") ediff-menu "OO-Browser...")
(add-submenu
'("Tools") ediff-merge-menu "OO-Browser...")
(add-submenu
'("Tools") epatch-menu "OO-Browser...")
(add-submenu
'("Tools") ediff-misc-menu "OO-Browser...")
(add-menu-button
'("Tools")
["-------" nil nil] "OO-Browser...")
......@@ -88,9 +82,6 @@
"---"
["Regions Word-by-word..." ediff-regions-wordwise t]
["Regions Line-by-line..." ediff-regions-linewise t]
"---"
["List Ediff Sessions..." ediff-show-registry t]
["Ediff Manual..." ediff-documentation t]
))
(defvar ediff-merge-menu
'("Merge"
......@@ -110,17 +101,28 @@
["Directory Revisions..." ediff-merge-directory-revisions t]
["Directory Revisions with Ancestor..."
ediff-merge-directory-revisions-with-ancestor t]
"---"
["List Ediff Sessions..." ediff-show-registry t]
["Ediff Manual..." ediff-documentation t]
))
(defvar epatch-menu
'("Apply Patch"
["To a file..." ediff-patch-file t]
["To a buffer..." ediff-patch-buffer t]
"---"
["List Ediff Sessions..." ediff-show-registry t]
))
(defvar ediff-misc-menu
'("Ediff Miscellanea"
["Ediff Manual..." ediff-documentation t]
["List Ediff Sessions..." ediff-show-registry t]
["Use separate frame for Ediff control buffer..."
ediff-toggle-multiframe
:style toggle
:selected (if (and (featurep 'ediff-util)
(boundp 'ediff-window-setup-function))
(eq ediff-window-setup-function
'ediff-setup-windows-multiframe))]
["Use a toolbar with Ediff control buffer"
ediff-toggle-use-toolbar
:style toggle
:selected (if (featurep 'ediff-tbar)
(ediff-use-toolbar-p))]
))
;; put these menus before Object-Oriented-Browser in Tools menu
......@@ -132,6 +134,10 @@
;; Emacs--only if menu-bar is loaded
((featurep 'menu-bar)
;; initialize menu bar keymaps
(defvar menu-bar-ediff-misc-menu
(make-sparse-keymap "Ediff Miscellanea"))
(fset 'menu-bar-ediff-misc-menu
(symbol-value 'menu-bar-ediff-misc-menu))
(defvar menu-bar-epatch-menu (make-sparse-keymap "Apply Patch"))
(fset 'menu-bar-epatch-menu (symbol-value 'menu-bar-epatch-menu))
(defvar menu-bar-ediff-merge-menu (make-sparse-keymap "Merge"))
......@@ -141,14 +147,6 @@
(fset 'menu-bar-ediff-menu (symbol-value 'menu-bar-ediff-menu))
;; define ediff-menu
(define-key menu-bar-ediff-menu [ediff-doc]
'("Ediff Manual..." . ediff-documentation))
(define-key menu-bar-ediff-menu [emultiframe]
'("Toggle separate control buffer frame..."
. ediff-toggle-multiframe))
(define-key menu-bar-ediff-menu [eregistry]
'("List Ediff Sessions..." . ediff-show-registry))
(define-key menu-bar-ediff-menu [separator-ediff-manual] '("--"))
(define-key menu-bar-ediff-menu [window]
'("This Window and Next Window" . compare-windows))
(define-key menu-bar-ediff-menu [ediff-windows-linewise]
......@@ -181,15 +179,6 @@
'("Two Files..." . ediff-files))
;; define merge menu
(define-key menu-bar-ediff-merge-menu [ediff-doc2]
'("Ediff Manual..." . ediff-documentation))
(define-key menu-bar-ediff-merge-menu [emultiframe2]
'("Toggle separate control buffer frame..."
. ediff-toggle-multiframe))
(define-key menu-bar-ediff-merge-menu [eregistry2]
'("List Ediff Sessions..." . ediff-show-registry))
(define-key
menu-bar-ediff-merge-menu [separator-ediff-merge-manual] '("--"))
(define-key
menu-bar-ediff-merge-menu [ediff-merge-dir-revisions-with-ancestor]
'("Directory Revisions with Ancestor..."
......@@ -223,18 +212,20 @@
'("Files..." . ediff-merge-files))
;; define epatch menu
(define-key menu-bar-epatch-menu [ediff-doc3]
'("Ediff Manual..." . ediff-documentation))
(define-key menu-bar-epatch-menu [emultiframe3]
'("Toggle separate control buffer frame..."
. ediff-toggle-multiframe))
(define-key menu-bar-epatch-menu [eregistry3]
'("List Ediff Sessions..." . ediff-show-registry))
(define-key menu-bar-epatch-menu [separator-epatch] '("--"))
(define-key menu-bar-epatch-menu [ediff-patch-buffer]
'("To a Buffer..." . ediff-patch-buffer))
(define-key menu-bar-epatch-menu [ediff-patch-file]
'("To a File..." . ediff-patch-file)))
'("To a File..." . ediff-patch-file))
;; define ediff miscellanea
(define-key menu-bar-ediff-misc-menu [emultiframe]
'("Toggle use of separate control buffer frame..."
. ediff-toggle-multiframe))
(define-key menu-bar-ediff-misc-menu [eregistry]
'("List Ediff Sessions..." . ediff-show-registry))
(define-key menu-bar-ediff-misc-menu [ediff-doc]
'("Ediff Manual..." . ediff-documentation))
)
) ; cond
......@@ -338,11 +329,11 @@
"ediff-util"
"Toggle the use of separate frame for Ediff control buffer."
t)
(if (string-match "XEmacs" emacs-version)
(autoload 'ediff-toggle-use-toolbar
"ediff-tbar"
"Toggle the use of Ediff toolbar."
t))
(autoload 'ediff-toggle-use-toolbar
"ediff-util"
"Toggle the use of Ediff toolbar."
t)
) ; if purify-flag
......
;;; ediff-init.el --- Macros, variables, and defsubsts used by Ediff
;; Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
;; Author: Michael Kifer <kifer@cs.sunysb.edu>
......@@ -32,6 +32,10 @@
(defvar ediff-mouse-pixel-threshold)
(defvar ediff-whitespace)
(defvar ediff-multiframe)
(and noninteractive
(eval-when-compile
(load "ange-ftp" 'noerror)))
;; end pacifier
;; Is it XEmacs?
......@@ -90,7 +94,7 @@ that Ediff doesn't know about.")
(ediff-defvar-local ediff-buffer-C nil "")
;; Ancestor buffer
(ediff-defvar-local ediff-ancestor-buffer nil "")
;; The control buffer of ediff.
;; The Ediff control buffer
(ediff-defvar-local ediff-control-buffer nil "")
;;; Macros
......@@ -125,10 +129,18 @@ that Ediff doesn't know about.")
(symbol-value
(intern (format "ediff-difference-vector-%S" (, buf-type)))) (, n))))
;; tell if it has been previously determined that the region has
;; Tell if it has been previously determined that the region has
;; no diffs other than the white space and newlines
;; The argument, N, is the diff region number used by Ediff to index the
;; diff vector. It is 1 less than the number seen by the user.
;; Returns:
;; t if the diffs are whitespace in all buffers
;; 'A (in 3-buf comparison only) if there are only whitespace
;; diffs in bufs B and C
;; 'B (in 3-buf comparison only) if there are only whitespace
;; diffs in bufs A and C
;; 'C (in 3-buf comparison only) if there are only whitespace
;; diffs in bufs A and B
;;
;; A difference vector has the form:
;; [diff diff diff ...]
......@@ -625,8 +637,8 @@ appropriate symbol: `rcs', `pcl-cvs', or `generic-sc' if you so desire.")
;;;; warn if it is a wrong version of emacs
;;(if (or (ediff-check-version '< 19 29 'emacs)
;; (ediff-check-version '< 19 12 'xemacs))
;;(if (or (ediff-check-version '< 19 35 'emacs)
;; (ediff-check-version '< 19 15 'xemacs))
;; (progn
;; (with-output-to-temp-buffer ediff-msg-buffer
;; (switch-to-buffer ediff-msg-buffer)
......@@ -635,9 +647,9 @@ appropriate symbol: `rcs', `pcl-cvs', or `generic-sc' if you so desire.")
;;
;;This version of Ediff requires
;;
;;\t Emacs 19.29 and higher
;;\t Emacs 19.35 and higher
;;\t OR
;;\t XEmacs 19.12 and higher
;;\t XEmacs 19.15 and higher
;;
;;It is unlikely to work under Emacs version %s
;;that you are using... " emacs-version))
......@@ -1152,11 +1164,13 @@ More precisely, a regexp to match any one such character.")
;;; In-line functions
(defsubst ediff-file-remote-p (file-name)
(require 'ange-ftp)
(car (if ediff-xemacs-p
(ange-ftp-ftp-path file-name)
(ange-ftp-ftp-name file-name))))
(or (fboundp 'ediff-file-remote-p) ; user supplied his own function: use it
(defun ediff-file-remote-p (file-name)
(car (cond ((featurep 'efs-auto) (efs-ftp-path file-name))
((fboundp 'file-remote-p) (file-remote-p file-name))
(t (require 'ange-ftp)
;; Can happen only in Emacs, since XEmacs has file-remote-p
(ange-ftp-ftp-name file-name))))))
(defsubst ediff-frame-unsplittable-p (frame)
......@@ -1174,6 +1188,14 @@ More precisely, a regexp to match any one such character.")
(if (ediff-buffer-live-p buf)
(kill-buffer (get-buffer buf))))
(defsubst ediff-background-face (buf-type dif-num)
;; The value of dif-num is always 1- the one that user sees.
;; This is why even face is used when dif-num is odd.
(intern (format (if (ediff-odd-p dif-num)
"ediff-even-diff-face-%S"
"ediff-odd-diff-face-%S")
buf-type)))
;; activate faces on diff regions in buffer
(defun ediff-paint-background-regions-in-one-buffer (buf-type unhighlight)
......@@ -1184,11 +1206,13 @@ More precisely, a regexp to match any one such character.")
(lambda (rec)
(setq overl (ediff-get-diff-overlay-from-diff-record rec)
diff-num (ediff-overlay-get overl 'ediff-diff-num))
(ediff-set-overlay-face
overl
(if (not unhighlight)
(ediff-background-face buf-type diff-num))
)))
(if (ediff-overlay-buffer overl)
;; only if overlay is alive
(ediff-set-overlay-face
overl
(if (not unhighlight)
(ediff-background-face buf-type diff-num))))
))
diff-vector)))
......@@ -1287,14 +1311,6 @@ More precisely, a regexp to match any one such character.")
(ediff-unhighlight-diffs-totally-in-one-buffer 'Ancestor)
)
(defsubst ediff-background-face (buf-type dif-num)
;; The value of dif-num is always 1- the one that user sees.
;; This is why even face is used when dif-num is odd.
(intern (format (if (ediff-odd-p dif-num)
"ediff-even-diff-face-%S"
"ediff-odd-diff-face-%S")
buf-type)))
;; arg is a record for a given diff in a difference vector
;; this record is itself a vector
......@@ -1419,6 +1435,18 @@ More precisely, a regexp to match any one such character.")
;; Some overlay functions
(defsubst ediff-overlay-start (overl)
(if (ediff-overlayp overl)
(if ediff-emacs-p
(overlay-start overl)
(extent-start-position overl))))
(defsubst ediff-overlay-end (overl)
(if (ediff-overlayp overl)
(if ediff-emacs-p
(overlay-end overl)
(extent-end-position overl))))
(defsubst ediff-empty-overlay-p (overl)
(= (ediff-overlay-start overl) (ediff-overlay-end overl)))
......@@ -1583,10 +1611,10 @@ Checks if overlay's buffer exists."
(apply 'message string args)))
(defun ediff-file-attributes (filename attr-number)
(let ((handler (find-file-name-handler filename 'find-file-noselect)))
(if (and handler (string-match "ange-ftp" (format "%S" handler)))
-1
(nth attr-number (file-attributes filename)))))
(if (ediff-file-remote-p filename)
-1
(nth attr-number (file-attributes filename))))
(defsubst ediff-file-size (filename)
(ediff-file-attributes filename 7))
(defsubst ediff-file-modtime (filename)
......@@ -1594,9 +1622,8 @@ Checks if overlay's buffer exists."
(defun ediff-convert-standard-filename (fname)
(if ediff-emacs-p
(if (fboundp 'convert-standard-filename)
(convert-standard-filename fname)
;; hopefully, XEmacs adds this functionality
fname))
......
;;; ediff-merg.el --- merging utilities
;; Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
;; Author: Michael Kifer <kifer@cs.sunysb.edu>
......@@ -23,14 +23,40 @@
;;; Code:
(provide 'ediff-merg)
(defgroup ediff-merge nil
"Merging utilities"
:prefix "ediff-"
:group 'ediff)
;; compiler pacifier
(defvar ediff-window-A)
(defvar ediff-window-B)
(defvar ediff-window-C)
(defvar ediff-merge-window-share)
(defvar ediff-window-config-saved)
(eval-when-compile
(let ((load-path (cons (expand-file-name ".") load-path)))
(or (featurep 'ediff-init)
(load "ediff-init.el" nil nil 'nosuffix))
(or (featurep 'ediff-util)
(load "ediff-util.el" nil nil 'nosuffix))
))
;; end pacifier
(require 'ediff-init)
(defvar ediff-default-variant 'combined
(defcustom ediff-default-variant 'combined
"*The variant to be used as a default for buffer C in merging.
Valid values are the symbols `default-A', `default-B', and `combined'.")
Valid values are the symbols `default-A', `default-B', and `combined'."
:type '(radio (const default-A) (const default-B) (const combined))
:group 'ediff-merge)
(defvar ediff-combination-pattern
(defcustom ediff-combination-pattern
'("<<<<<<<<<<<<<< variant A" ">>>>>>>>>>>>>> variant B" "======= end of combination")
"*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:
......@@ -40,7 +66,9 @@ diff region from variant A
STRING2
diff region from variant B
STRING3
")