Mercurial > emacs
comparison lisp/ediff-init.el @ 42602:633233bf2bbf
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
* viper-init.el (viper-cond-compile-for-xemacs-or-emacs):
new macro that replaces viper-emacs-p and viper-xemacs-p in many
cases. Used to reduce the number of warnings.
* viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs.
(viper-standard-value): moved here from viper.el.
(viper-set-unread-command-events): moved to viper-util.el
(viper-check-minibuffer-overlay): make sure
viper-minibuffer-overlay is moved to cover the entire input field.
* viper-util.el: use viper-cond-compile-for-xemacs-or-emacs.
(viper-read-key-sequence, viper-set-unread-command-events,
viper-char-symbol-sequence-p, viper-char-array-p): moved here.
* viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p,
viper-event-vector-p): moved to viper-util.el
* viper.el (viper-standard-value): moved to viper-cmd.el.
Use viper-cond-compile-for-xemacs-or-emacs.
* ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new
macro designed to be used in many places where ediff-emacs-p or
ediff-xemacs-p was previously used. Reduces the number of
warnings.
Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue
of ediff-xemacs-p.
(ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer,
ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p,
ediff-whitespace-diff-region-p, ediff-get-region-contents):
moved to ediff-util.el.
(ediff-event-key): moved here.
* ediff-merge.el: got rid of unreferenced variables.
* ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs.
(ediff-cleanup-mess): improved the way windows are set up after
quitting ediff.
(ediff-janitor): use ediff-dispose-of-variant-according-to-user.
(ediff-dispose-of-variant-according-to-user): new function
designed to be smarter and also understands indirect buffers.
(ediff-highlight-diff-in-one-buffer,
ediff-unhighlight-diff-in-one-buffer,
ediff-unhighlight-diffs-totally-in-one-buffer,
ediff-highlight-diff, ediff-highlight-diff,
ediff-unhighlight-diff, ediff-unhighlight-diffs-totally,
ediff-empty-diff-region-p, ediff-whitespace-diff-region-p,
ediff-get-region-contents, ediff-make-current-diff-overlay):
moved here.
(ediff-format-bindings-of): new function by Hannu Koivisto
<azure@iki.fi>.
(ediff-setup): make sure the merge buffer is always widened and
modifiable.
(ediff-write-merge-buffer-and-maybe-kill): refuse to write the
result of a merge into a file visited by another buffer.
(ediff-arrange-autosave-in-merge-jobs): check if the merge file
is visited by another buffer and ask to save/delete that buffer.
(ediff-verify-file-merge-buffer): new function to do the above.
* ediff-vers.el: load ediff-init.el at compile time.
* ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff.el (ediff-windows, ediff-regions-wordwise,
ediff-regions-linewise): use indirect buffers to improve
robustness and make it possible to compare regions of the same
buffer (even overlapping regions).
(ediff-clone-buffer-for-region-comparison,
ediff-clone-buffer-for-window-comparison): new functions.
(ediff-files-internal): refuse to compare identical files.
(ediff-regions-internal): get rid of the warning about comparing
regions of the same buffer.
* ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here.
Plus the following fixes courtesy of Dave Love:
Doc fixes.
(ediff-word-1): Use word class and move - to the
front per regexp documentation.
(ediff-wordify): Bind forward-word-function outside loop.
(ediff-copy-to-buffer): Use insert-buffer-substring rather than
consing buffer contents.
(ediff-goto-word): Move syntax table setting outside loop.
author | Michael Kifer <kifer@cs.stonybrook.edu> |
---|---|
date | Tue, 08 Jan 2002 04:36:01 +0000 |
parents | 3ce98f3e0608 |
children | 69c91aaa067a |
comparison
equal
deleted
inserted
replaced
42601:ddd4802ff361 | 42602:633233bf2bbf |
---|---|
1 ;;; ediff-init.el --- Macros, variables, and defsubsts used by Ediff | 1 ;;; ediff-init.el --- Macros, variables, and defsubsts used by Ediff |
2 | 2 |
3 ;; Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> | 5 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu> |
6 | 6 |
7 ;; This file is part of GNU Emacs. | 7 ;; This file is part of GNU Emacs. |
8 | 8 |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | 9 ;; GNU Emacs is free software; you can redistribute it and/or modify |
10 ;; it under the terms of the GNU General Public License as published by | 10 ;; it under the terms of the GNU General Public License as published by |
33 (defvar ediff-mouse-pixel-position) | 33 (defvar ediff-mouse-pixel-position) |
34 (defvar ediff-mouse-pixel-threshold) | 34 (defvar ediff-mouse-pixel-threshold) |
35 (defvar ediff-whitespace) | 35 (defvar ediff-whitespace) |
36 (defvar ediff-multiframe) | 36 (defvar ediff-multiframe) |
37 (defvar ediff-use-toolbar-p) | 37 (defvar ediff-use-toolbar-p) |
38 (defvar mswindowsx-bitmap-file-path) | |
38 | 39 |
39 (and noninteractive | 40 (and noninteractive |
40 (eval-when-compile | 41 (eval-when-compile |
41 (load "ange-ftp" 'noerror))) | 42 (load "ange-ftp" 'noerror))) |
42 ;; end pacifier | 43 ;; end pacifier |
44 ;; Is it XEmacs? | 45 ;; Is it XEmacs? |
45 (defconst ediff-xemacs-p (string-match "XEmacs" emacs-version)) | 46 (defconst ediff-xemacs-p (string-match "XEmacs" emacs-version)) |
46 ;; Is it Emacs? | 47 ;; Is it Emacs? |
47 (defconst ediff-emacs-p (not ediff-xemacs-p)) | 48 (defconst ediff-emacs-p (not ediff-xemacs-p)) |
48 | 49 |
50 ;; This is used to avoid compilation warnings. When emacs/xemacs forms can | |
51 ;; generate compile time warnings, we use this macro. | |
52 ;; In this case, the macro will expand into the form that is appropriate to the | |
53 ;; compiler at hand. | |
54 ;; Suggested by rms. | |
55 (defmacro ediff-cond-compile-for-xemacs-or-emacs (xemacs-form emacs-form) | |
56 (if (string-match "XEmacs" emacs-version) | |
57 xemacs-form emacs-form)) | |
58 | |
49 (defvar ediff-force-faces nil | 59 (defvar ediff-force-faces nil |
50 "If t, Ediff will think that it is running on a display that supports faces. | 60 "If t, Ediff will think that it is running on a display that supports faces. |
51 This is provided as a temporary relief for users of face-capable displays | 61 This is provided as a temporary relief for users of face-capable displays |
52 that Ediff doesn't know about.") | 62 that Ediff doesn't know about.") |
53 | 63 |
54 ;; Are we running as a window application or on a TTY? | 64 ;; Are we running as a window application or on a TTY? |
55 (defsubst ediff-device-type () | 65 (defsubst ediff-device-type () |
56 (if ediff-emacs-p | 66 (ediff-cond-compile-for-xemacs-or-emacs |
57 window-system | 67 (device-type (selected-device)) ; xemacs form |
58 (device-type (selected-device)))) | 68 window-system ; emacs form |
69 )) | |
59 | 70 |
60 ;; in XEmacs: device-type is tty on tty and stream in batch. | 71 ;; in XEmacs: device-type is tty on tty and stream in batch. |
61 (defun ediff-window-display-p () | 72 (defun ediff-window-display-p () |
62 (and (ediff-device-type) (not (memq (ediff-device-type) '(tty pc stream))))) | 73 (and (ediff-device-type) (not (memq (ediff-device-type) '(tty pc stream))))) |
63 | 74 |
67 (ediff-force-faces) | 78 (ediff-force-faces) |
68 ((ediff-color-display-p)) | 79 ((ediff-color-display-p)) |
69 (ediff-emacs-p (memq (ediff-device-type) '(pc))) | 80 (ediff-emacs-p (memq (ediff-device-type) '(pc))) |
70 (ediff-xemacs-p (memq (ediff-device-type) '(tty pc))))) | 81 (ediff-xemacs-p (memq (ediff-device-type) '(tty pc))))) |
71 | 82 |
83 ;; toolbar support for emacs hasn't been implemented in ediff | |
72 (defun ediff-has-toolbar-support-p () | 84 (defun ediff-has-toolbar-support-p () |
73 (and ediff-xemacs-p | 85 (ediff-cond-compile-for-xemacs-or-emacs |
74 (featurep 'toolbar) | 86 (and (featurep 'toolbar) (console-on-window-system-p)) ; xemacs form |
75 (console-on-window-system-p))) | 87 nil ; emacs form |
88 )) | |
76 | 89 |
77 (defun ediff-use-toolbar-p () | 90 (defun ediff-use-toolbar-p () |
78 (and (ediff-has-toolbar-support-p) ;Can it do it ? | 91 (and (ediff-has-toolbar-support-p) ;Can it do it ? |
79 (boundp 'ediff-use-toolbar-p) | 92 (boundp 'ediff-use-toolbar-p) |
80 ediff-use-toolbar-p)) ;Does the user want it ? | 93 ediff-use-toolbar-p)) ;Does the user want it ? |
105 (ediff-defvar-local ediff-buffer-C nil "") | 118 (ediff-defvar-local ediff-buffer-C nil "") |
106 ;; Ancestor buffer | 119 ;; Ancestor buffer |
107 (ediff-defvar-local ediff-ancestor-buffer nil "") | 120 (ediff-defvar-local ediff-ancestor-buffer nil "") |
108 ;; The Ediff control buffer | 121 ;; The Ediff control buffer |
109 (ediff-defvar-local ediff-control-buffer nil "") | 122 (ediff-defvar-local ediff-control-buffer nil "") |
123 | |
124 (ediff-defvar-local ediff-temp-indirect-buffer nil | |
125 "If t, the buffer is a temporary indirect buffer. | |
126 It needs to be killed when we quit the session.") | |
110 | 127 |
111 | 128 |
112 ;; Association between buff-type and ediff-buffer-* | 129 ;; Association between buff-type and ediff-buffer-* |
113 (defconst ediff-buffer-alist | 130 (defconst ediff-buffer-alist |
114 '((?A . ediff-buffer-A) | 131 '((?A . ediff-buffer-A) |
729 to temp files when Ediff needs to find fine differences." | 746 to temp files when Ediff needs to find fine differences." |
730 :type 'symbol | 747 :type 'symbol |
731 :group 'ediff) | 748 :group 'ediff) |
732 | 749 |
733 | 750 |
734 (if ediff-xemacs-p | 751 (ediff-cond-compile-for-xemacs-or-emacs |
735 (progn | 752 (progn ; xemacs |
736 (fset 'ediff-read-event (symbol-function 'next-command-event)) | 753 (fset 'ediff-read-event (symbol-function 'next-command-event)) |
737 (fset 'ediff-overlayp (symbol-function 'extentp)) | 754 (fset 'ediff-overlayp (symbol-function 'extentp)) |
738 (fset 'ediff-make-overlay (symbol-function 'make-extent)) | 755 (fset 'ediff-make-overlay (symbol-function 'make-extent)) |
739 (fset 'ediff-delete-overlay (symbol-function 'delete-extent))) | 756 (fset 'ediff-delete-overlay (symbol-function 'delete-extent))) |
740 (fset 'ediff-read-event (symbol-function 'read-event)) | 757 (progn ; emacs |
741 (fset 'ediff-overlayp (symbol-function 'overlayp)) | 758 (fset 'ediff-read-event (symbol-function 'read-event)) |
742 (fset 'ediff-make-overlay (symbol-function 'make-overlay)) | 759 (fset 'ediff-overlayp (symbol-function 'overlayp)) |
743 (fset 'ediff-delete-overlay (symbol-function 'delete-overlay))) | 760 (fset 'ediff-make-overlay (symbol-function 'make-overlay)) |
761 (fset 'ediff-delete-overlay (symbol-function 'delete-overlay))) | |
762 ) | |
744 | 763 |
745 ;; Check the current version against the major and minor version numbers | 764 ;; Check the current version against the major and minor version numbers |
746 ;; using op: cur-vers op major.minor If emacs-major-version or | 765 ;; using op: cur-vers op major.minor If emacs-major-version or |
747 ;; emacs-minor-version are not defined, we assume that the current version | 766 ;; emacs-minor-version are not defined, we assume that the current version |
748 ;; is hopelessly outdated. We assume that emacs-major-version and | 767 ;; is hopelessly outdated. We assume that emacs-major-version and |
770 ((memq op '(< <=)) t)))) | 789 ((memq op '(< <=)) t)))) |
771 | 790 |
772 | 791 |
773 (defun ediff-color-display-p () | 792 (defun ediff-color-display-p () |
774 (condition-case nil | 793 (condition-case nil |
775 (if ediff-emacs-p | 794 (ediff-cond-compile-for-xemacs-or-emacs |
776 (if (fboundp 'display-color-p) | 795 (eq (device-class (selected-device)) 'color) ; xemacs form |
777 (display-color-p) | 796 (if (fboundp 'display-color-p) ; emacs form |
778 (x-display-color-p)) | 797 (display-color-p) |
779 (eq (device-class (selected-device)) 'color)) | 798 (x-display-color-p)) |
780 (error | 799 ) |
781 nil))) | 800 (error nil))) |
782 | 801 |
783 | 802 |
784 (if (ediff-has-face-support-p) | 803 (if (ediff-has-face-support-p) |
785 (if ediff-xemacs-p | 804 (ediff-cond-compile-for-xemacs-or-emacs |
786 (progn | 805 (progn ; xemacs |
787 (fset 'ediff-valid-color-p (symbol-function 'valid-color-name-p)) | 806 (defalias 'ediff-valid-color-p 'valid-color-name-p) |
788 (fset 'ediff-get-face (symbol-function 'get-face))) | 807 (defalias 'ediff-get-face 'get-face)) |
789 (fset 'ediff-valid-color-p (symbol-function | 808 (progn ; emacs |
790 (if (fboundp 'color-defined-p) | 809 (defalias 'ediff-valid-color-p (if (fboundp 'color-defined-p) |
791 'color-defined-p | 810 'color-defined-p |
792 'x-color-defined-p))) | 811 'x-color-defined-p)) |
793 (fset 'ediff-get-face (symbol-function 'internal-get-face)))) | 812 (defalias 'ediff-get-face 'internal-get-face)) |
813 )) | |
794 | 814 |
795 (if (ediff-window-display-p) | 815 (if (ediff-window-display-p) |
796 (if ediff-xemacs-p | 816 (ediff-cond-compile-for-xemacs-or-emacs |
797 (progn | 817 (progn ; xemacs |
798 (fset 'ediff-display-pixel-width | 818 (fset 'ediff-display-pixel-width (symbol-function 'device-pixel-width)) |
799 (symbol-function 'device-pixel-width)) | 819 (fset 'ediff-display-pixel-height |
800 (fset 'ediff-display-pixel-height | 820 (symbol-function 'device-pixel-height))) |
801 (symbol-function 'device-pixel-height))) | 821 (progn ; emacs |
802 (fset 'ediff-display-pixel-width (symbol-function | 822 (fset 'ediff-display-pixel-width |
803 (if (fboundp 'display-pixel-width) | 823 (if (fboundp 'display-pixel-width) |
804 'display-pixel-width | 824 (symbol-function 'display-pixel-width) |
805 'x-display-pixel-width))) | 825 (symbol-function 'x-display-pixel-width))) |
806 (fset 'ediff-display-pixel-height (symbol-function | 826 (fset 'ediff-display-pixel-height |
807 (if (fboundp 'display-pixel-height) | 827 (if (fboundp 'display-pixel-height) |
808 'display-pixel-height | 828 (symbol-function 'display-pixel-height) |
809 'x-display-pixel-height))))) | 829 (symbol-function 'x-display-pixel-height)))) |
830 )) | |
810 | 831 |
811 ;; A-list of current-diff-overlay symbols associated with buf types | 832 ;; A-list of current-diff-overlay symbols associated with buf types |
812 (defconst ediff-current-diff-overlay-alist | 833 (defconst ediff-current-diff-overlay-alist |
813 '((A . ediff-current-diff-overlay-A) | 834 '((A . ediff-current-diff-overlay-A) |
814 (B . ediff-current-diff-overlay-B) | 835 (B . ediff-current-diff-overlay-B) |
820 '((A . ediff-current-diff-face-A) | 841 '((A . ediff-current-diff-face-A) |
821 (B . ediff-current-diff-face-B) | 842 (B . ediff-current-diff-face-B) |
822 (C . ediff-current-diff-face-C) | 843 (C . ediff-current-diff-face-C) |
823 (Ancestor . ediff-current-diff-face-Ancestor))) | 844 (Ancestor . ediff-current-diff-face-Ancestor))) |
824 | 845 |
825 | |
826 (defun ediff-make-current-diff-overlay (type) | |
827 (if (ediff-has-face-support-p) | |
828 (let ((overlay (ediff-get-symbol-from-alist | |
829 type ediff-current-diff-overlay-alist)) | |
830 (buffer (ediff-get-buffer type)) | |
831 (face (face-name | |
832 (symbol-value | |
833 (ediff-get-symbol-from-alist | |
834 type ediff-current-diff-face-alist))))) | |
835 (set overlay | |
836 (ediff-make-bullet-proof-overlay (point-max) (point-max) buffer)) | |
837 (ediff-set-overlay-face (symbol-value overlay) face) | |
838 (ediff-overlay-put (symbol-value overlay) 'ediff ediff-control-buffer)) | |
839 )) | |
840 | 846 |
841 (defun ediff-set-overlay-face (extent face) | 847 (defun ediff-set-overlay-face (extent face) |
842 (ediff-overlay-put extent 'face face) | 848 (ediff-overlay-put extent 'face face) |
843 (ediff-overlay-put extent 'help-echo 'ediff-region-help-echo)) | 849 (ediff-overlay-put extent 'help-echo 'ediff-region-help-echo)) |
844 | 850 |
1192 | 1198 |
1193 ;; Compute priority of a current ediff overlay. | 1199 ;; Compute priority of a current ediff overlay. |
1194 (defun ediff-highest-priority (start end buffer) | 1200 (defun ediff-highest-priority (start end buffer) |
1195 (let ((pos (max 1 (1- start))) | 1201 (let ((pos (max 1 (1- start))) |
1196 ovr-list) | 1202 ovr-list) |
1197 (if ediff-xemacs-p | 1203 (ediff-cond-compile-for-xemacs-or-emacs |
1198 (1+ ediff-shadow-overlay-priority) | 1204 (1+ ediff-shadow-overlay-priority) ; xemacs form |
1199 (ediff-with-current-buffer buffer | 1205 ;; emacs form |
1200 (while (< pos (min (point-max) (1+ end))) | 1206 (ediff-with-current-buffer buffer |
1201 (setq ovr-list (append (overlays-at pos) ovr-list)) | 1207 (while (< pos (min (point-max) (1+ end))) |
1202 (setq pos (next-overlay-change pos))) | 1208 (setq ovr-list (append (overlays-at pos) ovr-list)) |
1203 (+ 1 ediff-shadow-overlay-priority | 1209 (setq pos (next-overlay-change pos))) |
1204 (apply 'max | 1210 (+ 1 ediff-shadow-overlay-priority |
1205 (cons | 1211 (apply 'max |
1206 1 | 1212 (cons |
1207 (mapcar | 1213 1 |
1208 (lambda (ovr) | 1214 (mapcar |
1209 (if (and ovr | 1215 (lambda (ovr) |
1210 ;; exclude ediff overlays from priority | 1216 (if (and ovr |
1211 ;; calculation, or else priority will keep | 1217 ;; exclude ediff overlays from priority |
1212 ;; increasing | 1218 ;; calculation, or else priority will keep |
1213 (null (ediff-overlay-get ovr 'ediff)) | 1219 ;; increasing |
1214 (null (ediff-overlay-get ovr 'ediff-diff-num))) | 1220 (null (ediff-overlay-get ovr 'ediff)) |
1215 ;; use the overlay priority or 0 | 1221 (null (ediff-overlay-get ovr 'ediff-diff-num))) |
1216 (or (ediff-overlay-get ovr 'priority) 0) | 1222 ;; use the overlay priority or 0 |
1217 0)) | 1223 (or (ediff-overlay-get ovr 'priority) 0) |
1218 ovr-list) | 1224 0)) |
1219 ) | 1225 ovr-list) |
1220 )) | 1226 ) |
1221 )))) | 1227 ))) |
1228 ) ; ediff-cond-compile-for-xemacs-or-emacs | |
1229 )) | |
1222 | 1230 |
1223 | 1231 |
1224 (defvar ediff-toggle-read-only-function nil | 1232 (defvar ediff-toggle-read-only-function nil |
1225 "*Specifies the function to be used to toggle read-only. | 1233 "*Specifies the function to be used to toggle read-only. |
1226 If nil, Ediff tries to deduce the function from the binding of C-x C-q. | 1234 If nil, Ediff tries to deduce the function from the binding of C-x C-q. |
1304 (ediff-defvar-local ediff-temp-file-B nil "") | 1312 (ediff-defvar-local ediff-temp-file-B nil "") |
1305 ;; Temporary file used for refining difference regions in buffer C. | 1313 ;; Temporary file used for refining difference regions in buffer C. |
1306 (ediff-defvar-local ediff-temp-file-C nil "") | 1314 (ediff-defvar-local ediff-temp-file-C nil "") |
1307 | 1315 |
1308 | 1316 |
1309 ;;; In-line functions | |
1310 | |
1311 ;; If file-remote-p is defined (as in XEmacs, use it. Otherwise, check | 1317 ;; If file-remote-p is defined (as in XEmacs, use it. Otherwise, check |
1312 ;; if find-file-name-handler is defined for 'file-local-copy | 1318 ;; if find-file-name-handler is defined for 'file-local-copy |
1313 (defun ediff-file-remote-p (file-name) | 1319 (defun ediff-file-remote-p (file-name) |
1314 (or (and (fboundp 'file-remote-p) (file-remote-p file-name)) | 1320 (or (and (fboundp 'file-remote-p) (file-remote-p file-name)) |
1315 (find-file-name-handler file-name 'file-local-copy))) | 1321 (find-file-name-handler file-name 'file-local-copy))) |
1373 (ediff-paint-background-regions-in-one-buffer | 1379 (ediff-paint-background-regions-in-one-buffer |
1374 'C unhighlight) | 1380 'C unhighlight) |
1375 (ediff-paint-background-regions-in-one-buffer | 1381 (ediff-paint-background-regions-in-one-buffer |
1376 'Ancestor unhighlight)) | 1382 'Ancestor unhighlight)) |
1377 | 1383 |
1378 (defun ediff-highlight-diff-in-one-buffer (n buf-type) | |
1379 (if (ediff-buffer-live-p (ediff-get-buffer buf-type)) | |
1380 (let* ((buff (ediff-get-buffer buf-type)) | |
1381 (last (ediff-with-current-buffer buff (point-max))) | |
1382 (begin (ediff-get-diff-posn buf-type 'beg n)) | |
1383 (end (ediff-get-diff-posn buf-type 'end n)) | |
1384 (xtra (if (equal begin end) 1 0)) | |
1385 (end-hilit (min last (+ end xtra))) | |
1386 (current-diff-overlay | |
1387 (symbol-value | |
1388 (ediff-get-symbol-from-alist | |
1389 buf-type ediff-current-diff-overlay-alist)))) | |
1390 | |
1391 (if ediff-xemacs-p | |
1392 (ediff-move-overlay current-diff-overlay begin end-hilit) | |
1393 (ediff-move-overlay current-diff-overlay begin end-hilit buff)) | |
1394 (ediff-overlay-put current-diff-overlay 'priority | |
1395 (ediff-highest-priority begin end-hilit buff)) | |
1396 (ediff-overlay-put current-diff-overlay 'ediff-diff-num n) | |
1397 | |
1398 ;; unhighlight the background overlay for diff n so it won't | |
1399 ;; interfere with the current diff overlay | |
1400 (ediff-set-overlay-face (ediff-get-diff-overlay n buf-type) nil) | |
1401 ))) | |
1402 | |
1403 | |
1404 (defun ediff-unhighlight-diff-in-one-buffer (buf-type) | |
1405 (if (ediff-buffer-live-p (ediff-get-buffer buf-type)) | |
1406 (let ((current-diff-overlay | |
1407 (symbol-value | |
1408 (ediff-get-symbol-from-alist | |
1409 buf-type ediff-current-diff-overlay-alist))) | |
1410 (overlay | |
1411 (ediff-get-diff-overlay ediff-current-difference buf-type)) | |
1412 ) | |
1413 | |
1414 (ediff-move-overlay current-diff-overlay 1 1) | |
1415 | |
1416 ;; rehighlight the overlay in the background of the | |
1417 ;; current difference region | |
1418 (ediff-set-overlay-face | |
1419 overlay | |
1420 (if (and (ediff-has-face-support-p) | |
1421 ediff-use-faces ediff-highlight-all-diffs) | |
1422 (ediff-background-face buf-type ediff-current-difference))) | |
1423 ))) | |
1424 | |
1425 (defun ediff-unhighlight-diffs-totally-in-one-buffer (buf-type) | |
1426 (ediff-unselect-and-select-difference -1) | |
1427 (if (and (ediff-has-face-support-p) ediff-use-faces) | |
1428 (let* ((inhibit-quit t) | |
1429 (current-diff-overlay-var | |
1430 (ediff-get-symbol-from-alist | |
1431 buf-type ediff-current-diff-overlay-alist)) | |
1432 (current-diff-overlay (symbol-value current-diff-overlay-var))) | |
1433 (ediff-paint-background-regions 'unhighlight) | |
1434 (if (ediff-overlayp current-diff-overlay) | |
1435 (ediff-delete-overlay current-diff-overlay)) | |
1436 (set current-diff-overlay-var nil) | |
1437 ))) | |
1438 | |
1439 | |
1440 (defsubst ediff-highlight-diff (n) | |
1441 "Put face on diff N. Invoked for X displays only." | |
1442 (ediff-highlight-diff-in-one-buffer n 'A) | |
1443 (ediff-highlight-diff-in-one-buffer n 'B) | |
1444 (ediff-highlight-diff-in-one-buffer n 'C) | |
1445 (ediff-highlight-diff-in-one-buffer n 'Ancestor) | |
1446 ) | |
1447 | |
1448 | |
1449 (defsubst ediff-unhighlight-diff () | |
1450 "Remove overlays from buffers A, B, and C." | |
1451 (ediff-unhighlight-diff-in-one-buffer 'A) | |
1452 (ediff-unhighlight-diff-in-one-buffer 'B) | |
1453 (ediff-unhighlight-diff-in-one-buffer 'C) | |
1454 (ediff-unhighlight-diff-in-one-buffer 'Ancestor) | |
1455 ) | |
1456 | |
1457 ;; delete highlighting overlays, restore faces to their original form | |
1458 (defsubst ediff-unhighlight-diffs-totally () | |
1459 (ediff-unhighlight-diffs-totally-in-one-buffer 'A) | |
1460 (ediff-unhighlight-diffs-totally-in-one-buffer 'B) | |
1461 (ediff-unhighlight-diffs-totally-in-one-buffer 'C) | |
1462 (ediff-unhighlight-diffs-totally-in-one-buffer 'Ancestor) | |
1463 ) | |
1464 | |
1465 | 1384 |
1466 ;; arg is a record for a given diff in a difference vector | 1385 ;; arg is a record for a given diff in a difference vector |
1467 ;; this record is itself a vector | 1386 ;; this record is itself a vector |
1468 (defsubst ediff-clear-fine-diff-vector (diff-record) | 1387 (defsubst ediff-clear-fine-diff-vector (diff-record) |
1469 (if diff-record | 1388 (if diff-record |
1479 (ediff-clear-fine-differences-in-one-buffer n 'B) | 1398 (ediff-clear-fine-differences-in-one-buffer n 'B) |
1480 (if ediff-3way-job | 1399 (if ediff-3way-job |
1481 (ediff-clear-fine-differences-in-one-buffer n 'C))) | 1400 (ediff-clear-fine-differences-in-one-buffer n 'C))) |
1482 | 1401 |
1483 | 1402 |
1484 (defsubst ediff-convert-fine-diffs-to-overlays (diff-list region-num) | |
1485 (ediff-set-fine-overlays-in-one-buffer 'A diff-list region-num) | |
1486 (ediff-set-fine-overlays-in-one-buffer 'B diff-list region-num) | |
1487 (if ediff-3way-job | |
1488 (ediff-set-fine-overlays-in-one-buffer 'C diff-list region-num) | |
1489 )) | |
1490 | |
1491 (defsubst ediff-mouse-event-p (event) | 1403 (defsubst ediff-mouse-event-p (event) |
1492 (if ediff-xemacs-p | 1404 (ediff-cond-compile-for-xemacs-or-emacs |
1493 (button-event-p event) | 1405 (button-event-p event) ; xemacs form |
1494 (string-match "mouse" (format "%S" (event-basic-type event))) | 1406 (string-match "mouse" (format "%S" (event-basic-type event))) ; emacs form |
1495 )) | 1407 )) |
1496 | 1408 |
1497 | 1409 |
1498 (defsubst ediff-key-press-event-p (event) | 1410 (defsubst ediff-key-press-event-p (event) |
1499 (if ediff-xemacs-p | 1411 (ediff-cond-compile-for-xemacs-or-emacs |
1500 (key-press-event-p event) | 1412 (key-press-event-p event) ; xemacs form |
1501 (or (char-or-string-p event) (symbolp event)))) | 1413 (or (char-or-string-p event) (symbolp event)) ; emacs form |
1414 )) | |
1502 | 1415 |
1503 (defun ediff-event-point (event) | 1416 (defun ediff-event-point (event) |
1504 (cond ((ediff-mouse-event-p event) | 1417 (cond ((ediff-mouse-event-p event) |
1505 (if ediff-xemacs-p | 1418 (ediff-cond-compile-for-xemacs-or-emacs |
1506 (event-point event) | 1419 (event-point event) ; xemacs form |
1507 (posn-point (event-start event)))) | 1420 (posn-point (event-start event)) ; emacs form |
1421 ) | |
1422 ) | |
1508 ((ediff-key-press-event-p event) | 1423 ((ediff-key-press-event-p event) |
1509 (point)) | 1424 (point)) |
1510 (t (error)))) | 1425 (t (error nil)))) |
1511 | 1426 |
1512 (defun ediff-event-buffer (event) | 1427 (defun ediff-event-buffer (event) |
1513 (cond ((ediff-mouse-event-p event) | 1428 (cond ((ediff-mouse-event-p event) |
1514 (if ediff-xemacs-p | 1429 (ediff-cond-compile-for-xemacs-or-emacs |
1515 (event-buffer event) | 1430 (event-buffer event) ; xemacs form |
1516 (window-buffer (posn-window (event-start event))))) | 1431 (window-buffer (posn-window (event-start event))) ; emacs form |
1432 ) | |
1433 ) | |
1517 ((ediff-key-press-event-p event) | 1434 ((ediff-key-press-event-p event) |
1518 (current-buffer)) | 1435 (current-buffer)) |
1519 (t (error)))) | 1436 (t (error nil)))) |
1437 | |
1438 (defun ediff-event-key (event-or-key) | |
1439 (ediff-cond-compile-for-xemacs-or-emacs | |
1440 (if (eventp event-or-key) (event-key event-or-key) event-or-key) ; xemacs | |
1441 event-or-key ; emacs form | |
1442 )) | |
1520 | 1443 |
1521 | 1444 |
1522 (defsubst ediff-frame-iconified-p (frame) | 1445 (defsubst ediff-frame-iconified-p (frame) |
1523 (if (and (ediff-window-display-p) (frame-live-p frame)) | 1446 (if (and (ediff-window-display-p) (frame-live-p frame)) |
1524 (if ediff-xemacs-p | 1447 (ediff-cond-compile-for-xemacs-or-emacs |
1525 (frame-iconified-p frame) | 1448 (frame-iconified-p frame) ; xemacs form |
1526 (eq (frame-visible-p frame) 'icon)))) | 1449 (eq (frame-visible-p frame) 'icon) ; emacs form |
1450 ) | |
1451 )) | |
1527 | 1452 |
1528 (defsubst ediff-window-visible-p (wind) | 1453 (defsubst ediff-window-visible-p (wind) |
1529 ;; under TTY, window-live-p also means window is visible | 1454 ;; under TTY, window-live-p also means window is visible |
1530 (and (window-live-p wind) | 1455 (and (window-live-p wind) |
1531 (or (not (ediff-window-display-p)) | 1456 (or (not (ediff-window-display-p)) |
1532 (frame-visible-p (window-frame wind))))) | 1457 (frame-visible-p (window-frame wind))))) |
1533 | 1458 |
1534 | 1459 |
1535 (defsubst ediff-frame-char-width (frame) | 1460 (defsubst ediff-frame-char-width (frame) |
1536 (if ediff-xemacs-p | 1461 (ediff-cond-compile-for-xemacs-or-emacs |
1537 (/ (frame-pixel-width frame) (frame-width frame)) | 1462 (/ (frame-pixel-width frame) (frame-width frame)) ; xemacs |
1538 (frame-char-width frame))) | 1463 (frame-char-width frame) ; emacs |
1464 )) | |
1539 | 1465 |
1540 (defun ediff-reset-mouse (&optional frame do-not-grab-mouse) | 1466 (defun ediff-reset-mouse (&optional frame do-not-grab-mouse) |
1541 (or frame (setq frame (selected-frame))) | 1467 (or frame (setq frame (selected-frame))) |
1542 (if (ediff-window-display-p) | 1468 (if (ediff-window-display-p) |
1543 (let ((frame-or-wind frame)) | 1469 (let ((frame-or-wind frame)) |
1578 (cdr (cdr (mouse-pixel-position))))) | 1504 (cdr (cdr (mouse-pixel-position))))) |
1579 ediff-mouse-pixel-threshold)))) | 1505 ediff-mouse-pixel-threshold)))) |
1580 (t nil)))) | 1506 (t nil)))) |
1581 | 1507 |
1582 (defsubst ediff-frame-char-height (frame) | 1508 (defsubst ediff-frame-char-height (frame) |
1583 (if ediff-xemacs-p | 1509 (ediff-cond-compile-for-xemacs-or-emacs |
1584 (glyph-height ediff-H-glyph (selected-window frame)) | 1510 (glyph-height ediff-H-glyph (selected-window frame)) ; xemacs cse |
1585 (frame-char-height frame))) | 1511 (frame-char-height frame) ; emacs case |
1512 ) | |
1513 ) | |
1586 | 1514 |
1587 ;; Some overlay functions | 1515 ;; Some overlay functions |
1588 | 1516 |
1589 (defsubst ediff-overlay-start (overl) | 1517 (defsubst ediff-overlay-start (overl) |
1590 (if (ediff-overlayp overl) | 1518 (if (ediff-overlayp overl) |
1591 (if ediff-emacs-p | 1519 (ediff-cond-compile-for-xemacs-or-emacs |
1592 (overlay-start overl) | 1520 (extent-start-position overl) ; xemacs form |
1593 (extent-start-position overl)))) | 1521 (overlay-start overl) ; emacs form |
1522 ) | |
1523 )) | |
1594 | 1524 |
1595 (defsubst ediff-overlay-end (overl) | 1525 (defsubst ediff-overlay-end (overl) |
1596 (if (ediff-overlayp overl) | 1526 (if (ediff-overlayp overl) |
1597 (if ediff-emacs-p | 1527 (ediff-cond-compile-for-xemacs-or-emacs |
1598 (overlay-end overl) | 1528 (extent-end-position overl) ; xemacs form |
1599 (extent-end-position overl)))) | 1529 (overlay-end overl) ; emacs form |
1530 ) | |
1531 )) | |
1600 | 1532 |
1601 (defsubst ediff-empty-overlay-p (overl) | 1533 (defsubst ediff-empty-overlay-p (overl) |
1602 (= (ediff-overlay-start overl) (ediff-overlay-end overl))) | 1534 (= (ediff-overlay-start overl) (ediff-overlay-end overl))) |
1603 | 1535 |
1604 ;; like overlay-buffer in Emacs. In XEmacs, returns nil if the extent is | 1536 ;; like overlay-buffer in Emacs. In XEmacs, returns nil if the extent is |
1605 ;; dead. Otherwise, works like extent-buffer | 1537 ;; dead. Otherwise, works like extent-buffer |
1606 (defun ediff-overlay-buffer (overl) | 1538 (defun ediff-overlay-buffer (overl) |
1607 (if ediff-emacs-p | 1539 (ediff-cond-compile-for-xemacs-or-emacs |
1608 (overlay-buffer overl) | 1540 (and (extent-live-p overl) (extent-object overl)) ; xemacs form |
1609 (and (extent-live-p overl) (extent-object overl)))) | 1541 (overlay-buffer overl) ; emacs form |
1542 )) | |
1610 | 1543 |
1611 ;; like overlay-get in Emacs. In XEmacs, returns nil if the extent is | 1544 ;; like overlay-get in Emacs. In XEmacs, returns nil if the extent is |
1612 ;; dead. Otherwise, like extent-property | 1545 ;; dead. Otherwise, like extent-property |
1613 (defun ediff-overlay-get (overl property) | 1546 (defun ediff-overlay-get (overl property) |
1614 (if ediff-emacs-p | 1547 (ediff-cond-compile-for-xemacs-or-emacs |
1615 (overlay-get overl property) | 1548 (and (extent-live-p overl) (extent-property overl property)) ; xemacs form |
1616 (and (extent-live-p overl) (extent-property overl property)))) | 1549 (overlay-get overl property) ; emacs form |
1550 )) | |
1617 | 1551 |
1618 | 1552 |
1619 ;; These two functions are here because XEmacs refuses to | 1553 ;; These two functions are here because XEmacs refuses to |
1620 ;; handle overlays whose buffers were deleted. | 1554 ;; handle overlays whose buffers were deleted. |
1621 (defun ediff-move-overlay (overlay beg end &optional buffer) | 1555 (defun ediff-move-overlay (overlay beg end &optional buffer) |
1622 "Calls `move-overlay' in Emacs and `set-extent-endpoints' in Lemacs. | 1556 "Calls `move-overlay' in Emacs and `set-extent-endpoints' in Lemacs. |
1623 Checks if overlay's buffer exists before actually doing the move." | 1557 Checks if overlay's buffer exists before actually doing the move." |
1624 (let ((buf (and overlay (ediff-overlay-buffer overlay)))) | 1558 (let ((buf (and overlay (ediff-overlay-buffer overlay)))) |
1625 (if (ediff-buffer-live-p buf) | 1559 (if (ediff-buffer-live-p buf) |
1626 (if ediff-xemacs-p | 1560 (ediff-cond-compile-for-xemacs-or-emacs |
1627 (set-extent-endpoints overlay beg end) | 1561 (set-extent-endpoints overlay beg end) ; xemacs form |
1628 (move-overlay overlay beg end buffer)) | 1562 (move-overlay overlay beg end buffer) ; emacs form |
1563 ) | |
1629 ;; buffer's dead | 1564 ;; buffer's dead |
1630 (if overlay | 1565 (if overlay |
1631 (ediff-delete-overlay overlay))))) | 1566 (ediff-delete-overlay overlay))))) |
1632 | 1567 |
1633 (defun ediff-overlay-put (overlay prop value) | 1568 (defun ediff-overlay-put (overlay prop value) |
1634 "Calls `overlay-put' or `set-extent-property' depending on Emacs version. | 1569 "Calls `overlay-put' or `set-extent-property' depending on Emacs version. |
1635 Checks if overlay's buffer exists." | 1570 Checks if overlay's buffer exists." |
1636 (if (ediff-buffer-live-p (ediff-overlay-buffer overlay)) | 1571 (if (ediff-buffer-live-p (ediff-overlay-buffer overlay)) |
1637 (if ediff-xemacs-p | 1572 (ediff-cond-compile-for-xemacs-or-emacs |
1638 (set-extent-property overlay prop value) | 1573 (set-extent-property overlay prop value) ; xemacs form |
1639 (overlay-put overlay prop value)) | 1574 (overlay-put overlay prop value) ; emacs form |
1575 ) | |
1640 (ediff-delete-overlay overlay))) | 1576 (ediff-delete-overlay overlay))) |
1641 | |
1642 ;; Some diff region tests | |
1643 | |
1644 ;; t if diff region is empty. | |
1645 ;; In case of buffer C, t also if it is not a 3way | |
1646 ;; comparison job (merging jobs return t as well). | |
1647 (defun ediff-empty-diff-region-p (n buf-type) | |
1648 (if (eq buf-type 'C) | |
1649 (or (not ediff-3way-comparison-job) | |
1650 (= (ediff-get-diff-posn 'C 'beg n) | |
1651 (ediff-get-diff-posn 'C 'end n))) | |
1652 (= (ediff-get-diff-posn buf-type 'beg n) | |
1653 (ediff-get-diff-posn buf-type 'end n)))) | |
1654 | |
1655 ;; Test if diff region is white space only. | |
1656 ;; If 2-way job and buf-type = C, then returns t. | |
1657 (defun ediff-whitespace-diff-region-p (n buf-type) | |
1658 (or (and (eq buf-type 'C) (not ediff-3way-job)) | |
1659 (ediff-empty-diff-region-p n buf-type) | |
1660 (let ((beg (ediff-get-diff-posn buf-type 'beg n)) | |
1661 (end (ediff-get-diff-posn buf-type 'end n))) | |
1662 (ediff-with-current-buffer (ediff-get-buffer buf-type) | |
1663 (save-excursion | |
1664 (goto-char beg) | |
1665 (skip-chars-forward ediff-whitespace) | |
1666 (>= (point) end)))))) | |
1667 | 1577 |
1668 ;; temporarily uses DIR to abbreviate file name | 1578 ;; temporarily uses DIR to abbreviate file name |
1669 ;; if DIR is nil, use default-directory | 1579 ;; if DIR is nil, use default-directory |
1670 (defun ediff-abbreviate-file-name (file &optional dir) | 1580 (defun ediff-abbreviate-file-name (file &optional dir) |
1671 (cond ((stringp dir) | 1581 (cond ((stringp dir) |
1672 (let ((directory-abbrev-alist (list (cons dir "")))) | 1582 (let ((directory-abbrev-alist (list (cons dir "")))) |
1673 (abbreviate-file-name file))) | 1583 (abbreviate-file-name file))) |
1674 (ediff-emacs-p (abbreviate-file-name file)) | 1584 (t |
1675 (t ; XEmacs requires addl argument | 1585 (ediff-cond-compile-for-xemacs-or-emacs |
1676 (abbreviate-file-name file t)))) | 1586 ;; XEmacs requires addl argument |
1587 (abbreviate-file-name file t) ; xemacs form | |
1588 (abbreviate-file-name file)) ; emacs form | |
1589 ) | |
1590 )) | |
1677 | 1591 |
1678 ;; Takes a directory and returns the parent directory. | 1592 ;; Takes a directory and returns the parent directory. |
1679 ;; does nothing to `/'. If the ARG is a regular file, | 1593 ;; does nothing to `/'. If the ARG is a regular file, |
1680 ;; strip the file AND the last dir. | 1594 ;; strip the file AND the last dir. |
1681 (defun ediff-strip-last-dir (dir) | 1595 (defun ediff-strip-last-dir (dir) |
1738 (capitalize | 1652 (capitalize |
1739 (subst-char-in-string ?- ?\ (substring (symbol-name jobname) 6)))) | 1653 (subst-char-in-string ?- ?\ (substring (symbol-name jobname) 6)))) |
1740 )) | 1654 )) |
1741 | 1655 |
1742 | 1656 |
1743 (defsubst ediff-get-region-contents (n buf-type ctrl-buf &optional start end) | |
1744 (ediff-with-current-buffer | |
1745 (ediff-with-current-buffer ctrl-buf (ediff-get-buffer buf-type)) | |
1746 (buffer-substring | |
1747 (or start (ediff-get-diff-posn buf-type 'beg n ctrl-buf)) | |
1748 (or end (ediff-get-diff-posn buf-type 'end n ctrl-buf))))) | |
1749 | |
1750 ;; If ediff modified mode line, strip the modification | 1657 ;; If ediff modified mode line, strip the modification |
1751 (defsubst ediff-strip-mode-line-format () | 1658 (defsubst ediff-strip-mode-line-format () |
1752 (if (member (car mode-line-format) '(" A: " " B: " " C: " " Ancestor: ")) | 1659 (if (member (car mode-line-format) '(" A: " " B: " " C: " " Ancestor: ")) |
1753 (setq mode-line-format (nth 2 mode-line-format)))) | 1660 (setq mode-line-format (nth 2 mode-line-format)))) |
1754 | 1661 |