]> code.delx.au - gnu-emacs/blobdiff - lisp/ediff-init.el
New file.
[gnu-emacs] / lisp / ediff-init.el
index 8af930ec27e79674dee985f0205e569a9125336f..a99e643f0e058fcefe1ed4f813d5e9ecab9ee586 100644 (file)
@@ -1,7 +1,7 @@
 ;;; ediff-init.el --- Macros, variables, and defsubsts used by Ediff
 
 ;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-;;     2004, 2005 Free Software Foundation, Inc.
+;;   2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 
@@ -9,7 +9,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 (defvar ediff-multiframe)
 (defvar ediff-use-toolbar-p)
 (defvar mswindowsx-bitmap-file-path)
-
-(and noninteractive
-     (eval-when-compile
-        (load "ange-ftp" 'noerror)))
 ;; end pacifier
 
-;; Is it XEmacs?
-(defconst ediff-xemacs-p (featurep 'xemacs))
-;; Is it Emacs?
-(defconst ediff-emacs-p (not ediff-xemacs-p))
-
 ;; This is used to avoid compilation warnings. When emacs/xemacs forms can
 ;; generate compile time warnings, we use this macro.
 ;; In this case, the macro will expand into the form that is appropriate to the
@@ -78,8 +69,8 @@ that Ediff doesn't know about.")
   (cond ((ediff-window-display-p))
        (ediff-force-faces)
        ((ediff-color-display-p))
-       (ediff-emacs-p (memq (ediff-device-type) '(pc)))
-       (ediff-xemacs-p (memq (ediff-device-type) '(tty pc)))
+       ((featurep 'emacs) (memq (ediff-device-type) '(pc)))
+       ((featurep 'xemacs) (memq (ediff-device-type) '(tty pc)))
        ))
 
 ;; toolbar support for emacs hasn't been implemented in ediff
@@ -102,7 +93,7 @@ that Ediff doesn't know about.")
        (boundp 'ediff-use-toolbar-p)
        ediff-use-toolbar-p))           ;Does the user want it ?
 
-;; Defines SYMBOL as an advertised local variable.
+;; Defines VAR as an advertised local variable.
 ;; Performs a defvar, then executes `make-variable-buffer-local' on
 ;; the variable.  Also sets the `permanent-local' property,
 ;; so that `kill-all-local-variables' (called by major-mode setting
@@ -110,6 +101,8 @@ that Ediff doesn't know about.")
 ;;
 ;; Plagiarised from `emerge-defvar-local' for XEmacs.
 (defmacro ediff-defvar-local (var value doc)
+  "Defines VAR as a local variable."
+  (declare (indent defun))
   `(progn
      (defvar ,var ,value ,doc)
      (make-variable-buffer-local ',var)
@@ -258,6 +251,8 @@ It needs to be killed when we quit the session.")
 ;; 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)
+  "Evaluates BODY in BUFFER."
+  (declare (indent 1) (debug (form body)))
   `(if (ediff-buffer-live-p ,buffer)
        (save-current-buffer
         (set-buffer ,buffer)
@@ -502,7 +497,7 @@ set local variables that determine how the display looks like."
 *** of %sEmacs, does not seem to be properly installed.
 ***
 *** Please contact your system administrator. "
-                                (if ediff-xemacs-p "X" "")))
+                                (if (featurep 'xemacs) "X" "")))
 
 ;; Selective browsing
 
@@ -559,24 +554,24 @@ See the documentation string of `ediff-focus-on-regexp-matches' for details.")
 
 
 ;; Highlighting
-(defcustom ediff-before-flag-bol (if ediff-xemacs-p (make-glyph "->>") "->>")
+(defcustom ediff-before-flag-bol (if (featurep 'xemacs) (make-glyph "->>") "->>")
   "*Flag placed before a highlighted block of differences, if block starts at beginning of a line."
   :type 'string
   :tag  "Region before-flag at beginning of line"
   :group 'ediff)
 
-(defcustom ediff-after-flag-eol  (if ediff-xemacs-p (make-glyph "<<-") "<<-")
+(defcustom ediff-after-flag-eol  (if (featurep 'xemacs) (make-glyph "<<-") "<<-")
   "*Flag placed after a highlighted block of differences, if block ends at end of a line."
   :type 'string
   :tag  "Region after-flag at end of line"
   :group 'ediff)
 
-(defcustom ediff-before-flag-mol (if ediff-xemacs-p (make-glyph "->>") "->>")
+(defcustom ediff-before-flag-mol (if (featurep 'xemacs) (make-glyph "->>") "->>")
   "*Flag placed before a highlighted block of differences, if block starts in mid-line."
   :type 'string
   :tag  "Region before-flag in the middle of line"
   :group 'ediff)
-(defcustom ediff-after-flag-mol  (if ediff-xemacs-p (make-glyph "<<-") "<<-")
+(defcustom ediff-after-flag-mol  (if (featurep 'xemacs) (make-glyph "<<-") "<<-")
   "*Flag placed after a highlighted block of differences, if block ends in mid-line."
   :type 'string
   :tag  "Region after-flag in the middle of line"
@@ -781,8 +776,8 @@ to temp files when Ediff needs to find fine differences."
 ;; testing for sufficiently high Emacs versions.
 (defun ediff-check-version (op major minor &optional type-of-emacs)
   (if (and (boundp 'emacs-major-version) (boundp 'emacs-minor-version))
-      (and (cond ((eq type-of-emacs 'xemacs) ediff-xemacs-p)
-                ((eq type-of-emacs 'emacs) ediff-emacs-p)
+      (and (cond ((eq type-of-emacs 'xemacs) (featurep 'xemacs))
+                ((eq type-of-emacs 'emacs) (featurep 'emacs))
                 (t t))
           (cond ((eq op '=) (and (= emacs-minor-version minor)
                                  (= emacs-major-version major)))
@@ -904,7 +899,7 @@ to temp files when Ediff needs to find fine differences."
 
 
 (defface ediff-current-diff-A
-  (if ediff-emacs-p
+  (if (featurep 'emacs)
       '((((class color) (min-colors 16))
         (:foreground "firebrick" :background "pale green"))
        (((class color))
@@ -925,7 +920,7 @@ this variable represents.")
 (ediff-hide-face ediff-current-diff-face-A)
 ;; Until custom.el for XEmacs starts supporting :inverse-video we do this.
 ;; This means that some user customization may be trashed.
-(if (and ediff-xemacs-p
+(if (and (featurep 'xemacs)
         (ediff-has-face-support-p)
         (not (ediff-color-display-p)))
     (copy-face 'modeline ediff-current-diff-face-A))
@@ -933,7 +928,7 @@ this variable represents.")
 
 
 (defface ediff-current-diff-B
-  (if ediff-emacs-p
+  (if (featurep 'emacs)
       '((((class color) (min-colors 16))
         (:foreground "DarkOrchid" :background "Yellow"))
        (((class color))
@@ -956,14 +951,14 @@ this variable represents.")
 (ediff-hide-face ediff-current-diff-face-B)
 ;; Until custom.el for XEmacs starts supporting :inverse-video we do this.
 ;; This means that some user customization may be trashed.
-(if (and ediff-xemacs-p
+(if (and (featurep 'xemacs)
         (ediff-has-face-support-p)
         (not (ediff-color-display-p)))
     (copy-face 'modeline ediff-current-diff-face-B))
 
 
 (defface ediff-current-diff-C
-  (if ediff-emacs-p
+  (if (featurep 'emacs)
       '((((class color) (min-colors 16))
         (:foreground "Navy" :background "Pink"))
        (((class color))
@@ -984,14 +979,14 @@ this variable represents.")
 (ediff-hide-face ediff-current-diff-face-C)
 ;; Until custom.el for XEmacs starts supporting :inverse-video we do this.
 ;; This means that some user customization may be trashed.
-(if (and ediff-xemacs-p
+(if (and (featurep 'xemacs)
         (ediff-has-face-support-p)
         (not (ediff-color-display-p)))
     (copy-face 'modeline ediff-current-diff-face-C))
 
 
 (defface ediff-current-diff-Ancestor
-  (if ediff-emacs-p
+  (if (featurep 'emacs)
       '((((class color) (min-colors 16))
         (:foreground "Black" :background "VioletRed"))
        (((class color))
@@ -1012,14 +1007,14 @@ this variable represents.")
 (ediff-hide-face ediff-current-diff-face-Ancestor)
 ;; Until custom.el for XEmacs starts supporting :inverse-video we do this.
 ;; This means that some user customization may be trashed.
-(if (and ediff-xemacs-p
+(if (and (featurep 'xemacs)
         (ediff-has-face-support-p)
         (not (ediff-color-display-p)))
     (copy-face 'modeline ediff-current-diff-face-Ancestor))
 
 
 (defface ediff-fine-diff-A
-  (if ediff-emacs-p
+  (if (featurep 'emacs)
       '((((class color) (min-colors 16))
         (:foreground "Navy" :background "sky blue"))
        (((class color))
@@ -1040,7 +1035,7 @@ this variable represents.")
 (ediff-hide-face ediff-fine-diff-face-A)
 
 (defface ediff-fine-diff-B
-  (if ediff-emacs-p
+  (if (featurep 'emacs)
       '((((class color) (min-colors 16))
         (:foreground "Black" :background "cyan"))
        (((class color))
@@ -1061,7 +1056,7 @@ this variable represents.")
 (ediff-hide-face ediff-fine-diff-face-B)
 
 (defface ediff-fine-diff-C
-  (if ediff-emacs-p
+  (if (featurep 'emacs)
       '((((type pc))
         (:foreground "white" :background "Turquoise"))
        (((class color) (min-colors 16))
@@ -1087,7 +1082,7 @@ this variable represents.")
 (ediff-hide-face ediff-fine-diff-face-C)
 
 (defface ediff-fine-diff-Ancestor
-  (if ediff-emacs-p
+  (if (featurep 'emacs)
       '((((class color) (min-colors 16))
         (:foreground "Black" :background "Green"))
        (((class color))
@@ -1119,7 +1114,7 @@ this variable represents.")
        (t "Stipple")))
 
 (defface ediff-even-diff-A
-  (if ediff-emacs-p
+  (if (featurep 'emacs)
       `((((type pc))
         (:foreground "green3" :background "light grey"))
        (((class color) (min-colors 16))
@@ -1145,7 +1140,7 @@ this variable represents.")
 (ediff-hide-face ediff-even-diff-face-A)
 
 (defface ediff-even-diff-B
-  (if ediff-emacs-p
+  (if (featurep 'emacs)
       `((((class color) (min-colors 16))
         (:foreground "White" :background "Grey"))
        (((class color))
@@ -1166,7 +1161,7 @@ this variable represents.")
 (ediff-hide-face ediff-even-diff-face-B)
 
 (defface ediff-even-diff-C
-  (if ediff-emacs-p
+  (if (featurep 'emacs)
       `((((type pc))
         (:foreground "yellow3" :background "light grey"))
        (((class color) (min-colors 16))
@@ -1192,7 +1187,7 @@ this variable represents.")
 (ediff-hide-face ediff-even-diff-face-C)
 
 (defface ediff-even-diff-Ancestor
-  (if ediff-emacs-p
+  (if (featurep 'emacs)
       `((((type pc))
         (:foreground "cyan3" :background "light grey"))
        (((class color) (min-colors 16))
@@ -1225,7 +1220,7 @@ this variable represents.")
     (Ancestor . ediff-even-diff-Ancestor)))
 
 (defface ediff-odd-diff-A
-  (if ediff-emacs-p
+  (if (featurep 'emacs)
       '((((type pc))
         (:foreground "green3" :background "gray40"))
        (((class color) (min-colors 16))
@@ -1250,7 +1245,7 @@ this variable represents.")
 
 
 (defface ediff-odd-diff-B
-  (if ediff-emacs-p
+  (if (featurep 'emacs)
       '((((type pc))
         (:foreground "White" :background "gray40"))
        (((class color) (min-colors 16))
@@ -1274,7 +1269,7 @@ this variable represents.")
 (ediff-hide-face ediff-odd-diff-face-B)
 
 (defface ediff-odd-diff-C
-  (if ediff-emacs-p
+  (if (featurep 'emacs)
       '((((type pc))
         (:foreground "yellow3" :background "gray40"))
        (((class color) (min-colors 16))
@@ -1298,7 +1293,7 @@ this variable represents.")
 (ediff-hide-face ediff-odd-diff-face-C)
 
 (defface ediff-odd-diff-Ancestor
-  (if ediff-emacs-p
+  (if (featurep 'emacs)
       '((((class color) (min-colors 16))
         (:foreground "cyan3" :background "gray40"))
        (((class color))
@@ -1406,13 +1401,14 @@ 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.
-nil means don't save automatically.  t means always save.  Anything else
-means save automatically only if the merge job is part of a group of jobs, such
-as `ediff-merge-directory' or `ediff-merge-directory-revisions'."
+With value nil, don't save automatically.  With value t, always
+save.  Anything else means save automatically only if the merge
+job is part of a group of jobs, such as `ediff-merge-directory'
+or `ediff-merge-directory-revisions'."
   :type '(choice (const nil) (const t) (const group-jobs-only))
   :group 'ediff-merge)
 (make-variable-buffer-local 'ediff-autostore-merges)
@@ -1464,7 +1460,7 @@ This default should work without changes."
   :group 'ediff)
 
 ;; needed to simulate frame-char-width in XEmacs.
-(defvar ediff-H-glyph (if ediff-xemacs-p (make-glyph "H")))
+(defvar ediff-H-glyph (if (featurep 'xemacs) (make-glyph "H")))
 
 
 ;; Temporary file used for refining difference regions in buffer A.
@@ -1580,7 +1576,7 @@ This default should work without changes."
         )
        ((ediff-key-press-event-p event)
         (point))
-       (t (error nil))))
+       (t (error "Error"))))
 
 (defun ediff-event-buffer (event)
   (cond ((ediff-mouse-event-p event)
@@ -1591,7 +1587,7 @@ This default should work without changes."
         )
        ((ediff-key-press-event-p event)
         (current-buffer))
-       (t (error nil))))
+       (t (error "Error"))))
 
 (defun ediff-event-key (event-or-key)
   (ediff-cond-compile-for-xemacs-or-emacs
@@ -1625,7 +1621,7 @@ This default should work without changes."
   (or frame (setq frame (selected-frame)))
   (if (ediff-window-display-p)
       (let ((frame-or-wind frame))
-       (if ediff-xemacs-p
+       (if (featurep 'xemacs)
            (setq frame-or-wind (frame-selected-window frame)))
        (or do-not-grab-mouse
            ;; don't set mouse if the user said to never do this
@@ -1867,15 +1863,16 @@ Unless optional argument INPLACE is non-nil, return a new string."
             (set-buffer ,old-buffer)
             (set-syntax-table ,old-table)))))))
 
+
 (provide 'ediff-init)
 
 
 
-;;; Local Variables:
-;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
-;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1)
-;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body))
-;;; End:
+;; Local Variables:
+;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
+;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1)
+;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body))
+;; End:
 
-;;; arch-tag: fa31d384-1e70-4d4b-82a7-3e96307c46f5
+;; arch-tag: fa31d384-1e70-4d4b-82a7-3e96307c46f5
 ;;; ediff-init.el ends here