Mercurial > emacs
comparison lisp/ediff-init.el @ 13128:b0ec8d932b35
(ediff-abbreviate-file-name): function modified.
(ediff-truncate-string-left): new function.
(ediff-strip-last-dir,ediff-key-press-event-p,ediff-event-point,
ediff-event-buffer): new functions.
(ediff-frame-has-menubar,ediff-protect-meta-chars): functions deleted.
author | Michael Kifer <kifer@cs.stonybrook.edu> |
---|---|
date | Fri, 06 Oct 1995 00:55:57 +0000 |
parents | 5ab666b86a02 |
children | b9dc8cc658d5 |
comparison
equal
deleted
inserted
replaced
13127:4ca49c2e0c03 | 13128:b0ec8d932b35 |
---|---|
1 ;;; ediff-init.el --- Macros, variables and defsubsts used by Ediff | 1 ;;; ediff-init.el --- Macros, variables, and defsubsts used by Ediff |
2 ;;; Copyright (C) 1994, 1995 Free Software Foundation, Inc. | 2 ;;; Copyright (C) 1994, 1995 Free Software Foundation, Inc. |
3 | 3 |
4 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> | 4 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> |
5 | 5 |
6 ;; This file is part of GNU Emacs. | 6 ;; This file is part of GNU Emacs. |
19 ;; along with GNU Emacs; see the file COPYING. If not, write to | 19 ;; along with GNU Emacs; see the file COPYING. If not, write to |
20 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 20 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | 21 |
22 | 22 |
23 ;; Is it XEmacs? | 23 ;; Is it XEmacs? |
24 (defconst ediff-xemacs-p (string-match "\\(Lucid\\|Xemacs\\)" emacs-version)) | 24 (defconst ediff-xemacs-p (string-match "XEmacs" emacs-version)) |
25 ;; Is it Emacs? | 25 ;; Is it Emacs? |
26 (defconst ediff-emacs-p (not ediff-xemacs-p)) | 26 (defconst ediff-emacs-p (not ediff-xemacs-p)) |
27 ;; Are we running as a window application or on a TTY? | 27 ;; Are we running as a window application or on a TTY? |
28 (defsubst ediff-device-type () | 28 (defsubst ediff-device-type () |
29 (if ediff-emacs-p | 29 (if ediff-emacs-p |
42 | 42 |
43 (defmacro ediff-get-buffer (arg) | 43 (defmacro ediff-get-buffer (arg) |
44 (` (cond ((eq (, arg) 'A) ediff-buffer-A) | 44 (` (cond ((eq (, arg) 'A) ediff-buffer-A) |
45 ((eq (, arg) 'B) ediff-buffer-B) | 45 ((eq (, arg) 'B) ediff-buffer-B) |
46 ((eq (, arg) 'C) ediff-buffer-C) | 46 ((eq (, arg) 'C) ediff-buffer-C) |
47 ((eq (, arg) 'Ancestor) ediff-ancestor-buffer) | |
47 ) | 48 ) |
48 )) | 49 )) |
49 | 50 |
50 (defmacro ediff-get-value-according-to-buffer-type (buf-type list) | 51 (defmacro ediff-get-value-according-to-buffer-type (buf-type list) |
51 (` (cond ((eq (, buf-type) 'A) (nth 0 (, list))) | 52 (` (cond ((eq (, buf-type) 'A) (nth 0 (, list))) |
94 (` (if (ediff-buffer-live-p ediff-buffer-C) | 95 (` (if (ediff-buffer-live-p ediff-buffer-C) |
95 (aref (ediff-get-difference (, n) (, buf-type)) 3)))) | 96 (aref (ediff-get-difference (, n) (, buf-type)) 3)))) |
96 (defmacro ediff-set-state-of-diff (n buf-type val) | 97 (defmacro ediff-set-state-of-diff (n buf-type val) |
97 (` (aset (ediff-get-difference (, n) (, buf-type)) 3 (, val)))) | 98 (` (aset (ediff-get-difference (, n) (, buf-type)) 3 (, val)))) |
98 (defmacro ediff-get-state-of-merge (n) | 99 (defmacro ediff-get-state-of-merge (n) |
99 (` (if (ediff-buffer-live-p ediff-buffer-C) | 100 (` (if ediff-state-of-merge |
100 (aref (ediff-get-difference (, n) 'C) 4)))) | 101 (aref (aref ediff-state-of-merge (, n)) 0)))) |
102 (defmacro ediff-get-state-of-ancestor (n) | |
103 (` (if ediff-state-of-merge | |
104 (aref (aref ediff-state-of-merge (, n)) 1)))) | |
101 (defmacro ediff-set-state-of-merge (n val) | 105 (defmacro ediff-set-state-of-merge (n val) |
102 (` (aset (ediff-get-difference (, n) 'C) 4 (, val)))) | 106 (` (if ediff-state-of-merge |
107 (aset (aref ediff-state-of-merge (, n)) 0 (, val))))) | |
103 | 108 |
104 ;; if flag is t, puts a mark on diff region saying that | 109 ;; if flag is t, puts a mark on diff region saying that |
105 ;; the differences are in white space only. If flag is nil, | 110 ;; the differences are in white space only. If flag is nil, |
106 ;; the region is marked as essential (i.e., differences are | 111 ;; the region is marked as essential (i.e., differences are |
107 ;; not just in the white space and newlines.) | 112 ;; not just in the white space and newlines.) |
141 (error | 146 (error |
142 "You've killed an essential Ediff buffer---Please quit Ediff")) | 147 "You've killed an essential Ediff buffer---Please quit Ediff")) |
143 )))) | 148 )))) |
144 | 149 |
145 | 150 |
146 (defmacro ediff-multiframe-setup-p () | 151 (defsubst ediff-multiframe-setup-p () |
147 (` (and (ediff-window-display-p) ediff-multiframe))) | 152 (and (ediff-window-display-p) ediff-multiframe)) |
148 | 153 |
149 (defmacro ediff-narrow-control-frame-p () | 154 (defmacro ediff-narrow-control-frame-p () |
150 (` (and (ediff-multiframe-setup-p) | 155 (` (and (ediff-multiframe-setup-p) |
151 (equal ediff-help-message ediff-brief-message-string)))) | 156 (equal ediff-help-message ediff-brief-message-string)))) |
152 | 157 |
199 ediff-regions-wordwise | 204 ediff-regions-wordwise |
200 ediff-windows-linewise | 205 ediff-windows-linewise |
201 ediff-regions-linewise)))) | 206 ediff-regions-linewise)))) |
202 (ediff-defvar-local ediff-narrow-job nil "") | 207 (ediff-defvar-local ediff-narrow-job nil "") |
203 | 208 |
209 ;; Note: ediff-merge-directory-revisions-with-ancestor is not treated as an | |
210 ;; ancestor metajob, since it behaves differently. | |
211 (defsubst ediff-ancestor-metajob (&optional metajob) | |
212 (memq (or metajob ediff-metajob-name) | |
213 '(ediff-merge-directories-with-ancestor | |
214 ediff-merge-filegroups-with-ancestor))) | |
215 (defsubst ediff-revision-metajob (&optional metajob) | |
216 (memq (or metajob ediff-metajob-name) | |
217 '(ediff-directory-revisions | |
218 ediff-merge-directory-revisions | |
219 ediff-merge-directory-revisions-with-ancestor))) | |
220 ;; metajob involving only one directory | |
221 (defsubst ediff-dir1-metajob (&optional metajob) | |
222 (or (ediff-revision-metajob metajob) | |
223 ;; add more here | |
224 )) | |
225 (defsubst ediff-collect-diffs-metajob (&optional metajob) | |
226 (or (ediff-revision-metajob metajob) | |
227 (memq ediff-metajob-name | |
228 '(ediff-directories | |
229 ;; add more here | |
230 ediff-directory-revisions)))) | |
231 (defsubst ediff-metajob3 (&optional metajob) | |
232 (memq (or metajob ediff-metajob-name) | |
233 '(ediff-merge-directories-with-ancestor | |
234 ediff-merge-filegroups-with-ancestor | |
235 ediff-directories3 | |
236 ediff-filegroups3))) | |
237 (defsubst ediff-comparison-metajob3 (&optional metajob) | |
238 (memq (or metajob ediff-metajob-name) | |
239 '(ediff-directories3 ediff-filegroups3))) | |
240 | |
241 (defsubst ediff-barf-if-not-control-buffer (&optional meta-buf) | |
242 (or (eq (if meta-buf ediff-meta-buffer ediff-control-buffer) | |
243 (current-buffer)) | |
244 (error "%S: This command runs in Ediff Control Buffer only!" | |
245 this-command))) | |
246 | |
204 | 247 |
205 ;; Hook variables | 248 ;; Hook variables |
206 | 249 |
207 (defvar ediff-before-setup-windows-hooks nil | 250 (defvar ediff-before-setup-windows-hook nil |
208 "*Hooks to run before Ediff sets its own window config. | 251 "*Hooks to run before Ediff sets its window configuration. |
209 This can be used to save the previous window config, which can be restored | 252 This can be used to save the previous window config, which can be restored |
210 on ediff-quit or ediff-suspend.") | 253 on ediff-quit or ediff-suspend.") |
211 (defvar ediff-after-setup-windows-hooks nil | 254 (defvar ediff-after-setup-windows-hook nil |
212 "*Hooks to run after Ediff sets its own window config. | 255 "*Hooks to run after Ediff sets its window configuration. |
213 This can be used to set up control window or icon in a desired place.") | 256 This can be used to set up control window or icon in a desired place.") |
214 (defvar ediff-before-setup-control-frame-hooks nil | 257 (defvar ediff-before-setup-control-frame-hook nil |
215 "*Hooks run before setting up the frame to display Ediff Control Panel. | 258 "*Hooks run before setting up the frame to display Ediff Control Panel. |
216 Can be used to change control frame parameters to position it where it | 259 Can be used to change control frame parameters to position it where it |
217 is desirable.") | 260 is desirable.") |
218 (defvar ediff-after-setup-control-frame-hooks nil | 261 (defvar ediff-after-setup-control-frame-hook nil |
219 "*Hooks run after setting up the frame to display Ediff Control Panel. | 262 "*Hooks run after setting up the frame to display Ediff Control Panel. |
220 Can be used to move the frame where it is desired.") | 263 Can be used to move the frame where it is desired.") |
221 (defvar ediff-startup-hooks nil | 264 (defvar ediff-startup-hook nil |
222 "*Hooks to run in the control buffer after Ediff has been set up.") | 265 "*Hooks to run in the control buffer after Ediff has been set up.") |
223 (defvar ediff-select-hooks nil | 266 (defvar ediff-select-hook nil |
224 "*Hooks to run after a difference has been selected.") | 267 "*Hooks to run after a difference has been selected.") |
225 (defvar ediff-unselect-hooks nil | 268 (defvar ediff-unselect-hook nil |
226 "*Hooks to run after a difference has been unselected.") | 269 "*Hooks to run after a difference has been unselected.") |
227 (defvar ediff-prepare-buffer-hooks nil | 270 (defvar ediff-prepare-buffer-hook nil |
228 "*Hooks called after buffers A, B, and C are set up.") | 271 "*Hooks called after buffers A, B, and C are set up.") |
229 (defvar ediff-load-hooks nil | 272 (defvar ediff-load-hook nil |
230 "*Hook run after Ediff is loaded. Can be used to change defaults.") | 273 "*Hook run after Ediff is loaded. Can be used to change defaults.") |
231 | 274 |
232 (defvar ediff-mode-hooks nil | 275 (defvar ediff-mode-hook nil |
233 "*Hook run just after ediff-mode is set up in the control buffer. | 276 "*Hook run just after ediff-mode is set up in the control buffer. |
234 This is done before any windows or frames are created. One can use it to | 277 This is done before any windows or frames are created. One can use it to |
235 set local variables that determine how the display looks like.") | 278 set local variables that determine how the display looks like.") |
236 (defvar ediff-keymap-setup-hooks nil | 279 (defvar ediff-keymap-setup-hook nil |
237 "*Hook run just after the default bindings in Ediff keymap are set up.") | 280 "*Hook run just after the default bindings in Ediff keymap are set up.") |
238 | 281 |
239 (defvar ediff-display-help-hooks nil | 282 (defvar ediff-display-help-hook nil |
240 "*Hooks run after preparing the help message.") | 283 "*Hooks run after preparing the help message.") |
241 | 284 |
242 (defvar ediff-suspend-hooks (list 'ediff-default-suspend-hook) | 285 (defvar ediff-suspend-hook (list 'ediff-default-suspend-function) |
243 "*Hooks to run in the Ediff control buffer when Ediff is suspended.") | 286 "*Hooks to run in the Ediff control buffer when Ediff is suspended.") |
244 (defvar ediff-quit-hooks (list 'ediff-cleanup-mess) | 287 (defvar ediff-quit-hook (list 'ediff-cleanup-mess) |
245 "*Hooks to run in the Ediff control buffer after finishing Ediff.") | 288 "*Hooks to run in the Ediff control buffer after finishing Ediff.") |
246 (defvar ediff-cleanup-hooks nil | 289 (defvar ediff-cleanup-hook nil |
247 "*Hooks to run on exiting Ediff but before killing the control buffer. | 290 "*Hooks to run on exiting Ediff but before killing the control buffer. |
248 This is a place to do various cleanups, such as deleting the variant buffers. | 291 This is a place to do various cleanups, such as deleting the variant buffers. |
249 Ediff provides a function, `ediff-janitor', as one such possible hook.") | 292 Ediff provides a function, `ediff-janitor', as one such possible hook.") |
250 | 293 |
251 | 294 |
255 " Moving around | Toggling features | Manipulations | 298 " Moving around | Toggling features | Manipulations |
256 =====================|===========================|=============================" | 299 =====================|===========================|=============================" |
257 "The head of the full help message.") | 300 "The head of the full help message.") |
258 (defconst ediff-long-help-message-tail | 301 (defconst ediff-long-help-message-tail |
259 "=====================|===========================|============================= | 302 "=====================|===========================|============================= |
260 | D -on-line manual | | 303 R -show registry | | M -show session group |
261 i -status info | ? -help off | G -send bug report | 304 D -diff output | E -browse Ediff manual| G -send bug report |
305 i -status info | ? -help off | z/q -suspend/quit | |
262 ------------------------------------------------------------------------------- | 306 ------------------------------------------------------------------------------- |
263 X,Y (x,y) on the left are meta-symbols for the keys A,B,C (a,b,c). | 307 X,Y (x,y) on the left are meta-symbols for the keys A,B,C (a,b,c). |
264 X,Y on the right are meta-symbols for buffers A,B,C. | 308 X,Y on the right are meta-symbols for buffers A,B,C. |
265 A,B,C on the right denote the working buffers A,B,C, respectively." | 309 A,B,C on the right denote the working buffers A,B,C, respectively." |
266 "The tail of the full-help message.") | 310 "The tail of the full-help message.") |
272 j -jump to diff | @ -auto-refinement | * -refine current region | 316 j -jump to diff | @ -auto-refinement | * -refine current region |
273 gx -goto X's point| | ! -update diff regions | 317 gx -goto X's point| | ! -update diff regions |
274 C-l -recenter | ## -ignore whitespace | | 318 C-l -recenter | ## -ignore whitespace | |
275 v/V -scroll up/dn | #f/#h -focus/hide regions | wx -save buf X | 319 v/V -scroll up/dn | #f/#h -focus/hide regions | wx -save buf X |
276 </> -scroll lt/rt | X -read-only in buf X | wd -save diff output | 320 </> -scroll lt/rt | X -read-only in buf X | wd -save diff output |
277 z/q -suspend/quit | m -wide display | ~ -rotate buffers | 321 | m -wide display | ~ -rotate buffers |
278 " | 322 " |
279 "Help message usually used for 3-way comparison. | 323 "Help message usually used for 3-way comparison. |
280 Normally, not a user option. See `ediff-help-message' for details.") | 324 Normally, not a user option. See `ediff-help-message' for details.") |
281 | 325 |
282 (defconst ediff-long-help-message-compare2 | 326 (defconst ediff-long-help-message-compare2 |
286 j -jump to diff | @ -auto-refinement | * -refine current region | 330 j -jump to diff | @ -auto-refinement | * -refine current region |
287 gx -goto X's point| | ! -update diff regions | 331 gx -goto X's point| | ! -update diff regions |
288 C-l -recenter | ## -ignore whitespace | | 332 C-l -recenter | ## -ignore whitespace | |
289 v/V -scroll up/dn | #f/#h -focus/hide regions | wx -save buf X | 333 v/V -scroll up/dn | #f/#h -focus/hide regions | wx -save buf X |
290 </> -scroll lt/rt | X -read-only in buf X | wd -save diff output | 334 </> -scroll lt/rt | X -read-only in buf X | wd -save diff output |
291 z/q -suspend/quit | m -wide display | ~ -swap buffers | 335 | m -wide display | ~ -swap buffers |
292 " | 336 " |
293 "Help message usually used for 2-way comparison. | 337 "Help message usually used for 2-way comparison. |
294 Normally, not a user option. See `ediff-help-message' for details.") | 338 Normally, not a user option. See `ediff-help-message' for details.") |
295 | 339 |
296 (defconst ediff-long-help-message-narrow2 | 340 (defconst ediff-long-help-message-narrow2 |
300 j -jump to diff | @ -auto-refinement | * -refine current region | 344 j -jump to diff | @ -auto-refinement | * -refine current region |
301 gx -goto X's point| % -narrow/widen buffs | ! -update diff regions | 345 gx -goto X's point| % -narrow/widen buffs | ! -update diff regions |
302 C-l -recenter | ## -ignore whitespace | | 346 C-l -recenter | ## -ignore whitespace | |
303 v/V -scroll up/dn | #f/#h -focus/hide regions | wx -save buf X | 347 v/V -scroll up/dn | #f/#h -focus/hide regions | wx -save buf X |
304 </> -scroll lt/rt | X -read-only in buf X | wd -save diff output | 348 </> -scroll lt/rt | X -read-only in buf X | wd -save diff output |
305 z/q -suspend/quit | m -wide display | ~ -swap buffers | 349 | m -wide display | ~ -swap buffers |
306 " | 350 " |
307 "Help message when comparing windows or regions line-by-line. | 351 "Help message when comparing windows or regions line-by-line. |
308 Normally, not a user option. See `ediff-help-message' for details.") | 352 Normally, not a user option. See `ediff-help-message' for details.") |
309 | 353 |
310 (defconst ediff-long-help-message-word-mode | 354 (defconst ediff-long-help-message-word-mode |
314 j -jump to diff | | | 358 j -jump to diff | | |
315 gx -goto X's point| % -narrow/widen buffs | ! -recompute diffs | 359 gx -goto X's point| % -narrow/widen buffs | ! -recompute diffs |
316 C-l -recenter | | | 360 C-l -recenter | | |
317 v/V -scroll up/dn | #f/#h -focus/hide regions | wx -save buf X | 361 v/V -scroll up/dn | #f/#h -focus/hide regions | wx -save buf X |
318 </> -scroll lt/rt | X -read-only in buf X | wd -save diff output | 362 </> -scroll lt/rt | X -read-only in buf X | wd -save diff output |
319 z/q -suspend/quit | m -wide display | ~ -swap buffers | 363 | m -wide display | ~ -swap buffers |
320 " | 364 " |
321 "Help message when comparing windows or regions word-by-word. | 365 "Help message when comparing windows or regions word-by-word. |
322 Normally, not a user option. See `ediff-help-message' for details.") | 366 Normally, not a user option. See `ediff-help-message' for details.") |
323 | 367 |
324 (defconst ediff-long-help-message-merge | 368 (defconst ediff-long-help-message-merge |
328 j -jump to diff | @ -auto-refinement | * -refine current region | 372 j -jump to diff | @ -auto-refinement | * -refine current region |
329 gx -goto X's point| ## -ignore whitespace | ! -update diff regions | 373 gx -goto X's point| ## -ignore whitespace | ! -update diff regions |
330 C-l -recenter | #f/#h -focus/hide regions | + -combine diff regions | 374 C-l -recenter | #f/#h -focus/hide regions | + -combine diff regions |
331 v/V -scroll up/dn | X -read-only in buf X | wx -save buf X | 375 v/V -scroll up/dn | X -read-only in buf X | wx -save buf X |
332 </> -scroll lt/rt | m -wide display | wd -save diff output | 376 </> -scroll lt/rt | m -wide display | wd -save diff output |
333 z/q -suspend/quit | s -shrink window C | ~ -swap buffers | 377 / -ancestor buff | s -shrink window C | ~ -swap buffers |
334 | $ -show clashes only | & -merge w/new default | 378 | $ -show clashes only | & -merge w/new default |
335 " | 379 " |
336 "Help message during merging. | 380 "Help message during merging. |
337 Normally, not a user option. See `ediff-help-message' for details.") | 381 Normally, not a user option. See `ediff-help-message' for details.") |
338 | 382 |
345 "Contents of the brief help message.") | 389 "Contents of the brief help message.") |
346 ;; The actual brief help message | 390 ;; The actual brief help message |
347 (ediff-defvar-local ediff-brief-help-message "" | 391 (ediff-defvar-local ediff-brief-help-message "" |
348 "Normally, not a user option. See `ediff-help-message' for details.") | 392 "Normally, not a user option. See `ediff-help-message' for details.") |
349 | 393 |
350 (ediff-defvar-local ediff-brief-help-message-custom nil | 394 (ediff-defvar-local ediff-brief-help-message-function nil |
351 "The brief help message that the user can customize. | 395 "The brief help message that the user can customize. |
352 If the user sets this to a parameter-less function, Ediff will use it to | 396 If the user sets this to a parameter-less function, Ediff will use it to |
353 produce the brief help message. This function must return a string.") | 397 produce the brief help message. This function must return a string.") |
354 (ediff-defvar-local ediff-long-help-message-custom nil | 398 (ediff-defvar-local ediff-long-help-message-function nil |
355 "The long help message that the user can customize. | 399 "The long help message that the user can customize. |
356 See `ediff-brief-help-message-custom' for more.") | 400 See `ediff-brief-help-message-function' for more.") |
357 | 401 |
358 (defvar ediff-prefer-long-help-message nil | 402 (defvar ediff-prefer-long-help-message nil |
359 "*If t, Ediff starts with a long help message. Short help msg otherwise.") | 403 "*If t, Ediff starts with a long help message. Short help msg otherwise.") |
360 | 404 |
361 ;; The actual help message. | 405 ;; The actual help message. |
362 (ediff-defvar-local ediff-help-message "" | 406 (ediff-defvar-local ediff-help-message "" |
363 "The actual help message. | 407 "The actual help message. |
364 Normally, the user shouldn't touch this. However, if you want Ediff to | 408 Normally, the user shouldn't touch this. However, if you want Ediff to |
365 start up with different help messages for different jobs, you can change | 409 start up with different help messages for different jobs, you can change |
366 the value of this variable and the variables `ediff-help-message-*' in | 410 the value of this variable and the variables `ediff-help-message-*' in |
367 `ediff-startup-hooks'.") | 411 `ediff-startup-hook'.") |
368 | 412 |
369 ;; Selective browsing | 413 ;; Selective browsing |
370 | 414 |
371 (ediff-defvar-local ediff-skip-diff-region-function 'ediff-show-all-diffs | 415 (ediff-defvar-local ediff-skip-diff-region-function 'ediff-show-all-diffs |
372 "Function that determines the next/previous diff region to show. | 416 "Function that determines the next/previous diff region to show. |
373 Should return t for regions to be ignored and nil otherwise. | 417 Should return t for regions to be ignored and nil otherwise. |
374 This function gets a region number as an argument. The region number | 418 This function gets a region number as an argument. The region number |
375 is the one used internally by Ediff. It is 1 less than the number seen | 419 is the one used internally by Ediff. It is 1 less than the number seen |
376 by the user.") | 420 by the user.") |
421 | |
422 (ediff-defvar-local ediff-hide-regexp-matches-function | |
423 'ediff-hide-regexp-matches | |
424 "Function to use in determining which regions to hide. | |
425 See the documentation string of `ediff-hide-regexp-matches' for details.") | |
426 (ediff-defvar-local ediff-focus-on-regexp-matches-function | |
427 'ediff-focus-on-regexp-matches | |
428 "Function to use in determining which regions to focus on. | |
429 See the documentation string of `ediff-focus-on-regexp-matches' for details.") | |
377 | 430 |
378 ;; Regexp that determines buf A regions to focus on when skipping to diff | 431 ;; Regexp that determines buf A regions to focus on when skipping to diff |
379 (ediff-defvar-local ediff-regexp-focus-A "" "") | 432 (ediff-defvar-local ediff-regexp-focus-A "" "") |
380 ;; Regexp that determines buf B regions to focus on when skipping to diff | 433 ;; Regexp that determines buf B regions to focus on when skipping to diff |
381 (ediff-defvar-local ediff-regexp-focus-B "" "") | 434 (ediff-defvar-local ediff-regexp-focus-B "" "") |
437 | 490 |
438 | 491 |
439 ;; this indicates that diff regions are word-size, so fine diffs are | 492 ;; this indicates that diff regions are word-size, so fine diffs are |
440 ;; permanently nixed; used in ediff-windows-wordwise and ediff-regions-wordwise | 493 ;; permanently nixed; used in ediff-windows-wordwise and ediff-regions-wordwise |
441 (ediff-defvar-local ediff-word-mode nil "") | 494 (ediff-defvar-local ediff-word-mode nil "") |
442 ;; Name of the job (ediff-files, ediff-windows, etc. | 495 ;; Name of the job (ediff-files, ediff-windows, etc.) |
443 (ediff-defvar-local ediff-job-name nil "") | 496 (ediff-defvar-local ediff-job-name nil "") |
444 | 497 |
445 ;; Narrowing and ediff-region/windows support | 498 ;; Narrowing and ediff-region/windows support |
446 ;; This is a list (overlay-A overlay-B overlay-C) | 499 ;; This is a list (overlay-A overlay-B overlay-C) |
447 ;; If set, Ediff compares only those parts of buffers A/B/C that lie within | 500 ;; If set, Ediff compares only those parts of buffers A/B/C that lie within |
461 (ediff-defvar-local ediff-start-narrowed t | 514 (ediff-defvar-local ediff-start-narrowed t |
462 "Non-nil means start narrowed, if doing ediff-windows-* or ediff-regions-*") | 515 "Non-nil means start narrowed, if doing ediff-windows-* or ediff-regions-*") |
463 (ediff-defvar-local ediff-quit-widened t | 516 (ediff-defvar-local ediff-quit-widened t |
464 "*Non-nil means: when finished, Ediff widens buffers A/B. | 517 "*Non-nil means: when finished, Ediff widens buffers A/B. |
465 Actually, Ediff restores the scope of visibility that existed at startup.") | 518 Actually, Ediff restores the scope of visibility that existed at startup.") |
519 (defvar ediff-keep-variants t | |
520 "*Nil means that non-modified variant buffers should be removed after some | |
521 interrogation. | |
522 Supplying a prefix agument to the quit command `q' temporarily reverses the | |
523 meaning of this variable.") | |
466 | 524 |
467 (ediff-defvar-local ediff-highlight-all-diffs t | 525 (ediff-defvar-local ediff-highlight-all-diffs t |
468 "If nil, only the selected differences are highlighted. | 526 "If nil, only the selected differences are highlighted. |
469 This variable can be set either in .emacs or toggled interactively, using | 527 This variable can be set either in .emacs or toggled interactively, using |
470 ediff-toggle-hilit. Use `setq-default' to set it.") | 528 ediff-toggle-hilit. Use `setq-default' to set it.") |
502 (ediff-defvar-local ediff-buffer-values-orig-A nil "") | 560 (ediff-defvar-local ediff-buffer-values-orig-A nil "") |
503 ;; The original values of ediff-protected-variables for buffer B | 561 ;; The original values of ediff-protected-variables for buffer B |
504 (ediff-defvar-local ediff-buffer-values-orig-B nil "") | 562 (ediff-defvar-local ediff-buffer-values-orig-B nil "") |
505 ;; The original values of ediff-protected-variables for buffer C | 563 ;; The original values of ediff-protected-variables for buffer C |
506 (ediff-defvar-local ediff-buffer-values-orig-C nil "") | 564 (ediff-defvar-local ediff-buffer-values-orig-C nil "") |
565 ;; The original values of ediff-protected-variables for buffer Ancestor | |
566 (ediff-defvar-local ediff-buffer-values-orig-Ancestor nil "") | |
567 ;; Buffer-local variables to be saved then restored during Ediff sessions | |
507 ;; Buffer-local variables to be saved then restored during Ediff sessions | 568 ;; Buffer-local variables to be saved then restored during Ediff sessions |
508 (defconst ediff-protected-variables '(buffer-read-only | 569 (defconst ediff-protected-variables '(buffer-read-only |
570 synchronize-minibuffers | |
509 mode-line-format)) | 571 mode-line-format)) |
510 | 572 |
511 ;; Vector of differences between the variants. Each difference is | 573 ;; Vector of differences between the variants. Each difference is |
512 ;; represented by a vector of two overlays plus a vector of fine diffs, | 574 ;; represented by a vector of two overlays plus a vector of fine diffs, |
513 ;; plus a no-fine-diffs flag. The first overlay spans the | 575 ;; plus a no-fine-diffs flag. The first overlay spans the |
516 ;; overlay's endpoints coincide. | 578 ;; overlay's endpoints coincide. |
517 ;; | 579 ;; |
518 ;; The precise form of a difference vector for one buffer is: | 580 ;; The precise form of a difference vector for one buffer is: |
519 ;; [diff diff diff ...] | 581 ;; [diff diff diff ...] |
520 ;; where each diff has the form: | 582 ;; where each diff has the form: |
521 ;; [diff-overlay fine-diff-vector no-fine-diffs-flag state-of-difference | 583 ;; [diff-overlay fine-diff-vector no-fine-diffs-flag state-of-difference] |
522 ;; state-of-merge] | |
523 ;; fine-diff-vector is a vector [fine-diff-overlay fine-diff-overlay ...] | 584 ;; fine-diff-vector is a vector [fine-diff-overlay fine-diff-overlay ...] |
524 ;; no-fine-diffs-flag says if there are fine differences. | 585 ;; no-fine-diffs-flag says if there are fine differences. |
525 ;; state-of-difference is A, B, C, or nil, indicating which buffer is | 586 ;; state-of-difference is A, B, C, or nil, indicating which buffer is |
526 ;; different from the other two (used only in 3-way jobs. | 587 ;; different from the other two (used only in 3-way jobs. |
527 ;; state-of-merge is default-A, default-B, prefer-A, or prefer-B. It | |
528 ;; indicates the way a diff region was created in buffer C. | |
529 (ediff-defvar-local ediff-difference-vector-A nil "") | 588 (ediff-defvar-local ediff-difference-vector-A nil "") |
530 (ediff-defvar-local ediff-difference-vector-B nil "") | 589 (ediff-defvar-local ediff-difference-vector-B nil "") |
531 (ediff-defvar-local ediff-difference-vector-C nil "") | 590 (ediff-defvar-local ediff-difference-vector-C nil "") |
591 (ediff-defvar-local ediff-difference-vector-Ancestor nil "") | |
592 | |
593 ;; [ status status status ...] | |
594 ;; Each status: [state-of-merge state-of-ancestor] | |
595 ;; state-of-merge is default-A, default-B, prefer-A, or prefer-B. It | |
596 ;; indicates the way a diff region was created in buffer C. | |
597 ;; state-of-ancestor says if the corresponding region in ancestor buffer is | |
598 ;; empty. | |
599 (ediff-defvar-local ediff-state-of-merge nil "") | |
532 | 600 |
533 ;; The difference that is currently selected. | 601 ;; The difference that is currently selected. |
534 (ediff-defvar-local ediff-current-difference -1 "") | 602 (ediff-defvar-local ediff-current-difference -1 "") |
535 ;; Number of differences found. | 603 ;; Number of differences found. |
536 (ediff-defvar-local ediff-number-of-differences nil "") | 604 (ediff-defvar-local ediff-number-of-differences nil "") |
550 ;; Buffer containing the output of diff when diff returns errors. | 618 ;; Buffer containing the output of diff when diff returns errors. |
551 (ediff-defvar-local ediff-error-buffer nil "") | 619 (ediff-defvar-local ediff-error-buffer nil "") |
552 ;; Buffer to display debug info | 620 ;; Buffer to display debug info |
553 (ediff-defvar-local ediff-debug-buffer "*ediff-debug*" "") | 621 (ediff-defvar-local ediff-debug-buffer "*ediff-debug*" "") |
554 | 622 |
555 ;; List of ediff control panels associated with each buffer A/B. | 623 ;; List of ediff control panels associated with each buffer A/B/C/Ancestor. |
556 ;; Not used any more, but may be needed in the future | 624 ;; Not used any more, but may be needed in the future. |
557 (ediff-defvar-local ediff-this-buffer-control-sessions nil "") | 625 (ediff-defvar-local ediff-this-buffer-ediff-sessions nil "") |
558 | 626 |
559 ;; to be deleted in due time | 627 ;; to be deleted in due time |
560 ;; List of difference overlays disturbed by working with the current diff. | 628 ;; List of difference overlays disturbed by working with the current diff. |
561 (defvar ediff-disturbed-overlays nil "") | 629 (defvar ediff-disturbed-overlays nil "") |
562 | 630 |
563 ;; Priority of non-selected overlays. | 631 ;; Priority of non-selected overlays. |
564 (defvar ediff-shadow-overlay-priority 100 "") | 632 (defvar ediff-shadow-overlay-priority 100 "") |
633 | |
634 (defvar ediff-version-control-package 'vc | |
635 "Version control package used. | |
636 Currently, Ediff supports vc.el, rcs.el, and generic-sc.el. The standard Emacs | |
637 interface to RCS, CVS, SCCS, etc., is vc.el. However, some people find the | |
638 other two packages more convenient. Set this variable `rcs' or `generic-sc' if | |
639 you are such a person.") | |
565 | 640 |
566 | 641 |
567 (if ediff-xemacs-p | 642 (if ediff-xemacs-p |
568 (progn | 643 (progn |
569 (fset 'ediff-read-event (symbol-function 'next-command-event)) | 644 (fset 'ediff-read-event (symbol-function 'next-command-event)) |
605 (t | 680 (t |
606 (error "%S: Invalid op in ediff-check-version" op)))) | 681 (error "%S: Invalid op in ediff-check-version" op)))) |
607 (cond ((memq op '(= > >=)) nil) | 682 (cond ((memq op '(= > >=)) nil) |
608 ((memq op '(< <=)) t)))) | 683 ((memq op '(< <=)) t)))) |
609 | 684 |
685 | |
686 ;;;; warn if it is a wrong version of emacs | |
687 ;;(if (or (ediff-check-version '< 19 29 'emacs) | |
688 ;; (ediff-check-version '< 19 12 'xemacs)) | |
689 ;; (progn | |
690 ;; (with-output-to-temp-buffer ediff-msg-buffer | |
691 ;; (switch-to-buffer ediff-msg-buffer) | |
692 ;; (insert | |
693 ;; (format " | |
694 ;; | |
695 ;;This version of Ediff requires | |
696 ;; | |
697 ;;\t Emacs 19.29 and higher | |
698 ;;\t OR | |
699 ;;\t XEmacs 19.12 and higher | |
700 ;; | |
701 ;;It is unlikely to work under Emacs version %s | |
702 ;;that you are using... " emacs-version)) | |
703 ;; (if noninteractive | |
704 ;; () | |
705 ;; (beep 1) | |
706 ;; (beep 1) | |
707 ;; (insert "\n\nType any key to continue...") | |
708 ;; (ediff-read-event))) | |
709 ;; (kill-buffer ediff-msg-buffer))) | |
710 | |
610 ;; A fix for NeXT Step | 711 ;; A fix for NeXT Step |
611 ;; Should probably be eliminated in later versions. | 712 ;; Should probably be eliminated in later versions. |
612 (if (and (ediff-window-display-p) (eq (ediff-device-type) 'ns)) | 713 (if (and (ediff-window-display-p) (eq (ediff-device-type) 'ns)) |
613 (progn | 714 (progn |
614 (fset 'x-display-color-p (symbol-function 'ns-display-color-p)) | 715 (fset 'x-display-color-p (symbol-function 'ns-display-color-p)) |
615 (fset 'x-color-defined-p (symbol-function 'ns-color-defined-p)) | 716 (fset 'x-color-defined-p (symbol-function 'ns-color-defined-p)) |
616 (fset 'x-display-pixel-height (symbol-function 'ns-display-pixel-height)) | 717 (fset 'x-display-pixel-height (symbol-function 'ns-display-pixel-height)) |
617 (fset 'x-display-pixel-width (symbol-function 'ns-display-pixel-width)) | 718 (fset 'x-display-pixel-width (symbol-function 'ns-display-pixel-width)) |
618 )) | 719 )) |
619 | 720 |
721 | |
620 (defsubst ediff-color-display-p () | 722 (defsubst ediff-color-display-p () |
621 (if ediff-emacs-p | 723 (if ediff-emacs-p |
622 (x-display-color-p) | 724 (x-display-color-p) |
623 (eq (device-class (selected-device)) 'color))) | 725 (eq (device-class (selected-device)) 'color))) |
726 | |
624 | 727 |
625 (if (ediff-window-display-p) | 728 (if (ediff-window-display-p) |
626 (if ediff-xemacs-p | 729 (if ediff-xemacs-p |
627 (progn | 730 (progn |
628 (fset 'ediff-display-pixel-width | 731 (fset 'ediff-display-pixel-width |
642 (function (lambda (color) (assoc color pm-color-alist)))) | 745 (function (lambda (color) (assoc color pm-color-alist)))) |
643 (fset 'ediff-valid-color-p (symbol-function 'x-color-defined-p))) | 746 (fset 'ediff-valid-color-p (symbol-function 'x-color-defined-p))) |
644 (fset 'ediff-get-face (symbol-function 'internal-get-face)))) | 747 (fset 'ediff-get-face (symbol-function 'internal-get-face)))) |
645 | 748 |
646 | 749 |
647 (if (not (ediff-window-display-p)) | 750 (defun ediff-make-current-diff-overlay (type) |
648 (fset 'ediff-make-current-diff-overlay (function (lambda (type) nil))) | 751 (if (ediff-window-display-p) |
649 ;; window system | 752 (let ((overlay (intern (format "ediff-current-diff-overlay-%S" type))) |
650 (defun ediff-set-face (ground face color) | 753 (buffer (ediff-get-buffer type)) |
651 "Sets face foreground/background." | 754 (face (face-name |
652 (if (ediff-valid-color-p color) | 755 (symbol-value |
653 (if (eq ground 'foreground) | 756 (intern (format "ediff-current-diff-face-%S" type)))))) |
654 (set-face-foreground face color) | 757 (set overlay |
655 (set-face-background face color)) | 758 (ediff-make-bullet-proof-overlay (point-max) (point-max) buffer)) |
656 (cond ((memq face | 759 (ediff-set-overlay-face (symbol-value overlay) face) |
657 '(ediff-current-diff-face-A | 760 (ediff-overlay-put (symbol-value overlay) 'ediff ediff-control-buffer)) |
658 ediff-current-diff-face-B | 761 )) |
659 ediff-current-diff-face-C)) | 762 |
660 (copy-face 'highlight face)) | 763 (defun ediff-set-overlay-face (extent face) |
661 ((memq face | 764 (ediff-overlay-put extent 'face face) |
662 '(ediff-fine-diff-face-A | 765 (ediff-overlay-put extent 'help-echo 'ediff-region-help-echo)) |
663 ediff-fine-diff-face-B | 766 |
664 ediff-fine-diff-face-C)) | 767 ;; This does nothing in Emacs, since overlays there have no help-echo property |
665 (copy-face 'secondary-selection face) | 768 (defun ediff-region-help-echo (extent) |
666 (set-face-underline-p face t)) | 769 (let ((is-current (ediff-overlay-get extent 'ediff)) |
667 ((memq face | 770 (face (ediff-overlay-get extent 'face)) |
668 '(ediff-even-diff-face-A ediff-odd-diff-face-A | 771 (diff-num (ediff-overlay-get extent 'ediff-diff-num)) |
669 ediff-even-diff-face-B ediff-odd-diff-face-B | 772 face-help help-msg) |
670 ediff-even-diff-face-C ediff-odd-diff-face-C)) | 773 |
671 (copy-face 'secondary-selection face))))) | 774 ;; This happens only for refinement overlays |
775 (setq face-help (and face (get face 'ediff-help-echo))) | |
776 | |
777 (setq help-msg | |
778 (cond ((and is-current diff-num) ; current diff region | |
779 (format "Difference region %S -- current" (1+ diff-num))) | |
780 (face-help) ; refinement of current diff region | |
781 (diff-num ; non-current | |
782 (format "Difference region %S -- non-current" (1+ diff-num))) | |
783 (t ""))))) ; none | |
784 | |
785 (defun ediff-set-face (ground face color) | |
786 "Set face foreground/background." | |
787 (if (ediff-window-display-p) | |
788 (if (ediff-valid-color-p color) | |
789 (if (eq ground 'foreground) | |
790 (set-face-foreground face color) | |
791 (set-face-background face color)) | |
792 (cond ((memq face | |
793 '(ediff-current-diff-face-A | |
794 ediff-current-diff-face-B | |
795 ediff-current-diff-face-C | |
796 ediff-current-diff-face-Ancestor)) | |
797 (copy-face 'highlight face)) | |
798 ((memq face | |
799 '(ediff-fine-diff-face-A | |
800 ediff-fine-diff-face-B | |
801 ediff-fine-diff-face-C | |
802 ediff-fine-diff-face-Ancestor)) | |
803 (copy-face 'secondary-selection face) | |
804 (set-face-underline-p face t)) | |
805 ((memq face | |
806 '(ediff-even-diff-face-A | |
807 ediff-odd-diff-face-A | |
808 ediff-even-diff-face-B ediff-odd-diff-face-B | |
809 ediff-even-diff-face-C ediff-odd-diff-face-C | |
810 ediff-even-diff-face-Ancestor | |
811 ediff-odd-diff-face-Ancestor)) | |
812 (copy-face 'secondary-selection face)))) | |
813 )) | |
672 | 814 |
673 (defvar ediff-current-diff-face-A | 815 (defvar ediff-current-diff-face-A |
674 (progn | 816 (if (ediff-window-display-p) |
675 (make-face 'ediff-current-diff-face-A) | 817 (progn |
676 (or (face-differs-from-default-p 'ediff-current-diff-face-A) | 818 (make-face 'ediff-current-diff-face-A) |
677 (cond ((ediff-color-display-p) | 819 (or (face-differs-from-default-p 'ediff-current-diff-face-A) |
678 (ediff-set-face | 820 (cond ((ediff-color-display-p) |
679 'foreground 'ediff-current-diff-face-A "firebrick") | 821 (ediff-set-face |
680 (ediff-set-face | 822 'foreground 'ediff-current-diff-face-A "firebrick") |
681 'background 'ediff-current-diff-face-A "pale green")) | 823 (ediff-set-face |
682 (t | 824 'background 'ediff-current-diff-face-A "pale green")) |
683 (if ediff-xemacs-p | 825 (t |
684 (copy-face 'modeline 'ediff-current-diff-face-A) | 826 (if ediff-xemacs-p |
685 (copy-face 'highlight 'ediff-current-diff-face-A)) | 827 (copy-face 'modeline 'ediff-current-diff-face-A) |
686 ))) | 828 (copy-face 'highlight 'ediff-current-diff-face-A)) |
687 'ediff-current-diff-face-A) | 829 ))) |
688 "Face for highlighting the selected difference in buffer A.") | 830 'ediff-current-diff-face-A)) |
689 | 831 "Face for highlighting the selected difference in buffer A.") |
690 (defvar ediff-current-diff-face-B | 832 |
691 (progn | 833 (defvar ediff-current-diff-face-B |
692 (make-face 'ediff-current-diff-face-B) | 834 (if (ediff-window-display-p) |
693 (or (face-differs-from-default-p 'ediff-current-diff-face-B) | 835 (progn |
694 (cond ((ediff-color-display-p) | 836 (make-face 'ediff-current-diff-face-B) |
695 (ediff-set-face | 837 (or (face-differs-from-default-p 'ediff-current-diff-face-B) |
696 'foreground 'ediff-current-diff-face-B "DarkOrchid") | 838 (cond ((ediff-color-display-p) |
697 (ediff-set-face | 839 (ediff-set-face |
698 'background 'ediff-current-diff-face-B "Yellow")) | 840 'foreground 'ediff-current-diff-face-B "DarkOrchid") |
699 (t | 841 (ediff-set-face |
700 (if ediff-xemacs-p | 842 'background 'ediff-current-diff-face-B "Yellow")) |
701 (copy-face 'modeline 'ediff-current-diff-face-B) | 843 (t |
702 (copy-face 'highlight 'ediff-current-diff-face-B)) | 844 (if ediff-xemacs-p |
703 ))) | 845 (copy-face 'modeline 'ediff-current-diff-face-B) |
704 'ediff-current-diff-face-B) | 846 (copy-face 'highlight 'ediff-current-diff-face-B)) |
705 "Face for highlighting the selected difference in buffer B.") | 847 ))) |
706 | 848 'ediff-current-diff-face-B)) |
707 | 849 "Face for highlighting the selected difference in buffer B.") |
708 (defvar ediff-current-diff-face-C | 850 |
709 (progn | 851 |
710 (make-face 'ediff-current-diff-face-C) | 852 (defvar ediff-current-diff-face-C |
711 (or (face-differs-from-default-p 'ediff-current-diff-face-C) | 853 (if (ediff-window-display-p) |
712 (cond ((ediff-color-display-p) | 854 (progn |
713 (ediff-set-face | 855 (make-face 'ediff-current-diff-face-C) |
714 'foreground 'ediff-current-diff-face-C "Navy") | 856 (or (face-differs-from-default-p 'ediff-current-diff-face-C) |
715 (ediff-set-face | 857 (cond ((ediff-color-display-p) |
716 'background 'ediff-current-diff-face-C "Pink")) | 858 (ediff-set-face |
717 (t | 859 'foreground 'ediff-current-diff-face-C "Navy") |
718 (if ediff-xemacs-p | 860 (ediff-set-face |
719 (copy-face 'modeline 'ediff-current-diff-face-C) | 861 'background 'ediff-current-diff-face-C "Pink")) |
720 (copy-face 'highlight 'ediff-current-diff-face-C)) | 862 (t |
721 ))) | 863 (if ediff-xemacs-p |
722 'ediff-current-diff-face-C) | 864 (copy-face 'modeline 'ediff-current-diff-face-C) |
723 "Face for highlighting the selected difference in buffer C.") | 865 (copy-face 'highlight 'ediff-current-diff-face-C)) |
724 | 866 ))) |
725 (defvar ediff-fine-diff-face-A | 867 'ediff-current-diff-face-C)) |
726 (progn | 868 "Face for highlighting the selected difference in buffer C.") |
727 (make-face 'ediff-fine-diff-face-A) | 869 |
728 (or (face-differs-from-default-p 'ediff-fine-diff-face-A) | 870 (defvar ediff-current-diff-face-Ancestor |
729 (cond ((ediff-color-display-p) | 871 (if (ediff-window-display-p) |
730 (ediff-set-face 'foreground 'ediff-fine-diff-face-A | 872 (progn |
731 "Navy") | 873 (make-face 'ediff-current-diff-face-Ancestor) |
732 (ediff-set-face 'background 'ediff-fine-diff-face-A | 874 (or (face-differs-from-default-p 'ediff-current-diff-face-Ancestor) |
733 "sky blue")) | 875 (copy-face |
734 (t (set-face-underline-p 'ediff-fine-diff-face-A t)))) | 876 'ediff-current-diff-face-C 'ediff-current-diff-face-Ancestor)))) |
735 'ediff-fine-diff-face-A) | 877 "Face for highlighting the selected difference in the ancestor buffer.") |
736 "Face for highlighting the refinement of the selected diff in buffer A.") | 878 |
737 | 879 (defvar ediff-fine-diff-face-A |
738 (defvar ediff-fine-diff-face-B | 880 (if (ediff-window-display-p) |
739 (progn | 881 (progn |
740 (make-face 'ediff-fine-diff-face-B) | 882 (make-face 'ediff-fine-diff-face-A) |
741 (or (face-differs-from-default-p 'ediff-fine-diff-face-B) | 883 (or (face-differs-from-default-p 'ediff-fine-diff-face-A) |
742 (cond ((ediff-color-display-p) | 884 (cond ((ediff-color-display-p) |
743 (ediff-set-face 'foreground 'ediff-fine-diff-face-B "Black") | 885 (ediff-set-face 'foreground 'ediff-fine-diff-face-A |
744 (ediff-set-face 'background 'ediff-fine-diff-face-B "cyan")) | 886 "Navy") |
745 (t (set-face-underline-p 'ediff-fine-diff-face-B t)))) | 887 (ediff-set-face 'background 'ediff-fine-diff-face-A |
746 'ediff-fine-diff-face-B) | 888 "sky blue")) |
747 "Face for highlighting the refinement of the selected diff in buffer B.") | 889 (t (set-face-underline-p 'ediff-fine-diff-face-A t)))) |
748 | 890 'ediff-fine-diff-face-A)) |
749 (defvar ediff-fine-diff-face-C | 891 "Face for highlighting the refinement of the selected diff in buffer A.") |
750 (progn | 892 |
751 (make-face 'ediff-fine-diff-face-C) | 893 (defvar ediff-fine-diff-face-B |
752 (or (face-differs-from-default-p 'ediff-fine-diff-face-C) | 894 (if (ediff-window-display-p) |
753 (cond ((ediff-color-display-p) | 895 (progn |
754 (ediff-set-face 'foreground 'ediff-fine-diff-face-C "black") | 896 (make-face 'ediff-fine-diff-face-B) |
755 (ediff-set-face | 897 (or (face-differs-from-default-p 'ediff-fine-diff-face-B) |
756 'background 'ediff-fine-diff-face-C "Turquoise")) | 898 (cond ((ediff-color-display-p) |
757 (t (set-face-underline-p 'ediff-fine-diff-face-C t)))) | 899 (ediff-set-face 'foreground 'ediff-fine-diff-face-B "Black") |
758 'ediff-fine-diff-face-C) | 900 (ediff-set-face 'background 'ediff-fine-diff-face-B "cyan")) |
759 "Face for highlighting the refinement of the selected diff in buffer C.") | 901 (t (set-face-underline-p 'ediff-fine-diff-face-B t)))) |
760 | 902 'ediff-fine-diff-face-B)) |
761 (defvar ediff-even-diff-face-A | 903 "Face for highlighting the refinement of the selected diff in buffer B.") |
762 (progn | 904 |
763 (make-face 'ediff-even-diff-face-A) | 905 (defvar ediff-fine-diff-face-C |
764 (or (face-differs-from-default-p 'ediff-even-diff-face-A) | 906 (if (ediff-window-display-p) |
765 (cond ((ediff-color-display-p) | 907 (progn |
766 (ediff-set-face | 908 (make-face 'ediff-fine-diff-face-C) |
767 'foreground 'ediff-even-diff-face-A "black") | 909 (or (face-differs-from-default-p 'ediff-fine-diff-face-C) |
768 (ediff-set-face | 910 (cond ((ediff-color-display-p) |
769 'background 'ediff-even-diff-face-A "light grey")) | 911 (ediff-set-face 'foreground 'ediff-fine-diff-face-C "black") |
770 (t | 912 (ediff-set-face |
771 (copy-face 'italic 'ediff-even-diff-face-A)))) | 913 'background 'ediff-fine-diff-face-C "Turquoise")) |
772 'ediff-even-diff-face-A) | 914 (t (set-face-underline-p 'ediff-fine-diff-face-C t)))) |
773 "Face used to highlight even-numbered differences in buffer A.") | 915 'ediff-fine-diff-face-C)) |
916 "Face for highlighting the refinement of the selected diff in buffer C.") | |
917 | |
918 (defvar ediff-fine-diff-face-Ancestor | |
919 (if (ediff-window-display-p) | |
920 (progn | |
921 (make-face 'ediff-fine-diff-face-Ancestor) | |
922 (or (face-differs-from-default-p 'ediff-fine-diff-face-Ancestor) | |
923 (copy-face | |
924 'ediff-fine-diff-face-C 'ediff-fine-diff-face-Ancestor)))) | |
925 "Face highlighting refinements of the selected diff in ancestor buffer. | |
926 Presently, this is not used, as difference regions are not refined in the | |
927 ancestor buffer.") | |
928 | |
929 (defvar ediff-even-diff-face-A | |
930 (if (ediff-window-display-p) | |
931 (progn | |
932 (make-face 'ediff-even-diff-face-A) | |
933 (or (face-differs-from-default-p 'ediff-even-diff-face-A) | |
934 (cond ((ediff-color-display-p) | |
935 (ediff-set-face | |
936 'foreground 'ediff-even-diff-face-A "black") | |
937 (ediff-set-face | |
938 'background 'ediff-even-diff-face-A "light grey")) | |
939 (t | |
940 (copy-face 'italic 'ediff-even-diff-face-A)))) | |
941 'ediff-even-diff-face-A)) | |
942 "Face used to highlight even-numbered differences in buffer A.") | |
774 | 943 |
775 (defvar ediff-even-diff-face-B | 944 (defvar ediff-even-diff-face-B |
776 (progn | 945 (if (ediff-window-display-p) |
777 (make-face 'ediff-even-diff-face-B) | 946 (progn |
778 (or (face-differs-from-default-p 'ediff-even-diff-face-B) | 947 (make-face 'ediff-even-diff-face-B) |
779 (cond ((ediff-color-display-p) | 948 (or (face-differs-from-default-p 'ediff-even-diff-face-B) |
780 (ediff-set-face | 949 (cond ((ediff-color-display-p) |
781 'foreground 'ediff-even-diff-face-B "White") | 950 (ediff-set-face |
782 (ediff-set-face | 951 'foreground 'ediff-even-diff-face-B "White") |
783 'background 'ediff-even-diff-face-B "Gray")) | 952 (ediff-set-face |
784 (t | 953 'background 'ediff-even-diff-face-B "Gray")) |
785 (copy-face 'italic 'ediff-even-diff-face-B)))) | 954 (t |
786 'ediff-even-diff-face-B) | 955 (copy-face 'italic 'ediff-even-diff-face-B)))) |
787 "Face used to highlight even-numbered differences in buffer B.") | 956 'ediff-even-diff-face-B)) |
788 | 957 "Face used to highlight even-numbered differences in buffer B.") |
789 (defvar ediff-even-diff-face-C | 958 |
790 (progn | 959 (defvar ediff-even-diff-face-C |
791 (make-face 'ediff-even-diff-face-C) | 960 (if (ediff-window-display-p) |
792 (copy-face 'ediff-even-diff-face-A 'ediff-even-diff-face-C) | 961 (progn |
793 'ediff-even-diff-face-C) | 962 (make-face 'ediff-even-diff-face-C) |
794 "Face used to highlight even-numbered differences in buffer C.") | 963 (or (face-differs-from-default-p 'ediff-even-diff-face-C) |
795 | 964 (copy-face 'ediff-even-diff-face-A 'ediff-even-diff-face-C)) |
796 (defvar ediff-odd-diff-face-A | 965 'ediff-even-diff-face-C)) |
797 (progn | 966 "Face used to highlight even-numbered differences in buffer C.") |
798 (make-face 'ediff-odd-diff-face-A) | 967 |
799 (or (face-differs-from-default-p 'ediff-odd-diff-face-A) | 968 (defvar ediff-even-diff-face-Ancestor |
800 (cond ((ediff-color-display-p) | 969 (if (ediff-window-display-p) |
801 (ediff-set-face | 970 (progn |
802 'foreground 'ediff-odd-diff-face-A "White") | 971 (make-face 'ediff-even-diff-face-Ancestor) |
803 (ediff-set-face | 972 (or (face-differs-from-default-p 'ediff-even-diff-face-Ancestor) |
804 'background 'ediff-odd-diff-face-A "Gray")) | 973 (copy-face 'ediff-even-diff-face-C 'ediff-even-diff-face-Ancestor)) |
805 (t | 974 'ediff-even-diff-face-Ancestor)) |
806 (copy-face 'italic 'ediff-odd-diff-face-A)))) | 975 "Face highlighting even-numbered differences in the ancestor buffer.") |
807 'ediff-odd-diff-face-A) | 976 |
808 "Face used to highlight odd-numbered differences in buffer A.") | 977 (defvar ediff-odd-diff-face-A |
978 (if (ediff-window-display-p) | |
979 (progn | |
980 (make-face 'ediff-odd-diff-face-A) | |
981 (or (face-differs-from-default-p 'ediff-odd-diff-face-A) | |
982 (cond ((ediff-color-display-p) | |
983 (ediff-set-face | |
984 'foreground 'ediff-odd-diff-face-A "White") | |
985 (ediff-set-face | |
986 'background 'ediff-odd-diff-face-A "Gray")) | |
987 (t | |
988 (copy-face 'italic 'ediff-odd-diff-face-A)))) | |
989 'ediff-odd-diff-face-A)) | |
990 "Face used to highlight odd-numbered differences in buffer A.") | |
809 | 991 |
810 (defvar ediff-odd-diff-face-B | 992 (defvar ediff-odd-diff-face-B |
811 (progn | 993 (if (ediff-window-display-p) |
812 (make-face 'ediff-odd-diff-face-B) | 994 (progn |
813 (or (face-differs-from-default-p 'ediff-odd-diff-face-B) | 995 (make-face 'ediff-odd-diff-face-B) |
814 (cond ((ediff-color-display-p) | 996 (or (face-differs-from-default-p 'ediff-odd-diff-face-B) |
815 (ediff-set-face | 997 (cond ((ediff-color-display-p) |
816 'foreground 'ediff-odd-diff-face-B "Black") | 998 (ediff-set-face |
817 (ediff-set-face | 999 'foreground 'ediff-odd-diff-face-B "Black") |
818 'background 'ediff-odd-diff-face-B "light grey")) | 1000 (ediff-set-face |
819 (t | 1001 'background 'ediff-odd-diff-face-B "light grey")) |
820 (copy-face 'italic 'ediff-odd-diff-face-B)))) | 1002 (t |
821 'ediff-odd-diff-face-B) | 1003 (copy-face 'italic 'ediff-odd-diff-face-B)))) |
822 "Face used to highlight odd-numbered differences in buffer B.") | 1004 'ediff-odd-diff-face-B)) |
823 | 1005 "Face used to highlight odd-numbered differences in buffer B.") |
824 (defvar ediff-odd-diff-face-C | 1006 |
825 (progn | 1007 (defvar ediff-odd-diff-face-C |
826 (make-face 'ediff-odd-diff-face-C) | 1008 (if (ediff-window-display-p) |
827 (copy-face 'ediff-odd-diff-face-A 'ediff-odd-diff-face-C) | 1009 (progn |
828 'ediff-odd-diff-face-C) | 1010 (make-face 'ediff-odd-diff-face-C) |
829 "Face used to highlight odd-numbered differences in buffer C.") | 1011 (or (face-differs-from-default-p 'ediff-odd-diff-face-C) |
830 | 1012 (copy-face 'ediff-odd-diff-face-A 'ediff-odd-diff-face-C)) |
831 ;; Create *-var faces. These are the actual faces used to highlight | 1013 'ediff-odd-diff-face-C)) |
832 ;; odd-numbered difference regions. | 1014 "Face used to highlight odd-numbered differences in buffer C.") |
833 ;; They are used as follows: when highlighting is turned on, | 1015 |
834 ;; ediff-odd/even-diff-face-A/B/C are copied | 1016 (defvar ediff-odd-diff-face-Ancestor |
835 ;; into ediff-odd/even-diff-face-A/B/C-var, and all odd/even overlays become | 1017 (if (ediff-window-display-p) |
836 ;; highlighted. When highlighting is turned off, then the face 'default is | 1018 (progn |
837 ;; copied into ediff-odd/even-diff-face-A/B/C-var, thereby unhighlighting all | 1019 (make-face 'ediff-odd-diff-face-Ancestor) |
838 ;; difference regions. | 1020 (or (face-differs-from-default-p 'ediff-odd-diff-face-Ancestor) |
839 (make-face 'ediff-even-diff-face-A-var) | 1021 (copy-face 'ediff-odd-diff-face-C 'ediff-odd-diff-face-Ancestor)) |
840 (make-face 'ediff-even-diff-face-B-var) | 1022 'ediff-odd-diff-face-Ancestor)) |
841 (make-face 'ediff-even-diff-face-C-var) | 1023 "Face used to highlight even-numbered differences in the ancestor buffer.") |
842 (make-face 'ediff-odd-diff-face-A-var) | 1024 |
843 (make-face 'ediff-odd-diff-face-B-var) | 1025 ;; Help echo |
844 (make-face 'ediff-odd-diff-face-C-var) | 1026 (put 'ediff-fine-diff-face-A 'ediff-help-echo |
845 | 1027 "A `refinement' of the current difference region") |
846 ;; initialize *-var faces | 1028 (put 'ediff-fine-diff-face-B 'ediff-help-echo |
847 (defun ediff-init-var-faces () | 1029 "A `refinement' of the current difference region") |
848 (copy-face (if (and ediff-use-faces ediff-highlight-all-diffs) | 1030 (put 'ediff-fine-diff-face-C 'ediff-help-echo |
849 ediff-even-diff-face-A 'default) | 1031 "A `refinement' of the current difference region") |
850 'ediff-even-diff-face-A-var) | 1032 (put 'ediff-fine-diff-face-Ancestor 'ediff-help-echo |
851 (copy-face (if (and ediff-use-faces ediff-highlight-all-diffs) | 1033 "A `refinement' of the current difference region") |
852 ediff-even-diff-face-B 'default) | 1034 |
853 'ediff-even-diff-face-B-var) | |
854 (copy-face (if (and ediff-use-faces ediff-highlight-all-diffs) | |
855 ediff-even-diff-face-C 'default) | |
856 'ediff-even-diff-face-C-var) | |
857 (copy-face (if (and ediff-use-faces ediff-highlight-all-diffs) | |
858 ediff-odd-diff-face-A 'default) | |
859 'ediff-odd-diff-face-A-var) | |
860 (copy-face (if (and ediff-use-faces ediff-highlight-all-diffs) | |
861 ediff-odd-diff-face-B 'default) | |
862 'ediff-odd-diff-face-B-var) | |
863 (copy-face (if (and ediff-use-faces ediff-highlight-all-diffs) | |
864 ediff-odd-diff-face-C 'default) | |
865 'ediff-odd-diff-face-C-var) | |
866 ) | |
867 | |
868 | 1035 |
869 ;;; Overlays | 1036 ;;; Overlays |
870 | 1037 |
871 (ediff-defvar-local ediff-current-diff-overlay-A nil | 1038 (ediff-defvar-local ediff-current-diff-overlay-A nil |
872 "Overlay for the current difference region in buffer A.") | 1039 "Overlay for the current difference region in buffer A.") |
873 (ediff-defvar-local ediff-current-diff-overlay-B nil | 1040 (ediff-defvar-local ediff-current-diff-overlay-B nil |
874 "Overlay for the current difference region in buffer B.") | 1041 "Overlay for the current difference region in buffer B.") |
875 (ediff-defvar-local ediff-current-diff-overlay-C nil | 1042 (ediff-defvar-local ediff-current-diff-overlay-C nil |
876 "Overlay for the current difference region in buffer C.") | 1043 "Overlay for the current difference region in buffer C.") |
877 | 1044 (ediff-defvar-local ediff-current-diff-overlay-Ancestor nil |
878 (defun ediff-make-current-diff-overlay (type) | 1045 "Overlay for the current difference region in the ancestor buffer.") |
879 (let ((overlay (intern (format "ediff-current-diff-overlay-%S" type))) | 1046 |
880 (buffer (ediff-get-buffer type)) | 1047 ;; Compute priority of ediff overlay. |
881 (face (face-name | 1048 (defun ediff-highest-priority (start end buffer) |
882 (symbol-value | 1049 (let ((pos (max 1 (1- start))) |
883 (intern (format "ediff-current-diff-face-%S" type)))))) | 1050 ovr-list) |
884 (set overlay | 1051 (if ediff-xemacs-p |
885 (ediff-make-bullet-proof-overlay (point-max) (point-max) buffer)) | 1052 (1+ ediff-shadow-overlay-priority) |
886 (ediff-overlay-put (symbol-value overlay) 'face face) | 1053 (ediff-eval-in-buffer buffer |
887 (ediff-overlay-put (symbol-value overlay) 'ediff ediff-control-buffer) | 1054 (while (< pos (min (point-max) (1+ end))) |
888 )) | 1055 (setq ovr-list (append (overlays-at pos) ovr-list)) |
889 | 1056 (setq pos (next-overlay-change pos))) |
890 ;; Compute priority of ediff overlay. | 1057 (1+ (apply '+ |
891 (defun ediff-highest-priority (start end buffer) | 1058 (mapcar (function |
892 (let ((pos (max 1 (1- start))) | 1059 (lambda (ovr) |
893 ovr-list) | 1060 (if ovr |
894 (if ediff-xemacs-p | 1061 (or (ediff-overlay-get ovr 'priority) 0) |
895 (1+ ediff-shadow-overlay-priority) | 1062 0))) |
896 (ediff-eval-in-buffer buffer | 1063 ovr-list) |
897 (while (< pos (min (point-max) (1+ end))) | 1064 )) |
898 (setq ovr-list (append (overlays-at pos) ovr-list)) | 1065 )))) |
899 (setq pos (next-overlay-change pos))) | |
900 (1+ (apply '+ | |
901 (mapcar (function | |
902 (lambda (ovr) | |
903 (if ovr | |
904 (or (ediff-overlay-get ovr 'priority) 0) | |
905 0))) | |
906 ovr-list) | |
907 )) | |
908 )))) | |
909 ) | |
910 | 1066 |
911 | 1067 |
912 (defvar ediff-toggle-read-only-function nil | 1068 (defvar ediff-toggle-read-only-function nil |
913 "*Specifies the function to be used to toggle read-only. | 1069 "*Specifies the function to be used to toggle read-only. |
914 If nil, Ediff tries to deduce the function from the binding of C-x C-q. | 1070 If nil, Ediff tries to deduce the function from the binding of C-x C-q. |
981 (or (window-live-p wind) | 1137 (or (window-live-p wind) |
982 (setq wind (if prev-wind | 1138 (setq wind (if prev-wind |
983 (next-window wind) | 1139 (next-window wind) |
984 (selected-window))))) | 1140 (selected-window))))) |
985 | 1141 |
986 (defsubst ediff-convert-diffs-to-overlays (diff-list) | |
987 (ediff-set-diff-overlays-in-one-buffer 'A diff-list) | |
988 (ediff-set-diff-overlays-in-one-buffer 'B diff-list) | |
989 (if ediff-3way-job | |
990 (ediff-set-diff-overlays-in-one-buffer 'C diff-list)) | |
991 (message "Processing difference regions ... done")) | |
992 | |
993 | 1142 |
994 (defsubst ediff-kill-buffer-carefully (buf) | 1143 (defsubst ediff-kill-buffer-carefully (buf) |
995 "Kill buffer BUF if it exists." | 1144 "Kill buffer BUF if it exists." |
996 (if (ediff-buffer-live-p buf) | 1145 (if (ediff-buffer-live-p buf) |
997 (kill-buffer (get-buffer buf)))) | 1146 (kill-buffer (get-buffer buf)))) |
999 | 1148 |
1000 (defsubst ediff-highlight-diff (n) | 1149 (defsubst ediff-highlight-diff (n) |
1001 "Put face on diff N. Invoked for X displays only." | 1150 "Put face on diff N. Invoked for X displays only." |
1002 (ediff-highlight-diff-in-one-buffer n 'A) | 1151 (ediff-highlight-diff-in-one-buffer n 'A) |
1003 (ediff-highlight-diff-in-one-buffer n 'B) | 1152 (ediff-highlight-diff-in-one-buffer n 'B) |
1004 (ediff-highlight-diff-in-one-buffer n 'C)) | 1153 (ediff-highlight-diff-in-one-buffer n 'C) |
1154 (ediff-highlight-diff-in-one-buffer n 'Ancestor) | |
1155 ) | |
1005 | 1156 |
1006 | 1157 |
1007 (defsubst ediff-unhighlight-diff () | 1158 (defsubst ediff-unhighlight-diff () |
1008 "Remove overlays from buffers A, B, and C." | 1159 "Remove overlays from buffers A, B, and C." |
1009 (ediff-unhighlight-diff-in-one-buffer 'A) | 1160 (ediff-unhighlight-diff-in-one-buffer 'A) |
1010 (ediff-unhighlight-diff-in-one-buffer 'B) | 1161 (ediff-unhighlight-diff-in-one-buffer 'B) |
1011 (ediff-unhighlight-diff-in-one-buffer 'C)) | 1162 (ediff-unhighlight-diff-in-one-buffer 'C) |
1163 (ediff-unhighlight-diff-in-one-buffer 'Ancestor) | |
1164 ) | |
1012 | 1165 |
1013 ;; delete highlighting overlays, restore faces to their original form | 1166 ;; delete highlighting overlays, restore faces to their original form |
1014 (defsubst ediff-unhighlight-diffs-totally () | 1167 (defsubst ediff-unhighlight-diffs-totally () |
1015 (ediff-unhighlight-diffs-totally-in-one-buffer 'A) | 1168 (ediff-unhighlight-diffs-totally-in-one-buffer 'A) |
1016 (ediff-unhighlight-diffs-totally-in-one-buffer 'B) | 1169 (ediff-unhighlight-diffs-totally-in-one-buffer 'B) |
1017 (ediff-unhighlight-diffs-totally-in-one-buffer 'C)) | 1170 (ediff-unhighlight-diffs-totally-in-one-buffer 'C) |
1171 (ediff-unhighlight-diffs-totally-in-one-buffer 'Ancestor) | |
1172 ) | |
1173 | |
1174 (defsubst ediff-background-face (buf-type dif-num) | |
1175 ;; The value of dif-num is always 1- the one that user sees. | |
1176 ;; This is why even face is used when dif-num is odd. | |
1177 (intern (format (if (ediff-odd-p dif-num) | |
1178 "ediff-even-diff-face-%S" | |
1179 "ediff-odd-diff-face-%S") | |
1180 buf-type))) | |
1018 | 1181 |
1019 | 1182 |
1020 ;; arg is a record for a given diff in a difference vector | 1183 ;; arg is a record for a given diff in a difference vector |
1021 ;; this record is itself a vector | 1184 ;; this record is itself a vector |
1022 (defsubst ediff-clear-fine-diff-vector (diff-record) | 1185 (defsubst ediff-clear-fine-diff-vector (diff-record) |
1045 (defsubst ediff-mouse-event-p (event) | 1208 (defsubst ediff-mouse-event-p (event) |
1046 (if ediff-xemacs-p | 1209 (if ediff-xemacs-p |
1047 (button-event-p event) | 1210 (button-event-p event) |
1048 (string-match "mouse" (format "%S" (event-basic-type event))) | 1211 (string-match "mouse" (format "%S" (event-basic-type event))) |
1049 )) | 1212 )) |
1213 | |
1214 | |
1215 (defsubst ediff-key-press-event-p (event) | |
1216 (if ediff-xemacs-p | |
1217 (key-press-event-p event) | |
1218 (or (char-or-string-p event) (symbolp event)))) | |
1219 | |
1220 (defun ediff-event-point (event) | |
1221 (cond ((ediff-mouse-event-p event) | |
1222 (if ediff-xemacs-p | |
1223 (event-point event) | |
1224 (posn-point (event-start event)))) | |
1225 ((ediff-key-press-event-p event) | |
1226 (point)) | |
1227 (t (error)))) | |
1228 | |
1229 (defun ediff-event-buffer (event) | |
1230 (cond ((ediff-mouse-event-p event) | |
1231 (if ediff-xemacs-p | |
1232 (event-buffer event) | |
1233 (window-buffer (posn-window (event-start event))))) | |
1234 ((ediff-key-press-event-p event) | |
1235 (current-buffer)) | |
1236 (t (error)))) | |
1237 | |
1050 | 1238 |
1051 (defsubst ediff-frame-iconified-p (frame) | 1239 (defsubst ediff-frame-iconified-p (frame) |
1052 (if (and (ediff-window-display-p) (frame-live-p frame)) | 1240 (if (and (ediff-window-display-p) (frame-live-p frame)) |
1053 (if ediff-xemacs-p | 1241 (if ediff-xemacs-p |
1054 (frame-iconified-p frame) | 1242 (frame-iconified-p frame) |
1064 (defsubst ediff-frame-char-width (frame) | 1252 (defsubst ediff-frame-char-width (frame) |
1065 (if ediff-xemacs-p | 1253 (if ediff-xemacs-p |
1066 (/ (frame-pixel-width frame) (frame-width frame)) | 1254 (/ (frame-pixel-width frame) (frame-width frame)) |
1067 (frame-char-width frame))) | 1255 (frame-char-width frame))) |
1068 | 1256 |
1069 (defsubst ediff-reset-mouse (&optional frame) | 1257 (defun ediff-reset-mouse (&optional frame do-not-grab-mouse) |
1070 (setq frame | 1258 (or frame (setq frame (selected-frame))) |
1071 (if ediff-xemacs-p | 1259 (if (ediff-window-display-p) |
1072 (frame-selected-window (or frame (selected-frame))) | 1260 (let ((frame-or-wind frame)) |
1073 (or frame (selected-frame)))) | 1261 (if ediff-xemacs-p |
1074 (if (ediff-window-display-p) | 1262 (setq frame-or-wind (frame-selected-window frame))) |
1075 (set-mouse-position frame 1 0))) | 1263 (or do-not-grab-mouse |
1264 ;; don't set mouse if the user said to never do this | |
1265 (not ediff-grab-mouse) | |
1266 ;; Don't grab on quit, if the user doesn't want to. | |
1267 ;; If ediff-grab-mouse = t, then mouse won't be grabbed for | |
1268 ;; sessions that are not part of a group (this is done in | |
1269 ;; ediff-recenter). The condition below affects only terminating | |
1270 ;; sessions in session groups (in whhich case mouse is warped into | |
1271 ;; a meta buffer). | |
1272 (and (eq ediff-grab-mouse 'maybe) | |
1273 (memq this-command '(ediff-quit ediff-update-diffs))) | |
1274 (set-mouse-position frame-or-wind 1 0)) | |
1275 ))) | |
1276 | |
1277 (defsubst ediff-spy-after-mouse () | |
1278 (setq ediff-mouse-pixel-position (mouse-pixel-position))) | |
1279 | |
1280 ;; This is actually not easy to find out since emacs and xemacs behave | |
1281 ;; differently when mouse is not in any frame. Also, this is sensitive to | |
1282 ;; when the user grabbed mouse. | |
1283 ;; Not used for now. | |
1284 (defun ediff-user-grabbed-mouse () | |
1285 (if ediff-mouse-pixel-position | |
1286 (cond ((not (eq (car ediff-mouse-pixel-position) | |
1287 (car (mouse-pixel-position))))) | |
1288 ((and (car (cdr ediff-mouse-pixel-position)) | |
1289 (car (cdr (mouse-pixel-position))) | |
1290 (cdr (cdr ediff-mouse-pixel-position)) | |
1291 (cdr (cdr (mouse-pixel-position)))) | |
1292 (not (and (< (abs (- (car (cdr ediff-mouse-pixel-position)) | |
1293 (car (cdr (mouse-pixel-position))))) | |
1294 ediff-mouse-pixel-threshhold) | |
1295 (< (abs (- (cdr (cdr ediff-mouse-pixel-position)) | |
1296 (cdr (cdr (mouse-pixel-position))))) | |
1297 ediff-mouse-pixel-threshhold)))) | |
1298 (t nil)))) | |
1076 | 1299 |
1077 (defsubst ediff-frame-char-height (frame) | 1300 (defsubst ediff-frame-char-height (frame) |
1078 (if ediff-xemacs-p | 1301 (if ediff-xemacs-p |
1079 (/ (frame-pixel-height frame) (frame-height frame)) | 1302 (/ (frame-pixel-height frame) (frame-height frame)) |
1080 (frame-char-height frame))) | 1303 (frame-char-height frame))) |
1096 | 1319 |
1097 ;; Test if diff region is white space only. | 1320 ;; Test if diff region is white space only. |
1098 ;; If 2-way job and buf-type = C, then returns t. | 1321 ;; If 2-way job and buf-type = C, then returns t. |
1099 (defun ediff-whitespace-diff-region-p (n buf-type) | 1322 (defun ediff-whitespace-diff-region-p (n buf-type) |
1100 (or (and (eq buf-type 'C) (not ediff-3way-job)) | 1323 (or (and (eq buf-type 'C) (not ediff-3way-job)) |
1324 (ediff-empty-diff-region-p n buf-type) | |
1101 (let ((beg (ediff-get-diff-posn buf-type 'beg n)) | 1325 (let ((beg (ediff-get-diff-posn buf-type 'beg n)) |
1102 (end (ediff-get-diff-posn buf-type 'end n))) | 1326 (end (ediff-get-diff-posn buf-type 'end n))) |
1103 (ediff-eval-in-buffer (ediff-get-buffer buf-type) | 1327 (ediff-eval-in-buffer (ediff-get-buffer buf-type) |
1104 (save-excursion | 1328 (save-excursion |
1105 (goto-char beg) | 1329 (goto-char beg) |
1106 (skip-chars-forward ediff-whitespace) | 1330 (skip-chars-forward ediff-whitespace) |
1107 (>= (point) end)))))) | 1331 (>= (point) end)))))) |
1108 | 1332 |
1109 ;; temporarily uses DIR to abbreviate file name | 1333 ;; temporarily uses DIR to abbreviate file name |
1110 ;; if DIR is nil, use default-directory | 1334 ;; if DIR is nil, use default-directory |
1111 (defsubst ediff-abbreviate-filename (file dir) | 1335 (defsubst ediff-abbreviate-file-name (file &optional dir) |
1112 (let* ((dir (or dir default-directory)) | 1336 (cond ((stringp dir) |
1113 (directory-abbrev-alist (list (cons dir "")))) | 1337 (let ((directory-abbrev-alist (list (cons dir "")))) |
1114 (abbreviate-file-name file))) | 1338 (abbreviate-file-name file))) |
1339 (ediff-emacs-p (abbreviate-file-name file)) | |
1340 (t ; XEmacs requires addl argument | |
1341 (abbreviate-file-name file t)))) | |
1342 | |
1343 ;; Takes a directory and returns the parent directory. | |
1344 ;; does nothing to `/'. If the ARG is a regular file, | |
1345 ;; strip the file AND the last dir. | |
1346 (defun ediff-strip-last-dir (dir) | |
1347 (if (not (stringp dir)) (setq dir default-directory)) | |
1348 (setq dir (expand-file-name dir)) | |
1349 (or (file-directory-p dir) (setq dir (file-name-directory dir))) | |
1350 (let* ((pos (1- (length dir))) | |
1351 (last-char (aref dir pos))) | |
1352 (if (and (> pos 0) (= last-char ?/)) | |
1353 (setq dir (substring dir 0 pos))) | |
1354 (ediff-abbreviate-file-name (file-name-directory dir)))) | |
1355 | |
1356 (defun ediff-truncate-string-left (str newlen) | |
1357 ;; leave space for ... on the left | |
1358 (let ((len (length str)) | |
1359 substr) | |
1360 (if (<= len newlen) | |
1361 str | |
1362 (setq newlen (max 0 (- newlen 3))) | |
1363 (setq substr (substring str (max 0 (- len 1 newlen)))) | |
1364 (concat "..." substr)))) | |
1365 | |
1366 (defun ediff-abbrev-jobname (jobname) | |
1367 (cond ((eq jobname 'ediff-directories) | |
1368 "Compare two directories") | |
1369 ((eq jobname 'ediff-files) | |
1370 "Compare two files") | |
1371 ((eq jobname 'ediff-buffers) | |
1372 "Compare two buffers") | |
1373 ((eq jobname 'ediff-directories3) | |
1374 "Compare three directories") | |
1375 ((eq jobname 'ediff-files3) | |
1376 "Compare three files") | |
1377 ((eq jobname 'ediff-buffers3) | |
1378 "Compare three buffers") | |
1379 ((eq jobname 'ediff-revision) | |
1380 "Compare file with a version") | |
1381 ((eq jobname 'ediff-directory-revisions) | |
1382 "Compare dir files with versions") | |
1383 ((eq jobname 'ediff-merge-directory-revisions) | |
1384 "Merge dir files with versions") | |
1385 ((eq jobname 'ediff-merge-directory-revisions-with-ancestor) | |
1386 "Merge dir versions via ancestors") | |
1387 (t | |
1388 (let* ((str (substring (symbol-name jobname) 6)) | |
1389 (len (length str)) | |
1390 (pos 0)) | |
1391 (while (< pos len) | |
1392 (if (= pos 0) | |
1393 (aset str pos (upcase (aref str pos)))) | |
1394 (if (= (aref str pos) ?-) | |
1395 (aset str pos ?\ )) | |
1396 (setq pos (1+ pos))) | |
1397 str)))) | |
1398 | |
1399 | |
1115 | 1400 |
1116 (defsubst ediff-get-region-contents (n buf-type ctrl-buf &optional start end) | 1401 (defsubst ediff-get-region-contents (n buf-type ctrl-buf &optional start end) |
1117 (ediff-eval-in-buffer | 1402 (ediff-eval-in-buffer |
1118 (ediff-eval-in-buffer ctrl-buf (ediff-get-buffer buf-type)) | 1403 (ediff-eval-in-buffer ctrl-buf (ediff-get-buffer buf-type)) |
1119 (buffer-substring | 1404 (buffer-substring |
1120 (or start (ediff-get-diff-posn buf-type 'beg n ctrl-buf)) | 1405 (or start (ediff-get-diff-posn buf-type 'beg n ctrl-buf)) |
1121 (or end (ediff-get-diff-posn buf-type 'end n ctrl-buf))))) | 1406 (or end (ediff-get-diff-posn buf-type 'end n ctrl-buf))))) |
1122 | 1407 |
1123 ;; If ediff modified mode line, strip the modification | 1408 ;; If ediff modified mode line, strip the modification |
1124 (defsubst ediff-strip-mode-line-format () | 1409 (defsubst ediff-strip-mode-line-format () |
1125 (if (member (car mode-line-format) '(" A: " " B: " " C: ")) | 1410 (if (member (car mode-line-format) '(" A: " " B: " " C: " " Ancestor: ")) |
1126 (setq mode-line-format (nth 2 mode-line-format)))) | 1411 (setq mode-line-format (nth 2 mode-line-format)))) |
1127 | 1412 |
1128 ;; Verify that we have a difference selected. | 1413 ;; Verify that we have a difference selected. |
1129 (defsubst ediff-valid-difference-p (&optional n) | 1414 (defsubst ediff-valid-difference-p (&optional n) |
1130 (or n (setq n ediff-current-difference)) | 1415 (or n (setq n ediff-current-difference)) |
1131 (and (>= n 0) (< n ediff-number-of-differences))) | 1416 (and (>= n 0) (< n ediff-number-of-differences))) |
1132 | 1417 |
1133 (defsubst ediff-show-all-diffs (n) | 1418 (defsubst ediff-show-all-diffs (n) |
1134 "Don't skip difference regions." | 1419 "Don't skip difference regions." |
1135 nil) | 1420 nil) |
1421 | |
1422 (defsubst Xor (a b) | |
1423 (or (and a (not b)) (and (not a) b))) | |
1136 | 1424 |
1137 (provide 'ediff-init) | 1425 (provide 'ediff-init) |
1138 | 1426 |
1139 | 1427 |
1140 ;;; ediff-init.el ends here | 1428 ;;; ediff-init.el ends here |