Sync to HEAD
[bpt/emacs.git] / lisp / ediff-init.el
index ae6d05a..81299b9 100644 (file)
@@ -1,6 +1,6 @@
 ;;; ediff-init.el --- Macros, variables, and defsubsts used by Ediff
 
-;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02, 04 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 
@@ -78,7 +78,8 @@ that Ediff doesn't know about.")
        (ediff-force-faces)
        ((ediff-color-display-p))
        (ediff-emacs-p (memq (ediff-device-type) '(pc)))
-       (ediff-xemacs-p (memq (ediff-device-type) '(tty pc)))))
+       (ediff-xemacs-p (memq (ediff-device-type) '(tty pc)))
+       ))
 
 ;; toolbar support for emacs hasn't been implemented in ediff
 (defun ediff-has-toolbar-support-p ()
@@ -289,6 +290,9 @@ It needs to be killed when we quit the session.")
       ediff-merge-revisions-with-ancestor)))
 (ediff-defvar-local ediff-merge-job nil "")
 
+(defmacro ediff-patch-job ()
+  `(eq ediff-job-name 'epatch))
+
 (defmacro ediff-merge-with-ancestor-job ()
   `(memq
     ediff-job-name
@@ -344,12 +348,13 @@ It needs to be killed when we quit the session.")
       (ediff-patch-metajob metajob)
       ;; add more here
       ))
+;; jobs suitable for the operation of collecting diffs into a multifile patch
 (defsubst ediff-collect-diffs-metajob (&optional metajob)
   (memq (or metajob ediff-metajob-name)
        '(ediff-directories
-         ediff-directory-revisions
          ediff-merge-directories
          ediff-merge-directories-with-ancestor
+         ediff-directory-revisions
          ediff-merge-directory-revisions
          ediff-merge-directory-revisions-with-ancestor
          ;; add more here
@@ -629,11 +634,6 @@ shown in brighter colors."
   :type 'boolean
   :group 'ediff-highlighting)
 
-;; A var local to each control panel buffer.  Indicates highlighting style
-;; in effect for this buffer: `face', `ascii', nil -- temporarily
-;; unhighlighted, `off' -- turned off \(on a dumb terminal only\).
-(ediff-defvar-local ediff-highlighting-style nil "")
-
 
 ;; The suffix of the control buffer name.
 (ediff-defvar-local ediff-control-buffer-suffix nil "")
@@ -740,7 +740,7 @@ appropriate symbol: `rcs', `pcl-cvs', or `generic-sc' if you so desire."
   :group 'ediff)
 
 (defcustom ediff-coding-system-for-read 'raw-text
-  "*The coding system for read to use when running the diff program as a subprocess. 
+  "*The coding system for read to use when running the diff program as a subprocess.
 In most cases, the default will do. However, under certain circumstances in
 Windows NT/98/95 you might need to use something like 'raw-text-dos here.
 So, if the output that your diff program sends to Emacs contains extra ^M's,
@@ -758,15 +758,15 @@ to temp files when Ediff needs to find fine differences."
 
 (ediff-cond-compile-for-xemacs-or-emacs
  (progn ; xemacs
-   (fset 'ediff-read-event (symbol-function 'next-command-event))
-   (fset 'ediff-overlayp (symbol-function 'extentp))
-   (fset 'ediff-make-overlay (symbol-function 'make-extent))
-   (fset 'ediff-delete-overlay (symbol-function 'delete-extent)))
+   (defalias 'ediff-read-event 'next-command-event)
+   (defalias 'ediff-overlayp 'extentp)
+   (defalias 'ediff-make-overlay 'make-extent)
+   (defalias 'ediff-delete-overlay 'delete-extent))
  (progn ; emacs
-   (fset 'ediff-read-event (symbol-function 'read-event))
-   (fset 'ediff-overlayp (symbol-function 'overlayp))
-   (fset 'ediff-make-overlay (symbol-function 'make-overlay))
-   (fset 'ediff-delete-overlay (symbol-function 'delete-overlay)))
+   (defalias 'ediff-read-event 'read-event)
+   (defalias 'ediff-overlayp 'overlayp)
+   (defalias 'ediff-make-overlay 'make-overlay)
+   (defalias 'ediff-delete-overlay 'delete-overlay))
  )
 
 ;; Check the current version against the major and minor version numbers
@@ -808,6 +808,14 @@ to temp files when Ediff needs to find fine differences."
     (error nil)))
 
 
+;; A var local to each control panel buffer.  Indicates highlighting style
+;; in effect for this buffer: `face', `ascii',
+;; `off' -- turned off \(on a dumb terminal only\).
+(ediff-defvar-local ediff-highlighting-style
+  (if (and (ediff-has-face-support-p) ediff-use-faces) 'face 'ascii)
+  "")
+
+
 (if (ediff-has-face-support-p)
     (ediff-cond-compile-for-xemacs-or-emacs
      (progn ; xemacs
@@ -823,18 +831,17 @@ to temp files when Ediff needs to find fine differences."
 (if (ediff-window-display-p)
     (ediff-cond-compile-for-xemacs-or-emacs
      (progn   ; xemacs
-       (fset 'ediff-display-pixel-width (symbol-function 'device-pixel-width))
-       (fset 'ediff-display-pixel-height
-            (symbol-function 'device-pixel-height)))
+       (defalias 'ediff-display-pixel-width 'device-pixel-width)
+       (defalias 'ediff-display-pixel-height 'device-pixel-height))
      (progn   ; emacs
-       (fset 'ediff-display-pixel-width
+       (defalias 'ediff-display-pixel-width
             (if (fboundp 'display-pixel-width)
-                (symbol-function 'display-pixel-width)
-              (symbol-function 'x-display-pixel-width)))
-       (fset 'ediff-display-pixel-height
+                'display-pixel-width
+              'x-display-pixel-width))
+       (defalias 'ediff-display-pixel-height
             (if (fboundp 'display-pixel-height)
-                (symbol-function 'display-pixel-height)
-              (symbol-function 'x-display-pixel-height))))
+                'display-pixel-height
+              'x-display-pixel-height)))
      ))
 
 ;; A-list of current-diff-overlay symbols associated with buf types
@@ -888,14 +895,16 @@ to temp files when Ediff needs to find fine differences."
         (sit-for 1)))))
 
 (defun ediff-hide-face (face)
-  (if (and (ediff-has-face-support-p) ediff-emacs-p)
+  (if (and (ediff-has-face-support-p) (boundp 'add-to-list)
+          (boundp 'facemenu-unlisted-faces))
       (add-to-list 'facemenu-unlisted-faces face)))
 
 
 
 (defface ediff-current-diff-face-A
-  '((((class color)) (:foreground "firebrick" :background "pale green"))
-    (t (:inverse-video t)))
+  '((((type tty))    (:foreground "blue3" :background "yellow3"))
+    (((class color)) (:foreground "firebrick" :background "pale green"))
+    (t              (:inverse-video t)))
   "Face for highlighting the selected difference in buffer A."
   :group 'ediff-highlighting)
 ;; An internal variable.  Ediff takes the face from here.  When unhighlighting,
@@ -916,8 +925,10 @@ this variable represents.")
 
 
 (defface ediff-current-diff-face-B
-  '((((class color)) (:foreground "DarkOrchid" :background "Yellow"))
-    (t (:inverse-video t)))
+  '((((type tty))    (:foreground "magenta3" :background "yellow3"
+                                 :weight bold))
+    (((class color)) (:foreground "DarkOrchid" :background "Yellow"))
+    (t              (:inverse-video t)))
   "Face for highlighting the selected difference in buffer B."
   :group 'ediff-highlighting)
 ;; An internal variable.  Ediff takes the face from here.  When unhighlighting,
@@ -937,8 +948,9 @@ this variable represents.")
 
 
 (defface ediff-current-diff-face-C
-  '((((class color)) (:foreground "Navy" :background "Pink"))
-    (t (:inverse-video t)))
+  '((((type tty))    (:foreground "cyan3" :background "yellow3" :weight bold))
+    (((class color)) (:foreground "Navy" :background "Pink"))
+    (t              (:inverse-video t)))
   "Face for highlighting the selected difference in buffer C."
   :group 'ediff-highlighting)
 ;; An internal variable.  Ediff takes the face from here.  When unhighlighting,
@@ -958,7 +970,8 @@ this variable represents.")
 
 
 (defface ediff-current-diff-face-Ancestor
-  '((((class color)) (:foreground "Black" :background "VioletRed"))
+  '((((type tty))    (:foreground "black" :background "magenta3"))
+    (((class color)) (:foreground "Black" :background "VioletRed"))
     (t (:inverse-video t)))
   "Face for highlighting the selected difference in buffer Ancestor."
   :group 'ediff-highlighting)
@@ -979,7 +992,8 @@ this variable represents.")
 
 
 (defface ediff-fine-diff-face-A
-  '((((class color)) (:foreground "Navy" :background "sky blue"))
+  '((((type tty))    (:foreground "white" :background "sky blue" :weight bold))
+    (((class color)) (:foreground "Navy" :background "sky blue"))
     (t (:underline t :stipple "gray3")))
   "Face for highlighting the refinement of the selected diff in buffer A."
   :group 'ediff-highlighting)
@@ -993,8 +1007,9 @@ this variable represents.")
 (ediff-hide-face 'ediff-fine-diff-face-A)
 
 (defface ediff-fine-diff-face-B
-  '((((class color)) (:foreground "Black" :background "cyan"))
-    (t (:underline t :stipple "gray3")))
+  '((((type tty))    (:foreground "magenta3" :background "cyan3"))
+    (((class color)) (:foreground "Black" :background "cyan"))
+    (t              (:underline t :stipple "gray3")))
   "Face for highlighting the refinement of the selected diff in buffer B."
   :group 'ediff-highlighting)
 ;; An internal variable.  Ediff takes the face from here.  When unhighlighting,
@@ -1007,7 +1022,10 @@ this variable represents.")
 (ediff-hide-face 'ediff-fine-diff-face-B)
 
 (defface ediff-fine-diff-face-C
-  '((((class color)) (:foreground "Black" :background "Turquoise"))
+  '((((type tty))    (:foreground "yellow3" :background "Turquoise"
+                                 :weight bold))
+    (((type pc))     (:foreground "white" :background "Turquoise"))
+    (((class color)) (:foreground "Black" :background "Turquoise"))
     (t (:underline t :stipple "gray3")))
   "Face for highlighting the refinement of the selected diff in buffer C."
   :group 'ediff-highlighting)
@@ -1021,8 +1039,9 @@ this variable represents.")
 (ediff-hide-face 'ediff-fine-diff-face-C)
 
 (defface ediff-fine-diff-face-Ancestor
-  '((((class color)) (:foreground "Black" :background "Green"))
-    (t (:underline t :stipple "gray3")))
+  '((((type tty))    (:foreground "red3" :background "green"))
+    (((class color)) (:foreground "Black" :background "Green"))
+    (t              (:underline t :stipple "gray3")))
   "Face for highlighting the refinement of the selected diff in the ancestor buffer.
 At present, this face is not used and no fine differences are computed for the
 ancestor buffer."
@@ -1046,8 +1065,11 @@ this variable represents.")
        (t "Stipple")))
 
 (defface ediff-even-diff-face-A
-  `((((class color)) (:foreground "Black" :background "light grey"))
-    (t (:italic t :stipple ,stipple-pixmap)))
+  `((((type tty))    (:foreground "red3" :background "light grey"
+                                 :weight bold))
+    (((type pc))     (:foreground "green3" :background "light grey"))
+    (((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,
@@ -1060,8 +1082,9 @@ 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)))
+  `((((type tty))    (:foreground "blue3" :background "Grey" :weight bold))
+    (((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,
@@ -1074,8 +1097,11 @@ 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)))
+  `((((type tty))    (:foreground "yellow3" :background "light grey"
+                                 :weight bold))
+    (((type pc))     (:foreground "yellow3" :background "light grey"))
+    (((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,
@@ -1088,7 +1114,10 @@ this variable represents.")
 (ediff-hide-face 'ediff-even-diff-face-C)
 
 (defface ediff-even-diff-face-Ancestor
-  `((((class color)) (:foreground "White" :background "Grey"))
+  `((((type tty))    (:foreground "cyan3" :background "light grey"
+                                 :weight bold))
+    (((type pc))     (:foreground "cyan3" :background "light grey"))
+    (((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)
@@ -1109,8 +1138,10 @@ this variable represents.")
     (Ancestor . ediff-even-diff-face-Ancestor)))
 
 (defface ediff-odd-diff-face-A
-  '((((class color)) (:foreground "White" :background "Grey"))
-    (t (:italic t :stipple "gray1")))
+  '((((type tty))    (:foreground "red3" :background "black" :weight bold))
+    (((type pc))     (:foreground "green3" :background "gray40"))
+    (((class color)) (:foreground "White" :background "Grey"))
+    (t              (:italic t :stipple "gray1")))
   "Face for highlighting odd-numbered non-current differences in buffer A."
   :group 'ediff-highlighting)
 ;; An internal variable.  Ediff takes the face from here.  When unhighlighting,
@@ -1124,8 +1155,10 @@ this variable represents.")
 
 
 (defface ediff-odd-diff-face-B
-  '((((class color)) (:foreground "Black" :background "light grey"))
-    (t (:italic t :stipple "gray1")))
+  '((((type tty))    (:foreground "cyan3" :background "black" :weight bold))
+    (((type pc))     (:foreground "White" :background "gray40"))
+    (((class color)) (:foreground "Black" :background "light grey"))
+    (t              (:italic t :stipple "gray1")))
   "Face for highlighting odd-numbered non-current differences in buffer B."
   :group 'ediff-highlighting)
 ;; An internal variable.  Ediff takes the face from here.  When unhighlighting,
@@ -1138,8 +1171,10 @@ this variable represents.")
 (ediff-hide-face 'ediff-odd-diff-face-B)
 
 (defface ediff-odd-diff-face-C
-  '((((class color)) (:foreground "White" :background "Grey"))
-    (t (:italic t :stipple "gray1")))
+  '((((type tty))    (:foreground "yellow3" :background "black" :weight bold))
+    (((type pc))     (:foreground "yellow3" :background "gray40"))
+    (((class color)) (:foreground "White" :background "Grey"))
+    (t              (:italic t :stipple "gray1")))
   "Face for highlighting odd-numbered non-current differences in buffer C."
   :group 'ediff-highlighting)
 ;; An internal variable.  Ediff takes the face from here.  When unhighlighting,
@@ -1152,8 +1187,9 @@ this variable represents.")
 (ediff-hide-face 'ediff-odd-diff-face-C)
 
 (defface ediff-odd-diff-face-Ancestor
-  '((((class color)) (:foreground "Black" :background "light grey"))
-    (t (:italic t :stipple "gray1")))
+  '((((type tty))    (:foreground "green3" :background "black" :weight bold))
+    (((class color)) (:foreground "cyan3" :background "gray40"))
+    (t              (:italic t :stipple "gray1")))
   "Face for highlighting odd-numbered non-current differences in the ancestor buffer."
   :group 'ediff-highlighting)
 ;; An internal variable.  Ediff takes the face from here.  When unhighlighting,
@@ -1253,7 +1289,7 @@ This property can be toggled interactively."
 ;;; Misc
 
 ;; if nil, this silences some messages
-(defconst ediff-verbose-p t)
+(defvar ediff-verbose-p t)
 
 (defcustom ediff-autostore-merges  'group-jobs-only
   "*Save the results of merge jobs automatically.
@@ -1338,10 +1374,10 @@ This default should work without changes."
   (cdr (assq 'unsplittable (frame-parameters frame))))
 
 (defsubst ediff-get-next-window (wind prev-wind)
-  (or (window-live-p wind)
-      (setq wind (if prev-wind
-                    (next-window wind)
-                  (selected-window)))))
+  (cond ((window-live-p wind) wind)
+       (prev-wind (next-window wind))
+       (t (selected-window))
+       ))
 
 
 (defsubst ediff-kill-buffer-carefully (buf)
@@ -1514,8 +1550,8 @@ This default should work without changes."
            (t nil))))
 
 (defsubst ediff-frame-char-height (frame)
-  (ediff-cond-compile-for-xemacs-or-emacs 
-   (glyph-height ediff-H-glyph (selected-window frame)) ; xemacs cse
+  (ediff-cond-compile-for-xemacs-or-emacs
+   (glyph-height ediff-H-glyph (frame-selected-window frame)) ; xemacs case
    (frame-char-height frame) ; emacs case
    )
   )
@@ -1702,7 +1738,7 @@ Unless optional argument INPLACE is non-nil, return a new string."
 
 
 (if (fboundp 'with-syntax-table)
-    (fset 'ediff-with-syntax-table 'with-syntax-table)
+    (defalias 'ediff-with-syntax-table 'with-syntax-table)
   ;; stolen from subr.el in emacs 21
   (defmacro ediff-with-syntax-table (table &rest body)
     (let ((old-table (make-symbol "table"))
@@ -1727,4 +1763,5 @@ Unless optional argument INPLACE is non-nil, return a new string."
 
 (provide 'ediff-init)
 
+;;; arch-tag: fa31d384-1e70-4d4b-82a7-3e96307c46f5
 ;;; ediff-init.el ends here