]> code.delx.au - gnu-emacs/blobdiff - lisp/vc/ediff-init.el
lisp/net/{eudc,ldap}: Merge branch streamline-eudc-configuration
[gnu-emacs] / lisp / vc / ediff-init.el
index 787a8b7c0f1580cc8a894d0a44d99e66a1838b0a..d6b538cff2bde2fc1789f9e375e7a994340f4cfe 100644 (file)
@@ -1,6 +1,6 @@
 ;;; ediff-init.el --- Macros, variables, and defsubsts used by Ediff
 
-;; Copyright (C) 1994-2011 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2015 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 ;; Package: ediff
@@ -24,6 +24,8 @@
 
 ;;; Code:
 
+(require 'cl-lib)
+
 ;; Start compiler pacifier
 (defvar ediff-metajob-name)
 (defvar ediff-meta-buffer)
@@ -118,11 +120,8 @@ It needs to be killed when we quit the session.")
     (?C . ediff-buffer-C)))
 
 ;;; Macros
-(defmacro ediff-odd-p (arg)
-  `(eq (logand ,arg 1) 1))
-
-(defmacro ediff-buffer-live-p (buf)
-  `(and ,buf (get-buffer ,buf) (buffer-name (get-buffer ,buf))))
+(defsubst ediff-buffer-live-p (buf)
+  (and buf (get-buffer buf) (buffer-name (get-buffer buf))))
 
 (defmacro ediff-get-buffer (arg)
   `(cond ((eq ,arg 'A) ediff-buffer-A)
@@ -370,7 +369,7 @@ It needs to be killed when we quit the session.")
             this-command)))
 
 (defgroup ediff-highlighting nil
-  "Hilighting of difference regions in Ediff."
+  "Highlighting of difference regions in Ediff."
   :prefix "ediff-"
   :group 'ediff)
 
@@ -567,7 +566,8 @@ and ediff-after-flag.  On a non-window system, differences are always
 highlighted using ASCII flags."
   :type 'boolean
   :group 'ediff-highlighting)
-(ediff-defvar-local ediff-use-faces t "")
+(make-variable-buffer-local 'ediff-use-faces)
+(put 'ediff-use-faces 'permanent-local t)
 
 ;; this indicates that diff regions are word-size, so fine diffs are
 ;; permanently nixed; used in ediff-windows-wordwise and ediff-regions-wordwise
@@ -594,7 +594,7 @@ highlighted using ASCII flags."
 (ediff-defvar-local ediff-start-narrowed t
   "Non-nil means start narrowed, if doing ediff-windows-* or ediff-regions-*")
 (ediff-defvar-local ediff-quit-widened t
-  "*Non-nil means: when finished, Ediff widens buffers A/B.
+  "Non-nil means: when finished, Ediff widens buffers A/B.
 Actually, Ediff restores the scope of visibility that existed at startup.")
 
 (defcustom ediff-keep-variants t
@@ -610,7 +610,8 @@ Otherwise, all difference regions are highlighted, but the selected region is
 shown in brighter colors."
   :type 'boolean
   :group 'ediff-highlighting)
-(ediff-defvar-local ediff-highlight-all-diffs t "")
+(make-variable-buffer-local 'ediff-highlight-all-diffs)
+(put 'ediff-highlight-all-diffs 'permanent-local t)
 
 
 ;; The suffix of the control buffer name.
@@ -705,9 +706,6 @@ shown in brighter colors."
 ;; List of difference overlays disturbed by working with the current diff.
 (defvar ediff-disturbed-overlays nil "")
 
-;; Priority of non-selected overlays.
-(defvar ediff-shadow-overlay-priority  100 "")
-
 (defcustom ediff-version-control-package 'vc
   "Version control package used.
 Currently, Ediff supports vc.el, rcs.el, pcl-cvs.el, and generic-sc.el.  The
@@ -753,6 +751,7 @@ to temp files in buffer jobs and when Ediff needs to find fine differences."
   "Check the current version against MAJOR and MINOR version numbers.
 The comparison uses operator OP, which may be any of: =, >, >=, <, <=.
 TYPE-OF-EMACS is either 'xemacs or 'emacs."
+  (declare (obsolete version< "23.1"))
   (and (cond ((eq type-of-emacs 'xemacs) (featurep 'xemacs))
             ((eq type-of-emacs 'emacs) (featurep 'emacs))
             (t))
@@ -767,9 +766,6 @@ TYPE-OF-EMACS is either 'xemacs or 'emacs."
             (t
              (error "%S: Invalid op in ediff-check-version" op)))))
 
-;; ediff-check-version seems to be totally unused anyway.
-(make-obsolete 'ediff-check-version 'version< "23.1")
-
 (defun ediff-color-display-p ()
   (condition-case nil
       (if (featurep 'xemacs)
@@ -786,19 +782,12 @@ TYPE-OF-EMACS is either 'xemacs or 'emacs."
   "")
 
 
-(if (ediff-window-display-p)
-    (if (featurep 'xemacs)
-       (progn
-         (defalias 'ediff-display-pixel-width 'device-pixel-width)
-         (defalias 'ediff-display-pixel-height 'device-pixel-height))
-      (defalias 'ediff-display-pixel-width
-       (if (fboundp 'display-pixel-width)
-           'display-pixel-width
-         'x-display-pixel-width))
-      (defalias 'ediff-display-pixel-height
-       (if (fboundp 'display-pixel-height)
-           'display-pixel-height
-         'x-display-pixel-height))))
+(if (featurep 'xemacs)
+    (progn
+      (defalias 'ediff-display-pixel-width 'device-pixel-width)
+      (defalias 'ediff-display-pixel-height 'device-pixel-height))
+  (defalias 'ediff-display-pixel-width 'display-pixel-width)
+  (defalias 'ediff-display-pixel-height 'display-pixel-height))
 
 ;; A-list of current-diff-overlay symbols associated with buf types
 (defconst ediff-current-diff-overlay-alist
@@ -817,9 +806,9 @@ TYPE-OF-EMACS is either 'xemacs or 'emacs."
 
 (defun ediff-set-overlay-face (extent face)
   (ediff-overlay-put extent 'face face)
-  (ediff-overlay-put extent 'help-echo 'ediff-region-help-echo))
+  (ediff-overlay-put extent 'help-echo (if face 'ediff-region-help-echo)))
 
-(defun ediff-region-help-echo (extent-or-window &optional overlay point)
+(defun ediff-region-help-echo (extent-or-window &optional overlay _point)
   (unless overlay
     (setq overlay extent-or-window))
   (let ((is-current (ediff-overlay-get overlay 'ediff))
@@ -860,7 +849,11 @@ TYPE-OF-EMACS is either 'xemacs or 'emacs."
 
 (defface ediff-current-diff-A
   (if (featurep 'emacs)
-      '((((class color) (min-colors 16))
+      '((((class color) (min-colors 88) (background light))
+        :background "#ffdddd")
+       (((class color) (min-colors 88) (background dark))
+        :background "#553333")
+       (((class color) (min-colors 16))
         (:foreground "firebrick" :background "pale green"))
        (((class color))
         (:foreground "blue3" :background "yellow3"))
@@ -889,7 +882,11 @@ this variable represents.")
 
 (defface ediff-current-diff-B
   (if (featurep 'emacs)
-      '((((class color) (min-colors 16))
+      '((((class color) (min-colors 88) (background light))
+        :background "#ddffdd")
+       (((class color) (min-colors 88) (background dark))
+        :background "#335533")
+       (((class color) (min-colors 16))
         (:foreground "DarkOrchid" :background "Yellow"))
        (((class color))
         (:foreground "magenta3" :background "yellow3"
@@ -919,7 +916,11 @@ this variable represents.")
 
 (defface ediff-current-diff-C
   (if (featurep 'emacs)
-      '((((class color) (min-colors 16))
+      '((((class color) (min-colors 88) (background light))
+        :background "#ffffaa")
+       (((class color) (min-colors 88) (background dark))
+        :background "#888833")
+       (((class color) (min-colors 16))
         (:foreground "Navy" :background "Pink"))
        (((class color))
         (:foreground "cyan3" :background "yellow3" :weight bold))
@@ -947,7 +948,9 @@ this variable represents.")
 
 (defface ediff-current-diff-Ancestor
   (if (featurep 'emacs)
-      '((((class color) (min-colors 16))
+      '((((class color) (min-colors 88))
+        (:background "VioletRed"))
+       (((class color) (min-colors 16))
         (:foreground "Black" :background "VioletRed"))
        (((class color))
         (:foreground "black" :background "magenta3"))
@@ -975,7 +978,11 @@ this variable represents.")
 
 (defface ediff-fine-diff-A
   (if (featurep 'emacs)
-      '((((class color) (min-colors 16))
+      '((((class color) (min-colors 88) (background light))
+        :background "#ffbbbb")
+       (((class color) (min-colors 88) (background dark))
+        :background "#aa2222")
+       (((class color) (min-colors 16))
         (:foreground "Navy" :background "sky blue"))
        (((class color))
         (:foreground "white" :background "sky blue" :weight bold))
@@ -996,7 +1003,11 @@ this variable represents.")
 
 (defface ediff-fine-diff-B
   (if (featurep 'emacs)
-      '((((class color) (min-colors 16))
+      '((((class color) (min-colors 88) (background light))
+        :background "#aaffaa")
+       (((class color) (min-colors 88) (background dark))
+        :background "#22aa22")
+       (((class color) (min-colors 16))
         (:foreground "Black" :background "cyan"))
        (((class color))
         (:foreground "magenta3" :background "cyan3"))
@@ -1017,7 +1028,11 @@ this variable represents.")
 
 (defface ediff-fine-diff-C
   (if (featurep 'emacs)
-      '((((type pc))
+      '((((class color) (min-colors 88) (background light))
+        :background "#ffff55")
+       (((class color) (min-colors 88) (background dark))
+        :background "#aaaa22")
+       (((type pc))
         (:foreground "white" :background "Turquoise"))
        (((class color) (min-colors 16))
         (:foreground "Black" :background "Turquoise"))
@@ -1043,7 +1058,9 @@ this variable represents.")
 
 (defface ediff-fine-diff-Ancestor
   (if (featurep 'emacs)
-      '((((class color) (min-colors 16))
+      '((((class color) (min-colors 88))
+        (:background "Green"))
+       (((class color) (min-colors 16))
         (:foreground "Black" :background "Green"))
        (((class color))
         (:foreground "red3" :background "green"))
@@ -1077,6 +1094,8 @@ this variable represents.")
   (if (featurep 'emacs)
       `((((type pc))
         (:foreground "green3" :background "light grey"))
+       (((class color) (min-colors 88))
+        (:background "light grey"))
        (((class color) (min-colors 16))
         (:foreground "Black" :background "light grey"))
        (((class color))
@@ -1101,7 +1120,9 @@ this variable represents.")
 
 (defface ediff-even-diff-B
   (if (featurep 'emacs)
-      `((((class color) (min-colors 16))
+      `((((class color) (min-colors 88))
+        (:background "Grey"))
+       (((class color) (min-colors 16))
         (:foreground "White" :background "Grey"))
        (((class color))
         (:foreground "blue3" :background "Grey" :weight bold))
@@ -1124,6 +1145,8 @@ this variable represents.")
   (if (featurep 'emacs)
       `((((type pc))
         (:foreground "yellow3" :background "light grey"))
+       (((class color) (min-colors 88))
+        (:background "light grey"))
        (((class color) (min-colors 16))
         (:foreground "Black" :background "light grey"))
        (((class color))
@@ -1150,6 +1173,8 @@ this variable represents.")
   (if (featurep 'emacs)
       `((((type pc))
         (:foreground "cyan3" :background "light grey"))
+       (((class color) (min-colors 88))
+        (:background "Grey"))
        (((class color) (min-colors 16))
         (:foreground "White" :background "Grey"))
        (((class color))
@@ -1183,6 +1208,8 @@ this variable represents.")
   (if (featurep 'emacs)
       '((((type pc))
         (:foreground "green3" :background "gray40"))
+       (((class color) (min-colors 88))
+        (:background "Grey"))
        (((class color) (min-colors 16))
         (:foreground "White" :background "Grey"))
        (((class color))
@@ -1208,6 +1235,8 @@ this variable represents.")
   (if (featurep 'emacs)
       '((((type pc))
         (:foreground "White" :background "gray40"))
+       (((class color) (min-colors 88))
+        (:background "light grey"))
        (((class color) (min-colors 16))
         (:foreground "Black" :background "light grey"))
        (((class color))
@@ -1232,6 +1261,8 @@ this variable represents.")
   (if (featurep 'emacs)
       '((((type pc))
         (:foreground "yellow3" :background "gray40"))
+       (((class color) (min-colors 88))
+        (:background "Grey"))
        (((class color) (min-colors 16))
         (:foreground "White" :background "Grey"))
        (((class color))
@@ -1254,7 +1285,9 @@ this variable represents.")
 
 (defface ediff-odd-diff-Ancestor
   (if (featurep 'emacs)
-      '((((class color) (min-colors 16))
+      '((((class color) (min-colors 88))
+        (:background "gray40"))
+       (((class color) (min-colors 16))
         (:foreground "cyan3" :background "gray40"))
        (((class color))
         (:foreground "green3" :background "black" :weight bold))
@@ -1312,35 +1345,7 @@ this variable represents.")
 (ediff-defvar-local ediff-current-diff-overlay-Ancestor nil
   "Overlay for the current difference region in the ancestor buffer.")
 
-;; Compute priority of a current ediff overlay.
-(defun ediff-highest-priority (start end buffer)
-  (let ((pos (max 1 (1- start)))
-       ovr-list)
-    (if (featurep 'xemacs)
-       (1+ ediff-shadow-overlay-priority)
-      (ediff-with-current-buffer buffer
-       (while (< pos (min (point-max) (1+ end)))
-         (setq ovr-list (append (overlays-at pos) ovr-list))
-         (setq pos (next-overlay-change pos)))
-       (+ 1 ediff-shadow-overlay-priority
-          (apply 'max
-                 (cons
-                  1
-                  (mapcar
-                   (lambda (ovr)
-                     (if (and ovr
-                              ;; exclude ediff overlays from priority
-                              ;; calculation, or else priority will keep
-                              ;; increasing
-                              (null (ediff-overlay-get ovr 'ediff))
-                              (null (ediff-overlay-get ovr 'ediff-diff-num)))
-                         ;; use the overlay priority or 0
-                         (or (ediff-overlay-get ovr 'priority) 0)
-                       0))
-                   ovr-list))))))))
-
-
-(defvar ediff-toggle-read-only-function 'toggle-read-only
+(defvar ediff-toggle-read-only-function 'read-only-mode
   "Function to be used to toggle read-only status of the buffer.
 If nil, Ediff tries using the command bound to C-x C-q.")
 
@@ -1450,7 +1455,7 @@ This default should work without changes."
   ;; 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.
   (ediff-get-symbol-from-alist
-   buf-type (if (ediff-odd-p dif-num)
+   buf-type (if (cl-oddp dif-num)
                ediff-even-diff-face-alist
              ediff-odd-diff-face-alist)
    ))
@@ -1743,15 +1748,17 @@ Unless optional argument INPLACE is non-nil, return a new string."
 
 ;; If ediff modified mode line, strip the modification
 (defsubst ediff-strip-mode-line-format ()
-  (if (member (car mode-line-format) '(" A: " " B: " " C: " " Ancestor: "))
-      (setq mode-line-format (nth 2 mode-line-format))))
+  (and (consp mode-line-format)
+       (member (car mode-line-format)
+              '(" A: " " B: " " C: " " Ancestor: "))
+       (setq mode-line-format (nth 2 mode-line-format))))
 
 ;; Verify that we have a difference selected.
 (defsubst ediff-valid-difference-p (&optional n)
   (or n (setq n ediff-current-difference))
   (and (>= n 0) (< n ediff-number-of-differences)))
 
-(defsubst ediff-show-all-diffs (n)
+(defsubst ediff-show-all-diffs (_n)
   "Don't skip difference regions."
   nil)