comparison lisp/ediff-init.el @ 26585:3ec5a485d0ab

*** empty log message ***
author Michael Kifer <kifer@cs.stonybrook.edu>
date Thu, 25 Nov 1999 04:34:23 +0000
parents 4f315ca65976
children 641e43bad886
comparison
equal deleted inserted replaced
26584:7547a144b80a 26585:3ec5a485d0ab
82 ;; so that `kill-all-local-variables' (called by major-mode setting 82 ;; so that `kill-all-local-variables' (called by major-mode setting
83 ;; commands) won't destroy Ediff control variables. 83 ;; commands) won't destroy Ediff control variables.
84 ;; 84 ;;
85 ;; Plagiarised from `emerge-defvar-local' for XEmacs. 85 ;; Plagiarised from `emerge-defvar-local' for XEmacs.
86 (defmacro ediff-defvar-local (var value doc) 86 (defmacro ediff-defvar-local (var value doc)
87 (` (progn 87 `(progn
88 (defvar (, var) (, value) (, doc)) 88 (defvar ,var ,value ,doc)
89 (make-variable-buffer-local '(, var)) 89 (make-variable-buffer-local ',var)
90 (put '(, var) 'permanent-local t)))) 90 (put ',var 'permanent-local t)))
91 91
92 92
93 93
94 ;; Variables that control each Ediff session---local to the control buffer. 94 ;; Variables that control each Ediff session---local to the control buffer.
95 95
112 (?B . ediff-buffer-B) 112 (?B . ediff-buffer-B)
113 (?C . ediff-buffer-C))) 113 (?C . ediff-buffer-C)))
114 114
115 ;;; Macros 115 ;;; Macros
116 (defmacro ediff-odd-p (arg) 116 (defmacro ediff-odd-p (arg)
117 (` (eq (logand (, arg) 1) 1))) 117 `(eq (logand ,arg 1) 1))
118 118
119 (defmacro ediff-buffer-live-p (buf) 119 (defmacro ediff-buffer-live-p (buf)
120 (` (and (, buf) (get-buffer (, buf)) (buffer-name (get-buffer (, buf)))))) 120 `(and ,buf (get-buffer ,buf) (buffer-name (get-buffer ,buf))))
121 121
122 (defmacro ediff-get-buffer (arg) 122 (defmacro ediff-get-buffer (arg)
123 (` (cond ((eq (, arg) 'A) ediff-buffer-A) 123 `(cond ((eq ,arg 'A) ediff-buffer-A)
124 ((eq (, arg) 'B) ediff-buffer-B) 124 ((eq ,arg 'B) ediff-buffer-B)
125 ((eq (, arg) 'C) ediff-buffer-C) 125 ((eq ,arg 'C) ediff-buffer-C)
126 ((eq (, arg) 'Ancestor) ediff-ancestor-buffer) 126 ((eq ,arg 'Ancestor) ediff-ancestor-buffer)
127 ) 127 ))
128 ))
129 128
130 (defmacro ediff-get-value-according-to-buffer-type (buf-type list) 129 (defmacro ediff-get-value-according-to-buffer-type (buf-type list)
131 (` (cond ((eq (, buf-type) 'A) (nth 0 (, list))) 130 `(cond ((eq ,buf-type 'A) (nth 0 ,list))
132 ((eq (, buf-type) 'B) (nth 1 (, list))) 131 ((eq ,buf-type 'B) (nth 1 ,list))
133 ((eq (, buf-type) 'C) (nth 2 (, list)))))) 132 ((eq ,buf-type 'C) (nth 2 ,list))
133 ))
134 134
135 (defmacro ediff-char-to-buftype (arg) 135 (defmacro ediff-char-to-buftype (arg)
136 (` (cond ((memq (, arg) '(?a ?A)) 'A) 136 `(cond ((memq ,arg '(?a ?A)) 'A)
137 ((memq (, arg) '(?b ?B)) 'B) 137 ((memq ,arg '(?b ?B)) 'B)
138 ((memq (, arg) '(?c ?C)) 'C) 138 ((memq ,arg '(?c ?C)) 'C)
139 ) 139 ))
140 ))
141 140
142 141
143 ;; A-list is supposed to be of the form (A . symb) (B . symb)...) 142 ;; A-list is supposed to be of the form (A . symb) (B . symb)...)
144 ;; where the first part of any association is a buffer type and the second is 143 ;; where the first part of any association is a buffer type and the second is
145 ;; an appropriate symbol. Given buffer-type, this function returns the 144 ;; an appropriate symbol. Given buffer-type, this function returns the
152 (B . ediff-difference-vector-B) 151 (B . ediff-difference-vector-B)
153 (C . ediff-difference-vector-C) 152 (C . ediff-difference-vector-C)
154 (Ancestor . ediff-difference-vector-Ancestor))) 153 (Ancestor . ediff-difference-vector-Ancestor)))
155 154
156 (defmacro ediff-get-difference (n buf-type) 155 (defmacro ediff-get-difference (n buf-type)
157 (` (aref 156 `(aref
158 (symbol-value 157 (symbol-value
159 (ediff-get-symbol-from-alist 158 (ediff-get-symbol-from-alist
160 (, buf-type) ediff-difference-vector-alist)) 159 ,buf-type ediff-difference-vector-alist))
161 (, n)))) 160 ,n))
162 161
163 ;; Tell if it has been previously determined that the region has 162 ;; Tell if it has been previously determined that the region has
164 ;; no diffs other than the white space and newlines 163 ;; no diffs other than the white space and newlines
165 ;; The argument, N, is the diff region number used by Ediff to index the 164 ;; The argument, N, is the diff region number used by Ediff to index the
166 ;; diff vector. It is 1 less than the number seen by the user. 165 ;; diff vector. It is 1 less than the number seen by the user.
180 ;; fine-diff-vector is a vector [fine-diff fine-diff fine-diff ...] 179 ;; fine-diff-vector is a vector [fine-diff fine-diff fine-diff ...]
181 ;; no-fine-diffs-flag says if there are fine differences. 180 ;; no-fine-diffs-flag says if there are fine differences.
182 ;; state-of-difference is A, B, C, or nil, indicating which buffer is 181 ;; state-of-difference is A, B, C, or nil, indicating which buffer is
183 ;; different from the other two (used only in 3-way jobs). 182 ;; different from the other two (used only in 3-way jobs).
184 (defmacro ediff-no-fine-diffs-p (n) 183 (defmacro ediff-no-fine-diffs-p (n)
185 (` (aref (ediff-get-difference (, n) 'A) 2))) 184 `(aref (ediff-get-difference ,n 'A) 2))
186 185
187 (defmacro ediff-get-diff-overlay-from-diff-record (diff-rec) 186 (defmacro ediff-get-diff-overlay-from-diff-record (diff-rec)
188 (` (aref (, diff-rec) 0))) 187 `(aref ,diff-rec 0))
189 188
190 (defmacro ediff-get-diff-overlay (n buf-type) 189 (defmacro ediff-get-diff-overlay (n buf-type)
191 (` (ediff-get-diff-overlay-from-diff-record 190 `(ediff-get-diff-overlay-from-diff-record
192 (ediff-get-difference (, n) (, buf-type))))) 191 (ediff-get-difference ,n ,buf-type)))
193 192
194 (defmacro ediff-get-fine-diff-vector-from-diff-record (diff-rec) 193 (defmacro ediff-get-fine-diff-vector-from-diff-record (diff-rec)
195 (` (aref (, diff-rec) 1))) 194 `(aref ,diff-rec 1))
196 195
197 (defmacro ediff-set-fine-diff-vector (n buf-type fine-vec) 196 (defmacro ediff-set-fine-diff-vector (n buf-type fine-vec)
198 (` (aset (ediff-get-difference (, n) (, buf-type)) 1 (, fine-vec)))) 197 `(aset (ediff-get-difference ,n ,buf-type) 1 ,fine-vec))
199 198
200 (defmacro ediff-get-state-of-diff (n buf-type) 199 (defmacro ediff-get-state-of-diff (n buf-type)
201 (` (if (ediff-buffer-live-p ediff-buffer-C) 200 `(if (ediff-buffer-live-p ediff-buffer-C)
202 (aref (ediff-get-difference (, n) (, buf-type)) 3)))) 201 (aref (ediff-get-difference ,n ,buf-type) 3)))
203 (defmacro ediff-set-state-of-diff (n buf-type val) 202 (defmacro ediff-set-state-of-diff (n buf-type val)
204 (` (aset (ediff-get-difference (, n) (, buf-type)) 3 (, val)))) 203 `(aset (ediff-get-difference ,n ,buf-type) 3 ,val))
205 204
206 (defmacro ediff-get-state-of-merge (n) 205 (defmacro ediff-get-state-of-merge (n)
207 (` (if ediff-state-of-merge 206 `(if ediff-state-of-merge
208 (aref (aref ediff-state-of-merge (, n)) 0)))) 207 (aref (aref ediff-state-of-merge ,n) 0)))
209 (defmacro ediff-set-state-of-merge (n val) 208 (defmacro ediff-set-state-of-merge (n val)
210 (` (if ediff-state-of-merge 209 `(if ediff-state-of-merge
211 (aset (aref ediff-state-of-merge (, n)) 0 (, val))))) 210 (aset (aref ediff-state-of-merge ,n) 0 ,val)))
212 211
213 (defmacro ediff-get-state-of-ancestor (n) 212 (defmacro ediff-get-state-of-ancestor (n)
214 (` (if ediff-state-of-merge 213 `(if ediff-state-of-merge
215 (aref (aref ediff-state-of-merge (, n)) 1)))) 214 (aref (aref ediff-state-of-merge ,n) 1)))
216 215
217 ;; if flag is t, puts a mark on diff region saying that 216 ;; if flag is t, puts a mark on diff region saying that
218 ;; the differences are in white space only. If flag is nil, 217 ;; the differences are in white space only. If flag is nil,
219 ;; the region is marked as essential (i.e., differences are 218 ;; the region is marked as essential (i.e., differences are
220 ;; not just in the white space and newlines.) 219 ;; not just in the white space and newlines.)
221 (defmacro ediff-mark-diff-as-space-only (n flag) 220 (defmacro ediff-mark-diff-as-space-only (n flag)
222 (` (aset (ediff-get-difference (, n) 'A) 2 (, flag)))) 221 `(aset (ediff-get-difference ,n 'A) 2 ,flag))
223 222
224 (defmacro ediff-get-fine-diff-vector (n buf-type) 223 (defmacro ediff-get-fine-diff-vector (n buf-type)
225 (` (ediff-get-fine-diff-vector-from-diff-record 224 `(ediff-get-fine-diff-vector-from-diff-record
226 (ediff-get-difference (, n) (, buf-type))))) 225 (ediff-get-difference ,n ,buf-type)))
227 226
228 ;; Macro to switch to BUFFER, evaluate BODY, returns to original buffer. 227 ;; Macro to switch to BUFFER, evaluate BODY, returns to original buffer.
229 ;; Doesn't save the point and mark. 228 ;; Doesn't save the point and mark.
230 ;; This is `with-current-buffer' with the added test for live buffers." 229 ;; This is `with-current-buffer' with the added test for live buffers."
231 (defmacro ediff-with-current-buffer (buffer &rest body) 230 (defmacro ediff-with-current-buffer (buffer &rest body)
232 (` (if (ediff-buffer-live-p (, buffer)) 231 `(if (ediff-buffer-live-p ,buffer)
233 (save-current-buffer 232 (save-current-buffer
234 (set-buffer (, buffer)) 233 (set-buffer ,buffer)
235 (,@ body)) 234 ,@body)
236 (or (eq this-command 'ediff-quit) 235 (or (eq this-command 'ediff-quit)
237 (error ediff-KILLED-VITAL-BUFFER)) 236 (error ediff-KILLED-VITAL-BUFFER))
238 ))) 237 ))
239 238
240 239
241 (defsubst ediff-multiframe-setup-p () 240 (defsubst ediff-multiframe-setup-p ()
242 (and (ediff-window-display-p) ediff-multiframe)) 241 (and (ediff-window-display-p) ediff-multiframe))
243 242
244 (defmacro ediff-narrow-control-frame-p () 243 (defmacro ediff-narrow-control-frame-p ()
245 (` (and (ediff-multiframe-setup-p) 244 `(and (ediff-multiframe-setup-p)
246 (equal ediff-help-message ediff-brief-message-string)))) 245 (equal ediff-help-message ediff-brief-message-string)))
247 246
248 (defmacro ediff-3way-comparison-job () 247 (defmacro ediff-3way-comparison-job ()
249 (` (memq 248 `(memq
250 ediff-job-name 249 ediff-job-name
251 '(ediff-files3 ediff-buffers3)))) 250 '(ediff-files3 ediff-buffers3)))
252 (ediff-defvar-local ediff-3way-comparison-job nil "") 251 (ediff-defvar-local ediff-3way-comparison-job nil "")
253 252
254 (defmacro ediff-merge-job () 253 (defmacro ediff-merge-job ()
255 (` (memq 254 `(memq
256 ediff-job-name 255 ediff-job-name
257 '(ediff-merge-files 256 '(ediff-merge-files
258 ediff-merge-buffers 257 ediff-merge-buffers
259 ediff-merge-files-with-ancestor 258 ediff-merge-files-with-ancestor
260 ediff-merge-buffers-with-ancestor 259 ediff-merge-buffers-with-ancestor
261 ediff-merge-revisions 260 ediff-merge-revisions
262 ediff-merge-revisions-with-ancestor)))) 261 ediff-merge-revisions-with-ancestor)))
263 (ediff-defvar-local ediff-merge-job nil "") 262 (ediff-defvar-local ediff-merge-job nil "")
264 263
265 (defmacro ediff-merge-with-ancestor-job () 264 (defmacro ediff-merge-with-ancestor-job ()
266 (` (memq 265 `(memq
267 ediff-job-name 266 ediff-job-name
268 '(ediff-merge-files-with-ancestor 267 '(ediff-merge-files-with-ancestor
269 ediff-merge-buffers-with-ancestor 268 ediff-merge-buffers-with-ancestor
270 ediff-merge-revisions-with-ancestor)))) 269 ediff-merge-revisions-with-ancestor)))
271 (ediff-defvar-local ediff-merge-with-ancestor-job nil "") 270 (ediff-defvar-local ediff-merge-with-ancestor-job nil "")
272 271
273 (defmacro ediff-3way-job () 272 (defmacro ediff-3way-job ()
274 (` (or ediff-3way-comparison-job ediff-merge-job))) 273 `(or ediff-3way-comparison-job ediff-merge-job))
275 (ediff-defvar-local ediff-3way-job nil "") 274 (ediff-defvar-local ediff-3way-job nil "")
276 275
277 ;; A diff3 job is like a 3way job, but ediff-merge doesn't require the use 276 ;; A diff3 job is like a 3way job, but ediff-merge doesn't require the use
278 ;; of diff3. 277 ;; of diff3.
279 (defmacro ediff-diff3-job () 278 (defmacro ediff-diff3-job ()
280 (` (or ediff-3way-comparison-job 279 `(or ediff-3way-comparison-job
281 ediff-merge-with-ancestor-job))) 280 ediff-merge-with-ancestor-job))
282 (ediff-defvar-local ediff-diff3-job nil "") 281 (ediff-defvar-local ediff-diff3-job nil "")
283 282
284 (defmacro ediff-windows-job () 283 (defmacro ediff-windows-job ()
285 (` (memq ediff-job-name '(ediff-windows-wordwise ediff-windows-linewise)))) 284 `(memq ediff-job-name '(ediff-windows-wordwise ediff-windows-linewise)))
286 (ediff-defvar-local ediff-windows-job nil "") 285 (ediff-defvar-local ediff-windows-job nil "")
287 286
288 (defmacro ediff-word-mode-job () 287 (defmacro ediff-word-mode-job ()
289 (` (memq ediff-job-name '(ediff-windows-wordwise ediff-regions-wordwise)))) 288 `(memq ediff-job-name '(ediff-windows-wordwise ediff-regions-wordwise)))
290 (ediff-defvar-local ediff-word-mode-job nil "") 289 (ediff-defvar-local ediff-word-mode-job nil "")
291 290
292 (defmacro ediff-narrow-job () 291 (defmacro ediff-narrow-job ()
293 (` (memq ediff-job-name '(ediff-windows-wordwise 292 `(memq ediff-job-name '(ediff-windows-wordwise
294 ediff-regions-wordwise 293 ediff-regions-wordwise
295 ediff-windows-linewise 294 ediff-windows-linewise
296 ediff-regions-linewise)))) 295 ediff-regions-linewise)))
297 (ediff-defvar-local ediff-narrow-job nil "") 296 (ediff-defvar-local ediff-narrow-job nil "")
298 297
299 ;; Note: ediff-merge-directory-revisions-with-ancestor is not treated as an 298 ;; Note: ediff-merge-directory-revisions-with-ancestor is not treated as an
300 ;; ancestor metajob, since it behaves differently. 299 ;; ancestor metajob, since it behaves differently.
301 (defsubst ediff-ancestor-metajob (&optional metajob) 300 (defsubst ediff-ancestor-metajob (&optional metajob)
993 this variable represents.") 992 this variable represents.")
994 (ediff-hide-face 'ediff-fine-diff-face-Ancestor) 993 (ediff-hide-face 'ediff-fine-diff-face-Ancestor)
995 994
996 ;; Some installs don't have stipple or Stipple. So, try them in turn. 995 ;; Some installs don't have stipple or Stipple. So, try them in turn.
997 (defvar stipple-pixmap 996 (defvar stipple-pixmap
998 (cond ((not (ediff-has-face-support-p))) 997 (cond ((not (ediff-has-face-support-p)) nil)
999 ((and (boundp 'x-bitmap-file-path) 998 ((and (boundp 'x-bitmap-file-path)
1000 (locate-library "stipple" t x-bitmap-file-path)) "stipple") 999 (locate-library "stipple" t x-bitmap-file-path)) "stipple")
1001 ((and (boundp 'mswindowsx-bitmap-file-path) 1000 ((and (boundp 'mswindowsx-bitmap-file-path)
1002 (locate-library "stipple" t mswindowsx-bitmap-file-path)) "stipple") 1001 (locate-library "stipple" t mswindowsx-bitmap-file-path)) "stipple")
1003 (t "Stipple"))) 1002 (t "Stipple")))
1004 1003
1005 (defface ediff-even-diff-face-A 1004 (defface ediff-even-diff-face-A
1006 (` ((((class color)) (:foreground "Black" :background "light grey")) 1005 `((((class color)) (:foreground "Black" :background "light grey"))
1007 (t (:italic t :stipple (, stipple-pixmap))))) 1006 (t (:italic t :stipple ,stipple-pixmap)))
1008 "Face for highlighting even-numbered non-current differences in buffer A." 1007 "Face for highlighting even-numbered non-current differences in buffer A."
1009 :group 'ediff-highlighting) 1008 :group 'ediff-highlighting)
1010 ;; An internal variable. Ediff takes the face from here. When unhighlighting, 1009 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1011 ;; this variable is set to nil, then again to the appropriate face. 1010 ;; this variable is set to nil, then again to the appropriate face.
1012 (defvar ediff-even-diff-face-A 'ediff-even-diff-face-A 1011 (defvar ediff-even-diff-face-A 'ediff-even-diff-face-A
1015 widget to customize the actual face object `ediff-even-diff-face-A' 1014 widget to customize the actual face object `ediff-even-diff-face-A'
1016 this variable represents.") 1015 this variable represents.")
1017 (ediff-hide-face 'ediff-even-diff-face-A) 1016 (ediff-hide-face 'ediff-even-diff-face-A)
1018 1017
1019 (defface ediff-even-diff-face-B 1018 (defface ediff-even-diff-face-B
1020 (` ((((class color)) (:foreground "White" :background "Grey")) 1019 `((((class color)) (:foreground "White" :background "Grey"))
1021 (t (:italic t :stipple (, stipple-pixmap))))) 1020 (t (:italic t :stipple ,stipple-pixmap)))
1022 "Face for highlighting even-numbered non-current differences in buffer B." 1021 "Face for highlighting even-numbered non-current differences in buffer B."
1023 :group 'ediff-highlighting) 1022 :group 'ediff-highlighting)
1024 ;; An internal variable. Ediff takes the face from here. When unhighlighting, 1023 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1025 ;; this variable is set to nil, then again to the appropriate face. 1024 ;; this variable is set to nil, then again to the appropriate face.
1026 (defvar ediff-even-diff-face-B 'ediff-even-diff-face-B 1025 (defvar ediff-even-diff-face-B 'ediff-even-diff-face-B
1029 widget to customize the actual face object `ediff-even-diff-face-B' 1028 widget to customize the actual face object `ediff-even-diff-face-B'
1030 this variable represents.") 1029 this variable represents.")
1031 (ediff-hide-face 'ediff-even-diff-face-B) 1030 (ediff-hide-face 'ediff-even-diff-face-B)
1032 1031
1033 (defface ediff-even-diff-face-C 1032 (defface ediff-even-diff-face-C
1034 (` ((((class color)) (:foreground "Black" :background "light grey")) 1033 `((((class color)) (:foreground "Black" :background "light grey"))
1035 (t (:italic t :stipple (, stipple-pixmap))))) 1034 (t (:italic t :stipple ,stipple-pixmap)))
1036 "Face for highlighting even-numbered non-current differences in buffer C." 1035 "Face for highlighting even-numbered non-current differences in buffer C."
1037 :group 'ediff-highlighting) 1036 :group 'ediff-highlighting)
1038 ;; An internal variable. Ediff takes the face from here. When unhighlighting, 1037 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1039 ;; this variable is set to nil, then again to the appropriate face. 1038 ;; this variable is set to nil, then again to the appropriate face.
1040 (defvar ediff-even-diff-face-C 'ediff-even-diff-face-C 1039 (defvar ediff-even-diff-face-C 'ediff-even-diff-face-C
1043 widget to customize the actual face object `ediff-even-diff-face-C' 1042 widget to customize the actual face object `ediff-even-diff-face-C'
1044 this variable represents.") 1043 this variable represents.")
1045 (ediff-hide-face 'ediff-even-diff-face-C) 1044 (ediff-hide-face 'ediff-even-diff-face-C)
1046 1045
1047 (defface ediff-even-diff-face-Ancestor 1046 (defface ediff-even-diff-face-Ancestor
1048 (` ((((class color)) (:foreground "White" :background "Grey")) 1047 `((((class color)) (:foreground "White" :background "Grey"))
1049 (t (:italic t :stipple (, stipple-pixmap))))) 1048 (t (:italic t :stipple ,stipple-pixmap)))
1050 "Face for highlighting even-numbered non-current differences in the ancestor buffer." 1049 "Face for highlighting even-numbered non-current differences in the ancestor buffer."
1051 :group 'ediff-highlighting) 1050 :group 'ediff-highlighting)
1052 ;; An internal variable. Ediff takes the face from here. When unhighlighting, 1051 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1053 ;; this variable is set to nil, then again to the appropriate face. 1052 ;; this variable is set to nil, then again to the appropriate face.
1054 (defvar ediff-even-diff-face-Ancestor 'ediff-even-diff-face-Ancestor 1053 (defvar ediff-even-diff-face-Ancestor 'ediff-even-diff-face-Ancestor