Mercurial > hg > xemacs-beta
comparison lisp/ediff/ediff-util.el @ 12:bcdc7deadc19 r19-15b7
Import from CVS: tag r19-15b7
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:48:16 +0200 |
parents | ac2d302a0011 |
children | 9ee227acff29 |
comparison
equal
deleted
inserted
replaced
11:91ffe8bd52e4 | 12:bcdc7deadc19 |
---|---|
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
22 ;; Boston, MA 02111-1307, USA. | 22 ;; Boston, MA 02111-1307, USA. |
23 | 23 |
24 ;;; Code: | 24 ;;; Code: |
25 | 25 |
26 (require 'ediff-init) | |
27 (require 'ediff-mult) | |
28 | |
29 ;; Pacify compiler and avoid the need in checking for boundp | 26 ;; Pacify compiler and avoid the need in checking for boundp |
30 (defvar ediff-patch-diagnostics nil) | 27 (defvar ediff-patch-diagnostics nil) |
31 (defvar ediff-patchbufer nil) | 28 (defvar ediff-patchbufer nil) |
29 (and noninteractive | |
30 (eval-when-compile | |
31 (let ((load-path (cons (expand-file-name ".") load-path))) | |
32 (load-file "ediff-init.el") | |
33 (load-file "ediff-help.el")))) | |
32 ;; end pacifier | 34 ;; end pacifier |
35 | |
36 (require 'ediff-init) | |
37 (require 'ediff-help) | |
38 (require 'ediff-mult) | |
39 | |
40 ;;(if ediff-xemacs-p | |
41 ;; (require 'ediff-tbar) | |
42 ;; (defun ediff-use-toolbar-p () nil)) | |
43 ;; | |
44 ;; for the time being | |
45 (defun ediff-use-toolbar-p () nil) | |
33 | 46 |
34 | 47 |
35 ;;; Functions | 48 ;;; Functions |
36 | 49 |
37 (defun ediff-mode () | 50 (defun ediff-mode () |
98 (defun ediff-setup-keymap () | 111 (defun ediff-setup-keymap () |
99 "Set up the keymap used in the control buffer of Ediff." | 112 "Set up the keymap used in the control buffer of Ediff." |
100 (setq ediff-mode-map (make-sparse-keymap)) | 113 (setq ediff-mode-map (make-sparse-keymap)) |
101 (suppress-keymap ediff-mode-map) | 114 (suppress-keymap ediff-mode-map) |
102 | 115 |
116 (define-key ediff-mode-map | |
117 (if ediff-emacs-p [mouse-2] [button2]) 'ediff-help-for-quick-help) | |
118 (define-key ediff-mode-map "\C-m" 'ediff-help-for-quick-help) | |
119 | |
103 (define-key ediff-mode-map "p" 'ediff-previous-difference) | 120 (define-key ediff-mode-map "p" 'ediff-previous-difference) |
104 (define-key ediff-mode-map "\C-?" 'ediff-previous-difference) | 121 (define-key ediff-mode-map "\C-?" 'ediff-previous-difference) |
105 (define-key ediff-mode-map [backspace] 'ediff-previous-difference) | 122 (define-key ediff-mode-map [backspace] 'ediff-previous-difference) |
106 (define-key ediff-mode-map [delete] 'ediff-previous-difference) | 123 (define-key ediff-mode-map [delete] 'ediff-previous-difference) |
107 (define-key ediff-mode-map "\C-h" (if ediff-no-emacs-help-in-control-buffer | 124 (define-key ediff-mode-map "\C-h" (if ediff-no-emacs-help-in-control-buffer |
181 (define-key ediff-mode-map "B" 'ediff-toggle-read-only) | 198 (define-key ediff-mode-map "B" 'ediff-toggle-read-only) |
182 (define-key ediff-mode-map "w" nil) | 199 (define-key ediff-mode-map "w" nil) |
183 (define-key ediff-mode-map "wa" 'ediff-save-buffer) | 200 (define-key ediff-mode-map "wa" 'ediff-save-buffer) |
184 (define-key ediff-mode-map "wb" 'ediff-save-buffer) | 201 (define-key ediff-mode-map "wb" 'ediff-save-buffer) |
185 (define-key ediff-mode-map "wd" 'ediff-save-buffer) | 202 (define-key ediff-mode-map "wd" 'ediff-save-buffer) |
203 (define-key ediff-mode-map "=" 'ediff-inferior-compare-regions) | |
186 (if (fboundp 'ediff-show-patch-diagnostics) | 204 (if (fboundp 'ediff-show-patch-diagnostics) |
187 (define-key ediff-mode-map "P" 'ediff-show-patch-diagnostics)) | 205 (define-key ediff-mode-map "P" 'ediff-show-patch-diagnostics)) |
188 (if ediff-3way-job | 206 (if ediff-3way-job |
189 (progn | 207 (progn |
190 (define-key ediff-mode-map "wc" 'ediff-save-buffer) | 208 (define-key ediff-mode-map "wc" 'ediff-save-buffer) |
208 | 226 |
209 ;; Common startup entry for all Ediff functions | 227 ;; Common startup entry for all Ediff functions |
210 ;; It now returns control buffer so other functions can do post-processing | 228 ;; It now returns control buffer so other functions can do post-processing |
211 (defun ediff-setup (buffer-A file-A buffer-B file-B buffer-C file-C | 229 (defun ediff-setup (buffer-A file-A buffer-B file-B buffer-C file-C |
212 startup-hooks setup-parameters) | 230 startup-hooks setup-parameters) |
213 (setq file-A (expand-file-name file-A)) | 231 ;; ediff-convert-standard-filename puts file names in the form appropriate |
214 (setq file-B (expand-file-name file-B)) | 232 ;; for the OS at hand. |
233 (setq file-A (ediff-convert-standard-filename (expand-file-name file-A))) | |
234 (setq file-B (ediff-convert-standard-filename (expand-file-name file-B))) | |
215 (if (stringp file-C) | 235 (if (stringp file-C) |
216 (setq file-C (expand-file-name file-C))) | 236 (setq file-C |
237 (ediff-convert-standard-filename (expand-file-name file-C)))) | |
217 (let* ((control-buffer-name | 238 (let* ((control-buffer-name |
218 (ediff-unique-buffer-name "*Ediff Control Panel" "*")) | 239 (ediff-unique-buffer-name "*Ediff Control Panel" "*")) |
219 (control-buffer (ediff-eval-in-buffer buffer-A | 240 (control-buffer (ediff-eval-in-buffer buffer-A |
220 (get-buffer-create control-buffer-name)))) | 241 (get-buffer-create control-buffer-name)))) |
221 (ediff-eval-in-buffer control-buffer | 242 (ediff-eval-in-buffer control-buffer |
459 (ediff-set-help-message) | 480 (ediff-set-help-message) |
460 (insert ediff-help-message) | 481 (insert ediff-help-message) |
461 (shrink-window-if-larger-than-buffer) | 482 (shrink-window-if-larger-than-buffer) |
462 (or (ediff-multiframe-setup-p) | 483 (or (ediff-multiframe-setup-p) |
463 (ediff-indent-help-message)) | 484 (ediff-indent-help-message)) |
485 (ediff-set-help-overlays) | |
486 | |
464 (set-buffer-modified-p nil) | 487 (set-buffer-modified-p nil) |
465 (ediff-refresh-mode-lines) | 488 (ediff-refresh-mode-lines) |
466 (setq ediff-control-window (selected-window)) | 489 (setq ediff-control-window (selected-window)) |
467 (setq ediff-window-config-saved | 490 (setq ediff-window-config-saved |
468 (format "\%S\%S\%S\%S\%S\%S\%S" | 491 (format "%S%S%S%S%S%S%S" |
469 ediff-control-window | 492 ediff-control-window |
470 ediff-window-A | 493 ediff-window-A |
471 ediff-window-B | 494 ediff-window-B |
472 ediff-window-C | 495 ediff-window-C |
473 ediff-split-window-function | 496 ediff-split-window-function |
474 (ediff-multiframe-setup-p) | 497 (ediff-multiframe-setup-p) |
475 ediff-wide-display-p)) | 498 ediff-wide-display-p)) |
499 (if (not (ediff-multiframe-setup-p)) | |
500 (ediff-make-bottom-toolbar)) ; checks if toolbar is requested | |
476 (goto-char (point-min)) | 501 (goto-char (point-min)) |
477 (skip-chars-forward ediff-whitespace))) | 502 (skip-chars-forward ediff-whitespace))) |
478 | 503 |
479 ;; assuming we are in control window, calculate length of the first line in | |
480 ;; help message | |
481 (defun ediff-help-message-line-length () | |
482 (save-excursion | |
483 (goto-char (point-min)) | |
484 (if ediff-use-long-help-message | |
485 (next-line 1)) | |
486 (end-of-line) | |
487 (current-column))) | |
488 | |
489 | |
490 (defun ediff-indent-help-message () | |
491 (let* ((shift (/ (max 0 (- (window-width (selected-window)) | |
492 (ediff-help-message-line-length))) | |
493 2)) | |
494 (str (make-string shift ?\ ))) | |
495 (save-excursion | |
496 (goto-char (point-min)) | |
497 (while (< (point) (point-max)) | |
498 (insert str) | |
499 (beginning-of-line) | |
500 (forward-line 1))))) | |
501 | |
502 | |
503 (defun ediff-set-help-message () | |
504 (setq ediff-long-help-message | |
505 (cond ((and ediff-long-help-message-function | |
506 (or (symbolp ediff-long-help-message-function) | |
507 (consp ediff-long-help-message-function))) | |
508 (funcall ediff-long-help-message-function)) | |
509 (ediff-word-mode | |
510 (concat ediff-long-help-message-head | |
511 ediff-long-help-message-word-mode | |
512 ediff-long-help-message-tail)) | |
513 (ediff-narrow-job | |
514 (concat ediff-long-help-message-head | |
515 ediff-long-help-message-narrow2 | |
516 ediff-long-help-message-tail)) | |
517 (ediff-merge-job | |
518 (concat ediff-long-help-message-head | |
519 ediff-long-help-message-merge | |
520 ediff-long-help-message-tail)) | |
521 (ediff-diff3-job | |
522 (concat ediff-long-help-message-head | |
523 ediff-long-help-message-compare3 | |
524 ediff-long-help-message-tail)) | |
525 (t | |
526 (concat ediff-long-help-message-head | |
527 ediff-long-help-message-compare2 | |
528 ediff-long-help-message-tail)))) | |
529 (setq ediff-brief-help-message | |
530 (cond ((and ediff-brief-help-message-function | |
531 (or (symbolp ediff-brief-help-message-function) | |
532 (consp ediff-brief-help-message-function))) | |
533 (funcall ediff-brief-help-message-function)) | |
534 ((stringp ediff-brief-help-message-function) | |
535 ediff-brief-help-message-function) | |
536 ((ediff-multiframe-setup-p) ediff-brief-message-string) | |
537 (t ; long brief msg, not multiframe --- put in the middle | |
538 ediff-brief-message-string) | |
539 )) | |
540 (setq ediff-help-message (if ediff-use-long-help-message | |
541 ediff-long-help-message | |
542 ediff-brief-help-message)) | |
543 (run-hooks 'ediff-display-help-hook)) | |
544 | 504 |
545 | 505 |
546 | 506 |
547 ;;; Commands for working with Ediff | 507 ;;; Commands for working with Ediff |
548 | 508 |
768 ;; never grab mouse on quit in this place | 728 ;; never grab mouse on quit in this place |
769 (ediff-reset-mouse | 729 (ediff-reset-mouse |
770 control-frame | 730 control-frame |
771 (eq this-command 'ediff-quit)))) | 731 (eq this-command 'ediff-quit)))) |
772 )) | 732 )) |
773 (ediff-eval-in-buffer control-buf | 733 |
774 (ediff-refresh-mode-lines)) | 734 (ediff-restore-highlighting) |
735 (ediff-eval-in-buffer control-buf (ediff-refresh-mode-lines)) | |
775 )) | 736 )) |
776 | 737 |
777 ;; this function returns to the window it was called from | 738 ;; this function returns to the window it was called from |
778 ;; (which was the control window) | 739 ;; (which was the control window) |
779 (defun ediff-recenter-one-window (buf-type) | 740 (defun ediff-recenter-one-window (buf-type) |
879 (message "Re-highlighting all difference regions") | 840 (message "Re-highlighting all difference regions") |
880 (setq ediff-use-faces t | 841 (setq ediff-use-faces t |
881 ediff-highlight-all-diffs t))) | 842 ediff-highlight-all-diffs t))) |
882 | 843 |
883 (if (and ediff-use-faces ediff-highlight-all-diffs) | 844 (if (and ediff-use-faces ediff-highlight-all-diffs) |
884 (ediff-color-background-regions) | 845 (ediff-paint-background-regions) |
885 (ediff-color-background-regions 'unhighlight)) | 846 (ediff-paint-background-regions 'unhighlight)) |
886 | 847 |
887 (ediff-unselect-and-select-difference | 848 (ediff-unselect-and-select-difference |
888 ediff-current-difference 'select-only)) | 849 ediff-current-difference 'select-only)) |
889 ) | 850 ) |
851 | |
890 | 852 |
891 (defun ediff-toggle-autorefine () | 853 (defun ediff-toggle-autorefine () |
892 "Toggle auto-refine mode." | 854 "Toggle auto-refine mode." |
893 (interactive) | 855 (interactive) |
894 (ediff-barf-if-not-control-buffer) | 856 (ediff-barf-if-not-control-buffer) |
999 'buffer-read-only nil buf-type))) | 961 'buffer-read-only nil buf-type))) |
1000 (t | 962 (t |
1001 (setq toggle-ro-cmd 'toggle-read-only) | 963 (setq toggle-ro-cmd 'toggle-read-only) |
1002 (beep 1) (beep 1) | 964 (beep 1) (beep 1) |
1003 (message | 965 (message |
1004 "Boy, this is risky! Better don't change this file...") | 966 "Boy, this is risky! Don't modify this file...") |
1005 (sit-for 3)))) ; let the user see the warning | 967 (sit-for 3)))) ; let the user see the warning |
1006 (if (and toggle-ro-cmd | 968 (if (and toggle-ro-cmd |
1007 (string-match "toggle-read-only" (symbol-name toggle-ro-cmd))) | 969 (string-match "toggle-read-only" (symbol-name toggle-ro-cmd))) |
1008 (save-excursion | 970 (save-excursion |
1009 (save-window-excursion | 971 (save-window-excursion |
972 (select-window (ediff-get-visible-buffer-window buf)) | |
1010 (command-execute toggle-ro-cmd))) | 973 (command-execute toggle-ro-cmd))) |
1011 (error "Don't know how to toggle read-only in buffer %S" buf)) | 974 (error "Don't know how to toggle read-only in buffer %S" buf)) |
1012 | 975 |
1013 ;; Check if we made the current buffer updatable, but its file is RO. | 976 ;; Check if we made the current buffer updatable, but its file is RO. |
1014 ;; Signal a warning in this case. | 977 ;; Signal a warning in this case. |
1017 (file-exists-p file) | 980 (file-exists-p file) |
1018 (not (file-writable-p file))) | 981 (not (file-writable-p file))) |
1019 (message "Warning: file %s is read-only" | 982 (message "Warning: file %s is read-only" |
1020 (ediff-abbreviate-file-name file) (beep 1))) | 983 (ediff-abbreviate-file-name file) (beep 1))) |
1021 )))) | 984 )))) |
1022 | 985 |
1023 | 986 ;; checkout if visited file is checked in |
1024 ;; This is a simple-minded check for whether a file is under version control | 987 (defun ediff-maybe-checkout (buf) |
1025 ;; and is checked out. | 988 (let ((file (buffer-file-name buf)) |
989 (checkout-function (key-binding "\C-x\C-q"))) | |
990 (if (and (ediff-file-checked-in-p file) | |
991 (or (beep 1) t) | |
992 (y-or-n-p | |
993 (format | |
994 "File %s is under version control. Check it out? " | |
995 (ediff-abbreviate-file-name file)))) | |
996 (ediff-eval-in-buffer buf | |
997 (command-execute checkout-function))))) | |
998 | |
999 | |
1000 ;; This is a simple-minded check for whether a file is under version control. | |
1026 ;; If file,v exists but file doesn't, this file is considered to be not checked | 1001 ;; If file,v exists but file doesn't, this file is considered to be not checked |
1027 ;; in and not checked out for the purpose of patching (since patch won't be | 1002 ;; in and not checked out for the purpose of patching (since patch won't be |
1028 ;; able to read such a file anyway). | 1003 ;; able to read such a file anyway). |
1029 ;; FILE is a string representing file name | 1004 ;; FILE is a string representing file name |
1005 (defun ediff-file-under-version-control (file) | |
1006 (let* ((filedir (file-name-directory file)) | |
1007 (file-nondir (file-name-nondirectory file)) | |
1008 (trial (concat file-nondir ",v")) | |
1009 (full-trial (concat filedir trial)) | |
1010 (full-rcs-trial (concat filedir "RCS/" trial))) | |
1011 (and (stringp file) | |
1012 (file-exists-p file) | |
1013 (or | |
1014 (and | |
1015 (file-exists-p full-trial) | |
1016 ;; in FAT FS, `file,v' and `file' may turn out to be the same! | |
1017 ;; don't be fooled by this! | |
1018 (not (equal (file-attributes file) | |
1019 (file-attributes full-trial)))) | |
1020 ;; check if a version is in RCS/ directory | |
1021 (file-exists-p full-rcs-trial))) | |
1022 )) | |
1023 | |
1030 (defun ediff-file-checked-out-p (file) | 1024 (defun ediff-file-checked-out-p (file) |
1031 (and (stringp file) | 1025 (and (ediff-file-under-version-control file) |
1032 (file-exists-p file) | 1026 (file-writable-p file))) |
1033 (file-writable-p file) | |
1034 (or | |
1035 (file-exists-p (concat file ",v")) | |
1036 (file-exists-p (concat "RCS/" file ",v"))) | |
1037 )) | |
1038 (defun ediff-file-checked-in-p (file) | 1027 (defun ediff-file-checked-in-p (file) |
1039 (and (stringp file) | 1028 (and (ediff-file-under-version-control file) |
1040 (file-exists-p file) | 1029 (not (file-writable-p file)))) |
1041 (not (file-writable-p file)) | |
1042 (or | |
1043 (file-exists-p (concat file ",v")) | |
1044 (file-exists-p (concat "RCS/" file ",v"))) | |
1045 )) | |
1046 | 1030 |
1047 (defun ediff-swap-buffers () | 1031 (defun ediff-swap-buffers () |
1048 "Rotate the display of buffers A, B, and C." | 1032 "Rotate the display of buffers A, B, and C." |
1049 (interactive) | 1033 (interactive) |
1050 (ediff-barf-if-not-control-buffer) | 1034 (ediff-barf-if-not-control-buffer) |
1173 (funcall ediff-make-wide-display-function) | 1157 (funcall ediff-make-wide-display-function) |
1174 ;;(sit-for (if ediff-xemacs-p 0.4 0)) | 1158 ;;(sit-for (if ediff-xemacs-p 0.4 0)) |
1175 (ediff-eval-in-buffer ctl-buf | 1159 (ediff-eval-in-buffer ctl-buf |
1176 (setq ediff-window-B nil) ; force update of window config | 1160 (setq ediff-window-B nil) ; force update of window config |
1177 (ediff-recenter 'no-rehighlight))))) | 1161 (ediff-recenter 'no-rehighlight))))) |
1178 | 1162 |
1163 ;;;###autoload | |
1179 (defun ediff-toggle-multiframe () | 1164 (defun ediff-toggle-multiframe () |
1180 "Switch from the multiframe display to single-frame display and back. | 1165 "Switch from the multiframe display to single-frame display and back. |
1181 For a permanent change, set the variable `ediff-window-setup-function', | 1166 For a permanent change, set the variable `ediff-window-setup-function', |
1182 which see." | 1167 which see." |
1183 (interactive) | 1168 (interactive) |
1184 (ediff-barf-if-not-control-buffer) | 1169 (let (set-func) |
1185 (or (ediff-window-display-p) | 1170 (or (ediff-window-display-p) |
1186 (error "%sEmacs is not running as a window application" | 1171 (error "%sEmacs is not running as a window application" |
1187 (if ediff-emacs-p "" "X"))) | 1172 (if ediff-emacs-p "" "X"))) |
1173 | |
1174 (setq set-func (if (ediff-in-control-buffer-p) 'setq 'setq-default)) | |
1175 | |
1188 (cond ((eq ediff-window-setup-function 'ediff-setup-windows-multiframe) | 1176 (cond ((eq ediff-window-setup-function 'ediff-setup-windows-multiframe) |
1189 (setq ediff-window-setup-function 'ediff-setup-windows-plain)) | 1177 (eval |
1178 (list | |
1179 set-func | |
1180 'ediff-window-setup-function ''ediff-setup-windows-plain))) | |
1190 ((eq ediff-window-setup-function 'ediff-setup-windows-plain) | 1181 ((eq ediff-window-setup-function 'ediff-setup-windows-plain) |
1191 (setq ediff-window-setup-function 'ediff-setup-windows-multiframe))) | 1182 (if (ediff-in-control-buffer-p) |
1192 (setq ediff-window-B nil) | 1183 (ediff-kill-bottom-toolbar)) |
1193 (ediff-recenter 'no-rehighlight)) | 1184 (eval |
1185 (list | |
1186 set-func | |
1187 'ediff-window-setup-function ''ediff-setup-windows-multiframe)))) | |
1188 (if (ediff-in-control-buffer-p) | |
1189 (progn | |
1190 (setq ediff-window-B nil) | |
1191 (ediff-recenter 'no-rehighlight))))) | |
1192 | |
1193 ;; if was using toolbar, kill it | |
1194 (defun ediff-kill-bottom-toolbar () | |
1195 ;; Using ctl-buffer or ediff-control-window for LOCALE does not | |
1196 ;; work properly in XEmacs 19.14: we have to use | |
1197 ;;(selected-frame). | |
1198 ;; The problem with this is that any previous bottom-toolbar | |
1199 ;; will not re-appear after our cleanup here. Is there a way | |
1200 ;; to do "push" and "pop" toolbars ? --marcpa | |
1201 (if (ediff-use-toolbar-p) | |
1202 (progn | |
1203 (set-specifier bottom-toolbar (list (selected-frame) nil)) | |
1204 (set-specifier bottom-toolbar-visible-p (list (selected-frame) nil))))) | |
1205 | |
1206 ;; if wants to use toolbar, make it | |
1207 (defun ediff-make-bottom-toolbar () | |
1208 (if (ediff-use-toolbar-p) | |
1209 (progn | |
1210 (set-specifier bottom-toolbar (list (selected-frame) ediff-toolbar)) | |
1211 (set-specifier bottom-toolbar-visible-p (list (selected-frame) t)) | |
1212 (set-specifier bottom-toolbar-height (list (selected-frame) 34))))) | |
1194 | 1213 |
1195 ;; Merging | 1214 ;; Merging |
1196 | 1215 |
1197 (defun ediff-toggle-show-clashes-only () | 1216 (defun ediff-toggle-show-clashes-only () |
1198 "Toggle the mode where only the regions where both buffers differ with the ancestor are shown." | 1217 "Toggle the mode where only the regions where both buffers differ with the ancestor are shown." |
2186 ediff-wide-bounds) | 2205 ediff-wide-bounds) |
2187 (mapcar (function (lambda (overl) | 2206 (mapcar (function (lambda (overl) |
2188 (if (ediff-overlayp overl) | 2207 (if (ediff-overlayp overl) |
2189 (ediff-delete-overlay overl)))) | 2208 (ediff-delete-overlay overl)))) |
2190 ediff-narrow-bounds) | 2209 ediff-narrow-bounds) |
2191 | 2210 |
2192 ;; restore buffer mode line id's in buffer-A/B/C | 2211 ;; restore buffer mode line id's in buffer-A/B/C |
2193 (let ((control-buffer ediff-control-buffer) | 2212 (let ((control-buffer ediff-control-buffer) |
2194 (meta-buffer ediff-meta-buffer)) | 2213 (meta-buffer ediff-meta-buffer) |
2214 ;; suitable working frame | |
2215 (warp-frame (if (and (ediff-window-display-p) (eq ediff-grab-mouse t)) | |
2216 (cond ((window-live-p ediff-window-A) | |
2217 (window-frame ediff-window-A)) | |
2218 ((window-live-p ediff-window-B) | |
2219 (window-frame ediff-window-B)) | |
2220 (t (next-frame)))))) | |
2195 (condition-case nil | 2221 (condition-case nil |
2196 (ediff-eval-in-buffer ediff-buffer-A | 2222 (ediff-eval-in-buffer ediff-buffer-A |
2197 (setq ediff-this-buffer-ediff-sessions | 2223 (setq ediff-this-buffer-ediff-sessions |
2198 (delq control-buffer ediff-this-buffer-ediff-sessions)) | 2224 (delq control-buffer ediff-this-buffer-ediff-sessions)) |
2199 (kill-local-variable 'mode-line-buffer-identification) | 2225 (kill-local-variable 'mode-line-buffer-identification) |
2231 (setq ediff-session-registry | 2257 (setq ediff-session-registry |
2232 (delq ediff-control-buffer ediff-session-registry)) | 2258 (delq ediff-control-buffer ediff-session-registry)) |
2233 (ediff-update-registry) | 2259 (ediff-update-registry) |
2234 ;; restore state of buffers to what it was before ediff | 2260 ;; restore state of buffers to what it was before ediff |
2235 (ediff-restore-protected-variables) | 2261 (ediff-restore-protected-variables) |
2262 | |
2263 ;; If the user interrupts (canceling saving the merge buffer), continue | |
2264 ;; normally. | |
2265 (condition-case nil | |
2266 (if (ediff-merge-job) | |
2267 (run-hooks 'ediff-quit-merge-hook)) | |
2268 (quit)) | |
2269 | |
2236 ;; good place to kill buffers A/B/C | 2270 ;; good place to kill buffers A/B/C |
2237 (run-hooks 'ediff-cleanup-hook) | 2271 (run-hooks 'ediff-cleanup-hook) |
2238 (let ((ediff-keep-variants ediff-keep-variants)) | 2272 (let ((ediff-keep-variants ediff-keep-variants)) |
2239 (if reverse-default-keep-variants | 2273 (if reverse-default-keep-variants |
2240 (setq ediff-keep-variants (not ediff-keep-variants))) | 2274 (setq ediff-keep-variants (not ediff-keep-variants))) |
2241 (or ediff-keep-variants (ediff-janitor 'ask))) | 2275 (or ediff-keep-variants (ediff-janitor 'ask))) |
2242 | 2276 |
2243 (run-hooks 'ediff-quit-hook) | 2277 (run-hooks 'ediff-quit-hook) |
2244 (ediff-cleanup-meta-buffer meta-buffer) | 2278 (ediff-cleanup-meta-buffer meta-buffer) |
2279 | |
2280 ;; warp mouse into a working window | |
2281 (setq warp-frame ; if mouse is over a reasonable frame, use it | |
2282 (cond ((and ediff-xemacs-p (window-live-p (car (mouse-position)))) | |
2283 (window-frame (car (mouse-position)))) | |
2284 ((frame-live-p (car (mouse-position))) | |
2285 (car (mouse-position))) | |
2286 (t warp-frame))) | |
2287 (if (frame-live-p warp-frame) | |
2288 (set-mouse-position (if ediff-emacs-p | |
2289 warp-frame | |
2290 (frame-selected-window warp-frame)) | |
2291 2 1)) | |
2292 | |
2245 (if (ediff-buffer-live-p meta-buffer) | 2293 (if (ediff-buffer-live-p meta-buffer) |
2246 (ediff-show-meta-buffer meta-buffer)) | 2294 (ediff-show-meta-buffer meta-buffer)) |
2247 )) | 2295 )) |
2248 | 2296 |
2249 | 2297 |
2275 (ediff-kill-buffer-carefully ediff-msg-buffer) | 2323 (ediff-kill-buffer-carefully ediff-msg-buffer) |
2276 (ediff-kill-buffer-carefully ediff-debug-buffer) | 2324 (ediff-kill-buffer-carefully ediff-debug-buffer) |
2277 | 2325 |
2278 (if (and (ediff-window-display-p) (frame-live-p ctl-frame)) | 2326 (if (and (ediff-window-display-p) (frame-live-p ctl-frame)) |
2279 (delete-frame ctl-frame)) | 2327 (delete-frame ctl-frame)) |
2328 ;; Hide bottom toolbar. --marcpa | |
2329 (if (not (ediff-multiframe-setup-p)) | |
2330 (ediff-kill-bottom-toolbar)) | |
2331 | |
2280 (ediff-kill-buffer-carefully ctl-buf) | 2332 (ediff-kill-buffer-carefully ctl-buf) |
2281 | 2333 |
2282 (delete-other-windows) | 2334 (delete-other-windows) |
2283 | 2335 |
2284 ;; display only if not visible | 2336 ;; display only if not visible |
2288 (error)) | 2340 (error)) |
2289 (condition-case nil | 2341 (condition-case nil |
2290 (or (ediff-get-visible-buffer-window buff-A) | 2342 (or (ediff-get-visible-buffer-window buff-A) |
2291 (progn | 2343 (progn |
2292 (if (ediff-get-visible-buffer-window buff-B) | 2344 (if (ediff-get-visible-buffer-window buff-B) |
2293 (split-window-vertically)) | 2345 (funcall ediff-split-window-function)) |
2294 (switch-to-buffer buff-A))) | 2346 (switch-to-buffer buff-A))) |
2295 (error)) | 2347 (error)) |
2296 (if three-way-job | 2348 (if three-way-job |
2297 (condition-case nil | 2349 (condition-case nil |
2298 (or (ediff-get-visible-buffer-window buff-C) | 2350 (or (ediff-get-visible-buffer-window buff-C) |
2299 (progn | 2351 (progn |
2300 (if (or (ediff-get-visible-buffer-window buff-A) | 2352 (if (or (ediff-get-visible-buffer-window buff-A) |
2301 (ediff-get-visible-buffer-window buff-B)) | 2353 (ediff-get-visible-buffer-window buff-B)) |
2302 (split-window-vertically)) | 2354 (funcall ediff-split-window-function)) |
2303 (switch-to-buffer buff-C) | 2355 (switch-to-buffer buff-C) |
2304 (balance-windows))) | 2356 (balance-windows))) |
2305 (error))) | 2357 (error))) |
2306 (message "") | 2358 (message "") |
2307 )) | 2359 )) |
2334 (or (not (ediff-buffer-live-p ediff-buffer-C)) | 2386 (or (not (ediff-buffer-live-p ediff-buffer-C)) |
2335 (buffer-modified-p ediff-buffer-C) | 2387 (buffer-modified-p ediff-buffer-C) |
2336 (and ask (not (y-or-n-p (format "Kill buffer C [%s]? " | 2388 (and ask (not (y-or-n-p (format "Kill buffer C [%s]? " |
2337 (buffer-name ediff-buffer-C))))) | 2389 (buffer-name ediff-buffer-C))))) |
2338 (ediff-kill-buffer-carefully ediff-buffer-C)))) | 2390 (ediff-kill-buffer-carefully ediff-buffer-C)))) |
2391 | |
2392 (defun ediff-maybe-save-and-delete-merge () | |
2393 "Default hook to run on quitting a merge job. | |
2394 If `ediff-autostore-merges' is nil, this does nothing. | |
2395 If it is t, it saves the merge buffer in the file `ediff-merge-store-file' | |
2396 or asks the user, if the latter is nil. It then then asks the user whether to | |
2397 delete the merge buffer. | |
2398 If `ediff-autostore-merges' is neither nil nor t, the merge buffer is saved | |
2399 only if this merge job is part of a group, i.e., was invoked from within | |
2400 `ediff-merge-directories', `ediff-merge-directory-revisions', and such." | |
2401 (let ((merge-store-file ediff-merge-store-file)) | |
2402 (if ediff-autostore-merges | |
2403 (cond ((stringp ediff-merge-store-file) | |
2404 ;; store, ask to delete | |
2405 (ediff-write-merge-buffer-then-kill | |
2406 ediff-buffer-C merge-store-file 'show-file)) | |
2407 ((eq ediff-autostore-merges t) | |
2408 ;; ask for file name | |
2409 (setq merge-store-file | |
2410 (read-file-name "Save the result of the merge in: ")) | |
2411 (ediff-write-merge-buffer-then-kill | |
2412 ediff-buffer-C merge-store-file)) | |
2413 ((and (ediff-buffer-live-p ediff-meta-buffer) | |
2414 (ediff-eval-in-buffer ediff-meta-buffer | |
2415 (ediff-merge-metajob))) | |
2416 ;; This case shouldn't occur, as the parent metajob must pass on | |
2417 ;; a file name, ediff-merge-store-file, where to save the result | |
2418 ;; of the merge. | |
2419 ;; Ask where to save anyway--will decide what to do here later. | |
2420 (setq merge-store-file | |
2421 (read-file-name "The result of the merge goes into: ")) | |
2422 (ediff-write-merge-buffer-then-kill | |
2423 ediff-buffer-C merge-store-file)))) | |
2424 )) | |
2425 | |
2426 (defun ediff-write-merge-buffer-then-kill (buf file &optional show-file) | |
2427 (ediff-eval-in-buffer buf | |
2428 (if (or (not (file-exists-p file)) | |
2429 (y-or-n-p (format "File %s exists, overwrite? " file))) | |
2430 (progn | |
2431 (write-region (point-min) (point-max) file) | |
2432 (if show-file | |
2433 (progn | |
2434 (message "Merge buffer saved in: %s" file) | |
2435 (sit-for 2))) | |
2436 (if (y-or-n-p "Merge buffer saved in file. Now kill the buffer? ") | |
2437 (ediff-kill-buffer-carefully buf)))))) | |
2339 | 2438 |
2340 ;; The default way of suspending Ediff. | 2439 ;; The default way of suspending Ediff. |
2341 ;; Buries Ediff buffers, kills all windows. | 2440 ;; Buries Ediff buffers, kills all windows. |
2342 (defun ediff-default-suspend-function () | 2441 (defun ediff-default-suspend-function () |
2343 (let* ((buf-A ediff-buffer-A) | 2442 (let* ((buf-A ediff-buffer-A) |
2581 (or (eq flag 'unselect-only) | 2680 (or (eq flag 'unselect-only) |
2582 (ediff-select-difference n)) | 2681 (ediff-select-difference n)) |
2583 (setq ediff-current-difference n) | 2682 (setq ediff-current-difference n) |
2584 ) ; end protected section | 2683 ) ; end protected section |
2585 | 2684 |
2586 (ediff-eval-in-buffer control-buf | 2685 (ediff-eval-in-buffer control-buf (ediff-refresh-mode-lines)) |
2587 (ediff-refresh-mode-lines)) | |
2588 ))) | 2686 ))) |
2589 | 2687 |
2590 | 2688 |
2591 (defun ediff-read-file-name (prompt default-dir default-file) | 2689 (defun ediff-read-file-name (prompt default-dir default-file) |
2592 ; This is a modified version of a similar function in `emerge.el'. | 2690 ; This is a modified version of a similar function in `emerge.el'. |
2616 (read-file-name | 2714 (read-file-name |
2617 (format "%s%s " | 2715 (format "%s%s " |
2618 prompt | 2716 prompt |
2619 (cond (default-file | 2717 (cond (default-file |
2620 (concat " (default " default-file "):")) | 2718 (concat " (default " default-file "):")) |
2621 ;;((string-match "[?:!,;][ \t]*$" prompt) "") | |
2622 (t (concat " (default " default-dir "):")))) | 2719 (t (concat " (default " default-dir "):")))) |
2623 default-dir | 2720 default-dir |
2624 (or default-file default-dir) | 2721 (or default-file default-dir) |
2625 t ; must match, no-confirm | 2722 t ; must match, no-confirm |
2626 (if default-file (file-name-directory default-file)) | 2723 (if default-file (file-name-directory default-file)) |
2671 (if end end (point-max)) | 2768 (if end end (point-max)) |
2672 f | 2769 f |
2673 nil ; don't append---erase | 2770 nil ; don't append---erase |
2674 'no-message) | 2771 'no-message) |
2675 (set-file-modes f ediff-temp-file-mode) | 2772 (set-file-modes f ediff-temp-file-mode) |
2676 f))) | 2773 (ediff-convert-standard-filename (expand-file-name f))))) |
2677 | 2774 |
2678 ;; Quote metacharacters (using \) when executing diff in Unix, but not in | 2775 ;; Quote metacharacters (using \) when executing diff in Unix, but not in |
2679 ;; EMX OS/2 | 2776 ;; EMX OS/2 |
2680 ;;(defun ediff-protect-metachars (str) | 2777 ;;(defun ediff-protect-metachars (str) |
2681 ;; (or (memq system-type '(emx vax-vms axp-vms)) | 2778 ;; (or (memq system-type '(emx vax-vms axp-vms)) |
2794 (raise-frame (selected-frame))))) | 2891 (raise-frame (selected-frame))))) |
2795 (if (frame-live-p ediff-control-frame) | 2892 (if (frame-live-p ediff-control-frame) |
2796 (ediff-reset-mouse ediff-control-frame)) | 2893 (ediff-reset-mouse ediff-control-frame)) |
2797 (if (window-live-p ediff-control-window) | 2894 (if (window-live-p ediff-control-window) |
2798 (select-window ediff-control-window))) | 2895 (select-window ediff-control-window))) |
2799 | 2896 |
2800 | 2897 |
2801 | 2898 (defun ediff-inferior-compare-regions () |
2802 ;; will simplify it in due time, when emacs acquires before/after strings | 2899 "Compare regions in an active Ediff session. |
2900 Like ediff-regions-linewise but is called from under an active Ediff session on | |
2901 the files that belong to that session. | |
2902 | |
2903 After quitting the session invoked via this function, type C-l to the parent | |
2904 Ediff Control Panel to restore highlighting." | |
2905 (interactive) | |
2906 (let ((answer "") | |
2907 (possibilities (list ?A ?B ?C)) | |
2908 (zmacs-regions t) | |
2909 quit-now | |
2910 begA begB endA endB bufA bufB) | |
2911 | |
2912 (cond ((ediff-merge-job) | |
2913 (setq bufB ediff-buffer-C) | |
2914 (while (cond ((memq answer '(?A ?a)) | |
2915 (setq bufA ediff-buffer-A) | |
2916 nil) | |
2917 ((memq answer '(?B ?b)) | |
2918 (setq bufA ediff-buffer-B) | |
2919 nil) | |
2920 ((equal answer "")) | |
2921 (t (beep 1) | |
2922 (message "Valid values are A or B") | |
2923 (sit-for 2) | |
2924 t)) | |
2925 (let ((cursor-in-echo-area t)) | |
2926 (message "Which buffer to compare to the merge buffer (A/B)? ") | |
2927 (setq answer (read-char-exclusive))))) | |
2928 | |
2929 ((ediff-3way-comparison-job) | |
2930 (while (cond ((memq answer possibilities) | |
2931 (setq possibilities (delq answer possibilities)) | |
2932 (setq bufA | |
2933 (eval | |
2934 (intern (format "ediff-buffer-%c" answer)))) | |
2935 nil) | |
2936 ((equal answer "")) | |
2937 (t (beep 1) | |
2938 (message | |
2939 "Valid values are %s" | |
2940 (mapconcat 'char-to-string possibilities " or ")) | |
2941 (sit-for 2) | |
2942 t)) | |
2943 (let ((cursor-in-echo-area t)) | |
2944 (message "Enter the 1st buffer you want to compare (%s): " | |
2945 (mapconcat 'char-to-string possibilities "/")) | |
2946 (setq answer (capitalize (read-char-exclusive))))) | |
2947 (setq answer "") ; silence error msg | |
2948 (while (cond ((memq answer possibilities) | |
2949 (setq possibilities (delq answer possibilities)) | |
2950 (setq bufB | |
2951 (eval | |
2952 (intern (format "ediff-buffer-%c" answer)))) | |
2953 nil) | |
2954 ((equal answer "")) | |
2955 (t (beep 1) | |
2956 (message | |
2957 "Valid values are %s" | |
2958 (mapconcat 'char-to-string possibilities " or ")) | |
2959 (sit-for 2) | |
2960 t)) | |
2961 (let ((cursor-in-echo-area t)) | |
2962 (message "Enter the 2nd buffer you want to compare (%s): " | |
2963 (mapconcat 'char-to-string possibilities "/")) | |
2964 (setq answer (capitalize (read-char-exclusive)))))) | |
2965 (t ; 2way comparison | |
2966 (setq bufA ediff-buffer-A | |
2967 bufB ediff-buffer-B))) | |
2968 | |
2969 (ediff-eval-in-buffer bufA | |
2970 (or (mark t) | |
2971 (error "You forgot to specify a region in buffer %s" (buffer-name))) | |
2972 (setq begA (region-beginning) | |
2973 endA (region-end)) | |
2974 (goto-char begA) | |
2975 (beginning-of-line) | |
2976 (setq begA (point)) | |
2977 (goto-char endA) | |
2978 (end-of-line) | |
2979 (or (eobp) (forward-char)) ; include the newline char | |
2980 (setq endA (point))) | |
2981 (ediff-eval-in-buffer bufB | |
2982 (or (mark t) | |
2983 (error "You forgot to specify a region in buffer %s" (buffer-name))) | |
2984 (setq begB (region-beginning) | |
2985 endB (region-end)) | |
2986 (goto-char begB) | |
2987 (beginning-of-line) | |
2988 (setq begB (point)) | |
2989 (goto-char endB) | |
2990 (end-of-line) | |
2991 (or (eobp) (forward-char)) ; include the newline char | |
2992 (setq endB (point))) | |
2993 | |
2994 (ediff-unselect-and-select-difference | |
2995 ediff-current-difference 'unselect-only) | |
2996 (ediff-paint-background-regions 'unhighlight) | |
2997 | |
2998 (ediff-eval-in-buffer bufA | |
2999 (goto-char begA) | |
3000 (set-mark endA) | |
3001 (narrow-to-region begA endA) | |
3002 ;; (ediff-activate-mark) | |
3003 ) | |
3004 ;; (sit-for 0) | |
3005 (ediff-eval-in-buffer bufB | |
3006 (goto-char begB) | |
3007 (set-mark endB) | |
3008 (narrow-to-region begB endB) | |
3009 ;; (ediff-activate-mark) | |
3010 ) | |
3011 ;; (sit-for 0) | |
3012 | |
3013 (or (y-or-n-p | |
3014 "Please check the selected regions. Continue? ") | |
3015 (setq quit-now t)) | |
3016 | |
3017 (ediff-eval-in-buffer bufA | |
3018 (widen)) | |
3019 (ediff-eval-in-buffer bufB | |
3020 (widen)) | |
3021 (if quit-now | |
3022 (error "Thank you. Come back another day...")) | |
3023 | |
3024 (ediff-regions-internal | |
3025 bufA begA endA bufB begB endB | |
3026 nil ; startup hook | |
3027 'ediff-regions-linewise ; job name | |
3028 nil) ; no word mode | |
3029 )) | |
3030 | |
3031 | |
2803 (defun ediff-remove-flags-from-buffer (buffer overlay) | 3032 (defun ediff-remove-flags-from-buffer (buffer overlay) |
2804 (ediff-eval-in-buffer buffer | 3033 (ediff-eval-in-buffer buffer |
2805 (let ((inhibit-read-only t)) | 3034 (let ((inhibit-read-only t)) |
2806 (if ediff-xemacs-p | 3035 (if ediff-xemacs-p |
2807 (ediff-overlay-put overlay 'begin-glyph nil) | 3036 (ediff-overlay-put overlay 'begin-glyph nil) |
2808 ;; before-string is not yet implemented in emacs. | |
2809 ;; when it will be, I will be able to delete much of the rest of | |
2810 ;; this function | |
2811 (ediff-overlay-put overlay 'before-string nil)) | 3037 (ediff-overlay-put overlay 'before-string nil)) |
2812 | 3038 |
2813 (if ediff-xemacs-p | 3039 (if ediff-xemacs-p |
2814 (ediff-overlay-put overlay 'end-glyph nil) | 3040 (ediff-overlay-put overlay 'end-glyph nil) |
2815 ;; after-string is not yet implemented in emacs. | |
2816 (ediff-overlay-put overlay 'after-string nil)) | 3041 (ediff-overlay-put overlay 'after-string nil)) |
2817 ))) | 3042 ))) |
2818 | 3043 |
2819 | 3044 |
2820 | 3045 |
2821 ;; will simplify it in due time, when emacs acquires before/after strings | |
2822 (defun ediff-place-flags-in-buffer (buf-type buffer ctl-buffer diff) | 3046 (defun ediff-place-flags-in-buffer (buf-type buffer ctl-buffer diff) |
2823 (ediff-eval-in-buffer buffer | 3047 (ediff-eval-in-buffer buffer |
2824 (ediff-place-flags-in-buffer1 buf-type ctl-buffer diff))) | 3048 (ediff-place-flags-in-buffer1 buf-type ctl-buffer diff))) |
2825 | 3049 |
2826 | 3050 |
2891 (ediff-overlay-start diff-overlay) | 3115 (ediff-overlay-start diff-overlay) |
2892 (ediff-overlay-end diff-overlay)) | 3116 (ediff-overlay-end diff-overlay)) |
2893 )) | 3117 )) |
2894 | 3118 |
2895 | 3119 |
2896 | 3120 ;; Restore highlighting to what it should be according to ediff-use-faces, |
2897 (defun ediff-highlight-diff-in-one-buffer (n buf-type) | 3121 ;; ediff-highlighting-style, and ediff-highlight-all-diffs variables. |
2898 (if (ediff-buffer-live-p (ediff-get-buffer buf-type)) | 3122 (defun ediff-restore-highlighting (&optional ctl-buf) |
2899 (let* ((buff (ediff-get-buffer buf-type)) | 3123 (ediff-eval-in-buffer (or ctl-buf (current-buffer)) |
2900 (last (ediff-eval-in-buffer buff (point-max))) | 3124 (if (and (ediff-has-face-support-p) |
2901 (begin (ediff-get-diff-posn buf-type 'beg n)) | 3125 ediff-use-faces |
2902 (end (ediff-get-diff-posn buf-type 'end n)) | 3126 ediff-highlight-all-diffs) |
2903 (xtra (if (equal begin end) 1 0)) | 3127 (ediff-paint-background-regions)) |
2904 (end-hilit (min last (+ end xtra))) | 3128 (ediff-select-difference ediff-current-difference))) |
2905 (current-diff-overlay | 3129 |
2906 (symbol-value | |
2907 (intern (format "ediff-current-diff-overlay-%S" buf-type)))) | |
2908 ) | |
2909 | |
2910 (if ediff-xemacs-p | |
2911 (ediff-move-overlay current-diff-overlay begin end-hilit) | |
2912 (ediff-move-overlay current-diff-overlay begin end-hilit buff)) | |
2913 ;; giving priority of 0 and then changing it may look funny, but | |
2914 ;; this overcomes an obscure Emacs bug. | |
2915 (ediff-overlay-put current-diff-overlay 'priority 0) | |
2916 (ediff-overlay-put current-diff-overlay 'priority | |
2917 (ediff-highest-priority begin end-hilit buff)) | |
2918 (ediff-overlay-put current-diff-overlay 'ediff-diff-num n) | |
2919 | |
2920 ;; unhighlight the background overlay for diff n so it won't | |
2921 ;; interfere with the current diff overlay | |
2922 (ediff-set-overlay-face (ediff-get-diff-overlay n buf-type) nil) | |
2923 ))) | |
2924 | |
2925 | |
2926 (defun ediff-unhighlight-diff-in-one-buffer (buf-type) | |
2927 (if (ediff-buffer-live-p (ediff-get-buffer buf-type)) | |
2928 (let ((current-diff-overlay | |
2929 (symbol-value | |
2930 (intern (format "ediff-current-diff-overlay-%S" buf-type)))) | |
2931 (overlay | |
2932 (ediff-get-diff-overlay ediff-current-difference buf-type)) | |
2933 ) | |
2934 | |
2935 (ediff-move-overlay current-diff-overlay 1 1) | |
2936 | |
2937 ;; rehighlight the overlay in the background of the | |
2938 ;; current difference region | |
2939 (ediff-set-overlay-face | |
2940 overlay | |
2941 (if (and (ediff-has-face-support-p) | |
2942 ediff-use-faces ediff-highlight-all-diffs) | |
2943 (ediff-background-face buf-type ediff-current-difference))) | |
2944 ))) | |
2945 | |
2946 (defun ediff-unhighlight-diffs-totally-in-one-buffer (buf-type) | |
2947 (ediff-unselect-and-select-difference -1) | |
2948 (if (and (ediff-has-face-support-p) ediff-use-faces) | |
2949 (let* ((inhibit-quit t) | |
2950 (current-diff-overlay-var | |
2951 (intern (format "ediff-current-diff-overlay-%S" buf-type))) | |
2952 (current-diff-overlay (symbol-value current-diff-overlay-var))) | |
2953 (ediff-color-background-regions 'unhighlight) | |
2954 (if (ediff-overlayp current-diff-overlay) | |
2955 (ediff-delete-overlay current-diff-overlay)) | |
2956 (set current-diff-overlay-var nil) | |
2957 ))) | |
2958 | 3130 |
2959 | 3131 |
2960 ;; null out difference overlays so they won't slow down future | 3132 ;; null out difference overlays so they won't slow down future |
2961 ;; editing operations | 3133 ;; editing operations |
2962 ;; VEC is either a difference vector or a fine-diff vector | 3134 ;; VEC is either a difference vector or a fine-diff vector |
2971 )) | 3143 )) |
2972 (symbol-value vec-var))) | 3144 (symbol-value vec-var))) |
2973 ;; allow them to be garbage collected | 3145 ;; allow them to be garbage collected |
2974 (set vec-var nil)) | 3146 (set vec-var nil)) |
2975 | 3147 |
2976 (defun ediff-color-background-regions (&optional unhighlight) | |
2977 (ediff-color-background-regions-in-one-buffer | |
2978 'A unhighlight) | |
2979 (ediff-color-background-regions-in-one-buffer | |
2980 'B unhighlight) | |
2981 (ediff-color-background-regions-in-one-buffer | |
2982 'C unhighlight) | |
2983 (ediff-color-background-regions-in-one-buffer | |
2984 'Ancestor unhighlight)) | |
2985 | |
2986 (defun ediff-color-background-regions-in-one-buffer (buf-type unhighlight) | |
2987 (let ((diff-vector | |
2988 (eval (intern (format "ediff-difference-vector-%S" buf-type)))) | |
2989 overl diff-num) | |
2990 (mapcar (function | |
2991 (lambda (rec) | |
2992 (setq overl (ediff-get-diff-overlay-from-diff-record rec) | |
2993 diff-num (ediff-overlay-get overl 'ediff-diff-num)) | |
2994 (ediff-set-overlay-face | |
2995 overl | |
2996 (if (not unhighlight) | |
2997 (ediff-background-face buf-type diff-num)) | |
2998 ))) | |
2999 diff-vector))) | |
3000 | 3148 |
3001 | 3149 |
3002 ;;; Misc | 3150 ;;; Misc |
3003 | |
3004 ;; These two functions are here to neutralize XEmacs unwillingless to | |
3005 ;; handle overlays whose buffers were deleted. | |
3006 (defun ediff-move-overlay (overlay beg end &optional buffer) | |
3007 "Calls `move-overlay' in Emacs and `set-extent-endpoints' in Lemacs. | |
3008 Checks if overlay's buffer exists before actually doing the move." | |
3009 (let ((buf (and overlay (ediff-overlay-buffer overlay)))) | |
3010 (if (ediff-buffer-live-p buf) | |
3011 (if ediff-xemacs-p | |
3012 (set-extent-endpoints overlay beg end) | |
3013 (move-overlay overlay beg end buffer)) | |
3014 ;; buffer's dead | |
3015 (if overlay | |
3016 (ediff-delete-overlay overlay))))) | |
3017 | |
3018 (defun ediff-overlay-put (overlay prop value) | |
3019 "Calls `overlay-put' or `set-extent-property' depending on Emacs version. | |
3020 Checks if overlay's buffer exists." | |
3021 (if (ediff-buffer-live-p (ediff-overlay-buffer overlay)) | |
3022 (if ediff-xemacs-p | |
3023 (set-extent-property overlay prop value) | |
3024 (overlay-put overlay prop value)) | |
3025 (ediff-delete-overlay overlay))) | |
3026 | |
3027 | 3151 |
3028 ;; In Emacs, this just makes overlay. In the future, when Emacs will start | 3152 ;; In Emacs, this just makes overlay. In the future, when Emacs will start |
3029 ;; supporting sticky overlays, this function will make a sticky overlay. | 3153 ;; supporting sticky overlays, this function will make a sticky overlay. |
3030 ;; BEG and END are expressions telling where overlay starts. | 3154 ;; BEG and END are expressions telling where overlay starts. |
3031 ;; If they are numbers or buffers, then all is well. Otherwise, they must | 3155 ;; If they are numbers or buffers, then all is well. Otherwise, they must |
3233 | 3357 |
3234 (defun ediff-deactivate-mark () | 3358 (defun ediff-deactivate-mark () |
3235 (if ediff-xemacs-p | 3359 (if ediff-xemacs-p |
3236 (zmacs-deactivate-region) | 3360 (zmacs-deactivate-region) |
3237 (deactivate-mark))) | 3361 (deactivate-mark))) |
3362 (defun ediff-activate-mark () | |
3363 (if ediff-emacs-p | |
3364 (setq mark-active t) | |
3365 (zmacs-activate-region))) | |
3238 | 3366 |
3239 (cond ((fboundp 'nuke-selective-display) | 3367 (cond ((fboundp 'nuke-selective-display) |
3240 ;; XEmacs 19.12 has nuke-selective-display | 3368 ;; XEmacs 19.12 has nuke-selective-display |
3241 (fset 'ediff-nuke-selective-display 'nuke-selective-display)) | 3369 (fset 'ediff-nuke-selective-display 'nuke-selective-display)) |
3242 (t | 3370 (t |
3460 | 3588 |
3461 | 3589 |
3462 ;;; Local Variables: | 3590 ;;; Local Variables: |
3463 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) | 3591 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) |
3464 ;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) | 3592 ;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) |
3593 ;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body)) | |
3465 ;;; End: | 3594 ;;; End: |
3466 | 3595 |
3467 (provide 'ediff-util) | 3596 (provide 'ediff-util) |
3468 | 3597 |
3469 ;;; ediff-util.el ends here | 3598 ;;; ediff-util.el ends here |