Mercurial > emacs
comparison lisp/ediff-util.el @ 19047:f90d40b0bff5
new version
author | Michael Kifer <kifer@cs.stonybrook.edu> |
---|---|
date | Thu, 31 Jul 1997 04:04:23 +0000 |
parents | 47924b18d95c |
children | 1ecc4a79d048 |
comparison
equal
deleted
inserted
replaced
19046:689f3dc973f9 | 19047:f90d40b0bff5 |
---|---|
258 (if (stringp file-C) | 258 (if (stringp file-C) |
259 (setq file-C | 259 (setq file-C |
260 (ediff-convert-standard-filename (expand-file-name file-C)))) | 260 (ediff-convert-standard-filename (expand-file-name file-C)))) |
261 (let* ((control-buffer-name | 261 (let* ((control-buffer-name |
262 (ediff-unique-buffer-name "*Ediff Control Panel" "*")) | 262 (ediff-unique-buffer-name "*Ediff Control Panel" "*")) |
263 (control-buffer (ediff-eval-in-buffer buffer-A | 263 (control-buffer (ediff-with-current-buffer buffer-A |
264 (get-buffer-create control-buffer-name)))) | 264 (get-buffer-create control-buffer-name)))) |
265 (ediff-eval-in-buffer control-buffer | 265 (ediff-with-current-buffer control-buffer |
266 (ediff-mode) | 266 (ediff-mode) |
267 | 267 |
268 (make-local-variable 'ediff-use-long-help-message) | 268 (make-local-variable 'ediff-use-long-help-message) |
269 (make-local-variable 'ediff-prefer-iconified-control-frame) | 269 (make-local-variable 'ediff-prefer-iconified-control-frame) |
270 (make-local-variable 'ediff-split-window-function) | 270 (make-local-variable 'ediff-split-window-function) |
323 (get-buffer-create | 323 (get-buffer-create |
324 (ediff-unique-buffer-name "*ediff-merge" "*"))) | 324 (ediff-unique-buffer-name "*ediff-merge" "*"))) |
325 (save-excursion | 325 (save-excursion |
326 (set-buffer buffer-C) | 326 (set-buffer buffer-C) |
327 (insert-buffer buf) | 327 (insert-buffer buf) |
328 (funcall (ediff-eval-in-buffer buf major-mode)) | 328 (funcall (ediff-with-current-buffer buf major-mode)) |
329 ;; after Stig@hackvan.com | 329 ;; after Stig@hackvan.com |
330 (add-hook 'local-write-file-hooks 'ediff-set-merge-mode nil t) | 330 (add-hook 'local-write-file-hooks 'ediff-set-merge-mode nil t) |
331 ))) | 331 ))) |
332 (setq buffer-read-only nil | 332 (setq buffer-read-only nil |
333 ediff-buffer-A buffer-A | 333 ediff-buffer-A buffer-A |
352 0)))))) | 352 0)))))) |
353 | 353 |
354 (setq ediff-error-buffer | 354 (setq ediff-error-buffer |
355 (get-buffer-create (ediff-unique-buffer-name "*ediff-errors" "*"))) | 355 (get-buffer-create (ediff-unique-buffer-name "*ediff-errors" "*"))) |
356 | 356 |
357 (ediff-eval-in-buffer buffer-A (ediff-strip-mode-line-format)) | 357 (ediff-with-current-buffer buffer-A (ediff-strip-mode-line-format)) |
358 (ediff-eval-in-buffer buffer-B (ediff-strip-mode-line-format)) | 358 (ediff-with-current-buffer buffer-B (ediff-strip-mode-line-format)) |
359 (if ediff-3way-job | 359 (if ediff-3way-job |
360 (ediff-eval-in-buffer buffer-C (ediff-strip-mode-line-format))) | 360 (ediff-with-current-buffer buffer-C (ediff-strip-mode-line-format))) |
361 (if (ediff-buffer-live-p ediff-ancestor-buffer) | 361 (if (ediff-buffer-live-p ediff-ancestor-buffer) |
362 (ediff-eval-in-buffer ediff-ancestor-buffer | 362 (ediff-with-current-buffer ediff-ancestor-buffer |
363 (ediff-strip-mode-line-format))) | 363 (ediff-strip-mode-line-format))) |
364 | 364 |
365 (ediff-save-protected-variables) ; save variables to be restored on exit | 365 (ediff-save-protected-variables) ; save variables to be restored on exit |
366 | 366 |
367 ;; ediff-setup-diff-regions-function must be set after setup | 367 ;; ediff-setup-diff-regions-function must be set after setup |
390 | 390 |
391 ;; set up ediff-narrow-bounds, if not set | 391 ;; set up ediff-narrow-bounds, if not set |
392 (or ediff-narrow-bounds | 392 (or ediff-narrow-bounds |
393 (setq ediff-narrow-bounds ediff-wide-bounds)) | 393 (setq ediff-narrow-bounds ediff-wide-bounds)) |
394 | 394 |
395 ;; All these must be inside ediff-eval-in-buffer control-buffer, | 395 ;; All these must be inside ediff-with-current-buffer control-buffer, |
396 ;; since these vars are local to control-buffer | 396 ;; since these vars are local to control-buffer |
397 ;; These won't run if there are errors in diff | 397 ;; These won't run if there are errors in diff |
398 (ediff-eval-in-buffer ediff-buffer-A | 398 (ediff-with-current-buffer ediff-buffer-A |
399 (ediff-nuke-selective-display) | 399 (ediff-nuke-selective-display) |
400 (run-hooks 'ediff-prepare-buffer-hook) | 400 (run-hooks 'ediff-prepare-buffer-hook) |
401 (if (ediff-eval-in-buffer control-buffer ediff-merge-job) | 401 (if (ediff-with-current-buffer control-buffer ediff-merge-job) |
402 (setq buffer-read-only t)) | 402 (setq buffer-read-only t)) |
403 ;; add control-buffer to the list of sessions--no longer used, but may | 403 ;; add control-buffer to the list of sessions--no longer used, but may |
404 ;; be used again in the future | 404 ;; be used again in the future |
405 (or (memq control-buffer ediff-this-buffer-ediff-sessions) | 405 (or (memq control-buffer ediff-this-buffer-ediff-sessions) |
406 (setq ediff-this-buffer-ediff-sessions | 406 (setq ediff-this-buffer-ediff-sessions |
407 (cons control-buffer ediff-this-buffer-ediff-sessions))) | 407 (cons control-buffer ediff-this-buffer-ediff-sessions))) |
408 (if ediff-make-buffers-readonly-at-startup | 408 (if ediff-make-buffers-readonly-at-startup |
409 (setq buffer-read-only t)) | 409 (setq buffer-read-only t)) |
410 ) | 410 ) |
411 | 411 |
412 (ediff-eval-in-buffer ediff-buffer-B | 412 (ediff-with-current-buffer ediff-buffer-B |
413 (ediff-nuke-selective-display) | 413 (ediff-nuke-selective-display) |
414 (run-hooks 'ediff-prepare-buffer-hook) | 414 (run-hooks 'ediff-prepare-buffer-hook) |
415 (if (ediff-eval-in-buffer control-buffer ediff-merge-job) | 415 (if (ediff-with-current-buffer control-buffer ediff-merge-job) |
416 (setq buffer-read-only t)) | 416 (setq buffer-read-only t)) |
417 ;; add control-buffer to the list of sessions | 417 ;; add control-buffer to the list of sessions |
418 (or (memq control-buffer ediff-this-buffer-ediff-sessions) | 418 (or (memq control-buffer ediff-this-buffer-ediff-sessions) |
419 (setq ediff-this-buffer-ediff-sessions | 419 (setq ediff-this-buffer-ediff-sessions |
420 (cons control-buffer ediff-this-buffer-ediff-sessions))) | 420 (cons control-buffer ediff-this-buffer-ediff-sessions))) |
421 (if ediff-make-buffers-readonly-at-startup | 421 (if ediff-make-buffers-readonly-at-startup |
422 (setq buffer-read-only t)) | 422 (setq buffer-read-only t)) |
423 ) | 423 ) |
424 | 424 |
425 (if ediff-3way-job | 425 (if ediff-3way-job |
426 (ediff-eval-in-buffer ediff-buffer-C | 426 (ediff-with-current-buffer ediff-buffer-C |
427 (ediff-nuke-selective-display) | 427 (ediff-nuke-selective-display) |
428 (run-hooks 'ediff-prepare-buffer-hook) | 428 (run-hooks 'ediff-prepare-buffer-hook) |
429 ;; add control-buffer to the list of sessions | 429 ;; add control-buffer to the list of sessions |
430 (or (memq control-buffer ediff-this-buffer-ediff-sessions) | 430 (or (memq control-buffer ediff-this-buffer-ediff-sessions) |
431 (setq ediff-this-buffer-ediff-sessions | 431 (setq ediff-this-buffer-ediff-sessions |
434 (if ediff-make-buffers-readonly-at-startup | 434 (if ediff-make-buffers-readonly-at-startup |
435 (setq buffer-read-only t)) | 435 (setq buffer-read-only t)) |
436 )) | 436 )) |
437 | 437 |
438 (if (ediff-buffer-live-p ediff-ancestor-buffer) | 438 (if (ediff-buffer-live-p ediff-ancestor-buffer) |
439 (ediff-eval-in-buffer ediff-ancestor-buffer | 439 (ediff-with-current-buffer ediff-ancestor-buffer |
440 (ediff-nuke-selective-display) | 440 (ediff-nuke-selective-display) |
441 (setq buffer-read-only t) | 441 (setq buffer-read-only t) |
442 (run-hooks 'ediff-prepare-buffer-hook) | 442 (run-hooks 'ediff-prepare-buffer-hook) |
443 (or (memq control-buffer ediff-this-buffer-ediff-sessions) | 443 (or (memq control-buffer ediff-this-buffer-ediff-sessions) |
444 (setq ediff-this-buffer-ediff-sessions | 444 (setq ediff-this-buffer-ediff-sessions |
546 to these buffers are not saved at this point---the user can do this later, | 546 to these buffers are not saved at this point---the user can do this later, |
547 if necessary." | 547 if necessary." |
548 (interactive) | 548 (interactive) |
549 (ediff-barf-if-not-control-buffer) | 549 (ediff-barf-if-not-control-buffer) |
550 (if (and (ediff-buffer-live-p ediff-ancestor-buffer) | 550 (if (and (ediff-buffer-live-p ediff-ancestor-buffer) |
551 (not (y-or-n-p "Recompute differences during merge, really? "))) | 551 (not |
552 (error "Recomputation of differences cancelled")) | 552 (y-or-n-p |
553 "Ancestor buffer will not be used. Recompute diffs anyway? "))) | |
554 (error "Recomputation of differences canceled")) | |
553 | 555 |
554 (let ((point-A (ediff-eval-in-buffer ediff-buffer-A (point))) | 556 (let ((point-A (ediff-with-current-buffer ediff-buffer-A (point))) |
555 ;;(point-B (ediff-eval-in-buffer ediff-buffer-B (point))) | 557 ;;(point-B (ediff-with-current-buffer ediff-buffer-B (point))) |
556 (tmp-buffer (get-buffer-create ediff-tmp-buffer)) | 558 (tmp-buffer (get-buffer-create ediff-tmp-buffer)) |
557 (buf-A-file-name | 559 (buf-A-file-name (buffer-file-name ediff-buffer-A)) |
558 (file-name-nondirectory (or (buffer-file-name ediff-buffer-A) | 560 (buf-B-file-name (buffer-file-name ediff-buffer-B)) |
559 (buffer-name ediff-buffer-A) | 561 ;; (null ediff-buffer-C) is no problem, as we later check if |
560 ))) | 562 ;; ediff-buffer-C is alive |
561 (buf-B-file-name | 563 (buf-C-file-name (buffer-file-name ediff-buffer-C)) |
562 (file-name-nondirectory (or (buffer-file-name ediff-buffer-B) | |
563 (buffer-name ediff-buffer-B) | |
564 ))) | |
565 (buf-C-file-name | |
566 (file-name-nondirectory (or (buffer-file-name ediff-buffer-C) | |
567 ;; if (null ediff-buffer-C), there is | |
568 ;; no danger, since we later check if | |
569 ;; ediff-buffer-C is alive | |
570 (buffer-name ediff-buffer-C) | |
571 ))) | |
572 (overl-A (ediff-get-value-according-to-buffer-type | 564 (overl-A (ediff-get-value-according-to-buffer-type |
573 'A ediff-narrow-bounds)) | 565 'A ediff-narrow-bounds)) |
574 (overl-B (ediff-get-value-according-to-buffer-type | 566 (overl-B (ediff-get-value-according-to-buffer-type |
575 'B ediff-narrow-bounds)) | 567 'B ediff-narrow-bounds)) |
576 (overl-C (ediff-get-value-according-to-buffer-type | 568 (overl-C (ediff-get-value-according-to-buffer-type |
577 'C ediff-narrow-bounds)) | 569 'C ediff-narrow-bounds)) |
578 beg-A end-A beg-B end-B beg-C end-C | 570 beg-A end-A beg-B end-B beg-C end-C |
579 file-A file-B file-C) | 571 file-A file-B file-C) |
572 | |
573 (if (stringp buf-A-file-name) | |
574 (setq buf-A-file-name (file-name-nondirectory buf-A-file-name))) | |
575 (if (stringp buf-B-file-name) | |
576 (setq buf-B-file-name (file-name-nondirectory buf-B-file-name))) | |
577 (if (stringp buf-C-file-name) | |
578 (setq buf-C-file-name (file-name-nondirectory buf-C-file-name))) | |
579 | |
580 (ediff-unselect-and-select-difference -1) | 580 (ediff-unselect-and-select-difference -1) |
581 | 581 |
582 (setq beg-A (ediff-overlay-start overl-A) | 582 (setq beg-A (ediff-overlay-start overl-A) |
583 beg-B (ediff-overlay-start overl-B) | 583 beg-B (ediff-overlay-start overl-B) |
584 beg-C (ediff-overlay-start overl-C) | 584 beg-C (ediff-overlay-start overl-C) |
657 (keep-variants ediff-keep-variants) | 657 (keep-variants ediff-keep-variants) |
658 (ancestor-buf ediff-ancestor-buffer) | 658 (ancestor-buf ediff-ancestor-buffer) |
659 (ancestor-job ediff-merge-with-ancestor-job) | 659 (ancestor-job ediff-merge-with-ancestor-job) |
660 (merge ediff-merge-job) | 660 (merge ediff-merge-job) |
661 (comparison ediff-3way-comparison-job)) | 661 (comparison ediff-3way-comparison-job)) |
662 (ediff-eval-in-buffer bufA | 662 (ediff-with-current-buffer bufA |
663 (revert-buffer t noconfirm)) | 663 (revert-buffer t noconfirm)) |
664 (ediff-eval-in-buffer bufB | 664 (ediff-with-current-buffer bufB |
665 (revert-buffer t noconfirm)) | 665 (revert-buffer t noconfirm)) |
666 ;; this should only be executed in a 3way comparison, not in merge | 666 ;; this should only be executed in a 3way comparison, not in merge |
667 (if comparison | 667 (if comparison |
668 (ediff-eval-in-buffer bufC | 668 (ediff-with-current-buffer bufC |
669 (revert-buffer t noconfirm))) | 669 (revert-buffer t noconfirm))) |
670 (if merge | 670 (if merge |
671 (progn | 671 (progn |
672 (set-buffer ctl-buf) | 672 (set-buffer ctl-buf) |
673 ;; the argument says whether to reverse the meaning of | 673 ;; the argument says whether to reverse the meaning of |
751 (ediff-recenter-one-window 'A) | 751 (ediff-recenter-one-window 'A) |
752 (ediff-recenter-one-window 'B) | 752 (ediff-recenter-one-window 'B) |
753 (if ediff-3way-job | 753 (if ediff-3way-job |
754 (ediff-recenter-one-window 'C)) | 754 (ediff-recenter-one-window 'C)) |
755 | 755 |
756 (ediff-eval-in-buffer control-buf | 756 (ediff-with-current-buffer control-buf |
757 (ediff-recenter-ancestor) ; check if ancestor is alive | 757 (ediff-recenter-ancestor) ; check if ancestor is alive |
758 | 758 |
759 (if (and (ediff-multiframe-setup-p) | 759 (if (and (ediff-multiframe-setup-p) |
760 (not ediff-use-long-help-message) | 760 (not ediff-use-long-help-message) |
761 (not (ediff-frame-iconified-p ediff-control-frame))) | 761 (not (ediff-frame-iconified-p ediff-control-frame))) |
764 control-frame | 764 control-frame |
765 (eq this-command 'ediff-quit)))) | 765 (eq this-command 'ediff-quit)))) |
766 )) | 766 )) |
767 | 767 |
768 (ediff-restore-highlighting) | 768 (ediff-restore-highlighting) |
769 (ediff-eval-in-buffer control-buf (ediff-refresh-mode-lines)) | 769 (ediff-with-current-buffer control-buf (ediff-refresh-mode-lines)) |
770 )) | 770 )) |
771 | 771 |
772 ;; this function returns to the window it was called from | 772 ;; this function returns to the window it was called from |
773 ;; (which was the control window) | 773 ;; (which was the control window) |
774 (defun ediff-recenter-one-window (buf-type) | 774 (defun ediff-recenter-one-window (buf-type) |
778 (shift (ediff-overlay-start | 778 (shift (ediff-overlay-start |
779 (ediff-get-value-according-to-buffer-type | 779 (ediff-get-value-according-to-buffer-type |
780 buf-type ediff-narrow-bounds))) | 780 buf-type ediff-narrow-bounds))) |
781 (job-name ediff-job-name) | 781 (job-name ediff-job-name) |
782 (control-buf ediff-control-buffer) | 782 (control-buf ediff-control-buffer) |
783 (window-name (intern (format "ediff-window-%S" buf-type))) | 783 (window-name (ediff-get-symbol-from-alist |
784 buf-type ediff-window-alist)) | |
784 (window (if (window-live-p (symbol-value window-name)) | 785 (window (if (window-live-p (symbol-value window-name)) |
785 (symbol-value window-name)))) | 786 (symbol-value window-name)))) |
786 | 787 |
787 (if (and window ediff-windows-job) | 788 (if (and window ediff-windows-job) |
788 (set-window-start window shift)) | 789 (set-window-start window shift)) |
806 (ediff-valid-difference-p)) | 807 (ediff-valid-difference-p)) |
807 (let ((window (ediff-get-visible-buffer-window ediff-ancestor-buffer)) | 808 (let ((window (ediff-get-visible-buffer-window ediff-ancestor-buffer)) |
808 (ctl-wind (selected-window)) | 809 (ctl-wind (selected-window)) |
809 (job-name ediff-job-name) | 810 (job-name ediff-job-name) |
810 (ctl-buf ediff-control-buffer)) | 811 (ctl-buf ediff-control-buffer)) |
811 (ediff-eval-in-buffer ediff-ancestor-buffer | 812 (ediff-with-current-buffer ediff-ancestor-buffer |
812 (goto-char (ediff-get-diff-posn 'Ancestor 'beg nil ctl-buf)) | 813 (goto-char (ediff-get-diff-posn 'Ancestor 'beg nil ctl-buf)) |
813 (if window | 814 (if window |
814 (progn | 815 (progn |
815 (select-window window) | 816 (select-window window) |
816 (ediff-position-region | 817 (ediff-position-region |
958 (buf-type (ediff-char-to-buftype last-command-char))) | 959 (buf-type (ediff-char-to-buftype last-command-char))) |
959 (or buf (ediff-recenter)) | 960 (or buf (ediff-recenter)) |
960 (or buf | 961 (or buf |
961 (setq buf (ediff-get-buffer buf-type))) | 962 (setq buf (ediff-get-buffer buf-type))) |
962 | 963 |
963 (ediff-eval-in-buffer buf ; eval in buf A/B/C | 964 (ediff-with-current-buffer buf ; eval in buf A/B/C |
964 (let* ((file (buffer-file-name buf)) | 965 (let* ((file (buffer-file-name buf)) |
965 (file-writable (and file | 966 (file-writable (and file |
966 (file-exists-p file) | 967 (file-exists-p file) |
967 (file-writable-p file))) | 968 (file-writable-p file))) |
968 (toggle-ro-cmd (cond (ediff-toggle-read-only-function) | 969 (toggle-ro-cmd (cond (ediff-toggle-read-only-function) |
988 ;; if we checked the file out, we should also change the | 989 ;; if we checked the file out, we should also change the |
989 ;; original state of buffer-read-only to nil. If we don't | 990 ;; original state of buffer-read-only to nil. If we don't |
990 ;; do this, the mode line will show %%, since the file was | 991 ;; do this, the mode line will show %%, since the file was |
991 ;; RO before ediff started, so the user will think the file | 992 ;; RO before ediff started, so the user will think the file |
992 ;; is checked in. | 993 ;; is checked in. |
993 (ediff-eval-in-buffer ctl-buf | 994 (ediff-with-current-buffer ctl-buf |
994 (ediff-change-saved-variable | 995 (ediff-change-saved-variable |
995 'buffer-read-only nil buf-type))) | 996 'buffer-read-only nil buf-type))) |
996 (t | 997 (t |
997 (setq toggle-ro-cmd 'toggle-read-only) | 998 (setq toggle-ro-cmd 'toggle-read-only) |
998 (beep 1) (beep 1) | 999 (beep 1) (beep 1) |
1025 (or (beep 1) t) | 1026 (or (beep 1) t) |
1026 (y-or-n-p | 1027 (y-or-n-p |
1027 (format | 1028 (format |
1028 "File %s is under version control. Check it out? " | 1029 "File %s is under version control. Check it out? " |
1029 (ediff-abbreviate-file-name file)))) | 1030 (ediff-abbreviate-file-name file)))) |
1030 (ediff-eval-in-buffer buf | 1031 (ediff-with-current-buffer buf |
1031 (command-execute checkout-function))))) | 1032 (command-execute checkout-function))))) |
1032 | 1033 |
1033 | 1034 |
1034 ;; This is a simple-minded check for whether a file is under version control. | 1035 ;; This is a simple-minded check for whether a file is under version control. |
1035 ;; If file,v exists but file doesn't, this file is considered to be not checked | 1036 ;; If file,v exists but file doesn't, this file is considered to be not checked |
1176 (if ediff-emacs-p "" "X"))) | 1177 (if ediff-emacs-p "" "X"))) |
1177 (ediff-recenter 'no-rehighlight) ; make sure buffs are displayed in windows | 1178 (ediff-recenter 'no-rehighlight) ; make sure buffs are displayed in windows |
1178 (let ((ctl-buf ediff-control-buffer)) | 1179 (let ((ctl-buf ediff-control-buffer)) |
1179 (setq ediff-wide-display-p (not ediff-wide-display-p)) | 1180 (setq ediff-wide-display-p (not ediff-wide-display-p)) |
1180 (if (not ediff-wide-display-p) | 1181 (if (not ediff-wide-display-p) |
1181 (ediff-eval-in-buffer ctl-buf | 1182 (ediff-with-current-buffer ctl-buf |
1182 (modify-frame-parameters | 1183 (modify-frame-parameters |
1183 ediff-wide-display-frame ediff-wide-display-orig-parameters) | 1184 ediff-wide-display-frame ediff-wide-display-orig-parameters) |
1184 ;;(sit-for (if ediff-xemacs-p 0.4 0)) | 1185 ;;(sit-for (if ediff-xemacs-p 0.4 0)) |
1185 ;; restore control buf, since ctl window may have been deleted | 1186 ;; restore control buf, since ctl window may have been deleted |
1186 ;; during resizing | 1187 ;; during resizing |
1188 (setq ediff-wide-display-orig-parameters nil | 1189 (setq ediff-wide-display-orig-parameters nil |
1189 ediff-window-B nil) ; force update of window config | 1190 ediff-window-B nil) ; force update of window config |
1190 (ediff-recenter 'no-rehighlight)) | 1191 (ediff-recenter 'no-rehighlight)) |
1191 (funcall ediff-make-wide-display-function) | 1192 (funcall ediff-make-wide-display-function) |
1192 ;;(sit-for (if ediff-xemacs-p 0.4 0)) | 1193 ;;(sit-for (if ediff-xemacs-p 0.4 0)) |
1193 (ediff-eval-in-buffer ctl-buf | 1194 (ediff-with-current-buffer ctl-buf |
1194 (setq ediff-window-B nil) ; force update of window config | 1195 (setq ediff-window-B nil) ; force update of window config |
1195 (ediff-recenter 'no-rehighlight))))) | 1196 (ediff-recenter 'no-rehighlight))))) |
1196 | 1197 |
1197 ;;;###autoload | 1198 ;;;###autoload |
1198 (defun ediff-toggle-multiframe () | 1199 (defun ediff-toggle-multiframe () |
1214 | 1215 |
1215 ;; change default | 1216 ;; change default |
1216 (setq-default ediff-window-setup-function window-setup-func) | 1217 (setq-default ediff-window-setup-function window-setup-func) |
1217 ;; change in all active ediff sessions | 1218 ;; change in all active ediff sessions |
1218 (mapcar (function (lambda(buf) | 1219 (mapcar (function (lambda(buf) |
1219 (ediff-eval-in-buffer buf | 1220 (ediff-with-current-buffer buf |
1220 (setq ediff-window-setup-function window-setup-func | 1221 (setq ediff-window-setup-function window-setup-func |
1221 ediff-window-B nil)))) | 1222 ediff-window-B nil)))) |
1222 ediff-session-registry) | 1223 ediff-session-registry) |
1223 (if (ediff-in-control-buffer-p) | 1224 (if (ediff-in-control-buffer-p) |
1224 (ediff-recenter 'no-rehighlight)))) | 1225 (ediff-recenter 'no-rehighlight)))) |
1239 (ediff-kill-bottom-toolbar)) | 1240 (ediff-kill-bottom-toolbar)) |
1240 ;; do this only after killing the toolbar | 1241 ;; do this only after killing the toolbar |
1241 (setq ediff-use-toolbar-p (not ediff-use-toolbar-p)) | 1242 (setq ediff-use-toolbar-p (not ediff-use-toolbar-p)) |
1242 | 1243 |
1243 (mapcar (function (lambda(buf) | 1244 (mapcar (function (lambda(buf) |
1244 (ediff-eval-in-buffer buf | 1245 (ediff-with-current-buffer buf |
1245 ;; force redisplay | 1246 ;; force redisplay |
1246 (setq ediff-window-config-saved "") | 1247 (setq ediff-window-config-saved "") |
1247 ))) | 1248 ))) |
1248 ediff-session-registry) | 1249 ediff-session-registry) |
1249 (if (ediff-in-control-buffer-p) | 1250 (if (ediff-in-control-buffer-p) |
1329 (overl-B (ediff-get-value-according-to-buffer-type | 1330 (overl-B (ediff-get-value-according-to-buffer-type |
1330 'B ediff-visible-bounds)) | 1331 'B ediff-visible-bounds)) |
1331 (overl-C (ediff-get-value-according-to-buffer-type | 1332 (overl-C (ediff-get-value-according-to-buffer-type |
1332 'C ediff-visible-bounds)) | 1333 'C ediff-visible-bounds)) |
1333 ) | 1334 ) |
1334 (ediff-eval-in-buffer ediff-buffer-A | 1335 (ediff-with-current-buffer ediff-buffer-A |
1335 (narrow-to-region | 1336 (narrow-to-region |
1336 (ediff-overlay-start overl-A) (ediff-overlay-end overl-A))) | 1337 (ediff-overlay-start overl-A) (ediff-overlay-end overl-A))) |
1337 (ediff-eval-in-buffer ediff-buffer-B | 1338 (ediff-with-current-buffer ediff-buffer-B |
1338 (narrow-to-region | 1339 (narrow-to-region |
1339 (ediff-overlay-start overl-B) (ediff-overlay-end overl-B))) | 1340 (ediff-overlay-start overl-B) (ediff-overlay-end overl-B))) |
1340 | 1341 |
1341 (if ediff-3way-job | 1342 (if ediff-3way-job |
1342 (ediff-eval-in-buffer ediff-buffer-C | 1343 (ediff-with-current-buffer ediff-buffer-C |
1343 (narrow-to-region | 1344 (narrow-to-region |
1344 (ediff-overlay-start overl-C) (ediff-overlay-end overl-C)))) | 1345 (ediff-overlay-start overl-C) (ediff-overlay-end overl-C)))) |
1345 ))) | 1346 ))) |
1346 | 1347 |
1347 | 1348 |
1520 | 1521 |
1521 ;; get number of lines from window start to region end | 1522 ;; get number of lines from window start to region end |
1522 (defun ediff-get-lines-to-region-end (buf-type &optional n ctl-buf) | 1523 (defun ediff-get-lines-to-region-end (buf-type &optional n ctl-buf) |
1523 (or n (setq n ediff-current-difference)) | 1524 (or n (setq n ediff-current-difference)) |
1524 (or ctl-buf (setq ctl-buf ediff-control-buffer)) | 1525 (or ctl-buf (setq ctl-buf ediff-control-buffer)) |
1525 (ediff-eval-in-buffer ctl-buf | 1526 (ediff-with-current-buffer ctl-buf |
1526 (let* ((buf (ediff-get-buffer buf-type)) | 1527 (let* ((buf (ediff-get-buffer buf-type)) |
1527 (wind (eval (intern (format "ediff-window-%S" buf-type)))) | 1528 (wind (eval (ediff-get-symbol-from-alist |
1529 buf-type ediff-window-alist))) | |
1528 (beg (window-start wind)) | 1530 (beg (window-start wind)) |
1529 (end (ediff-get-diff-posn buf-type 'end)) | 1531 (end (ediff-get-diff-posn buf-type 'end)) |
1530 lines) | 1532 lines) |
1531 (ediff-eval-in-buffer buf | 1533 (ediff-with-current-buffer buf |
1532 (if (< beg end) | 1534 (if (< beg end) |
1533 (setq lines (count-lines beg end)) | 1535 (setq lines (count-lines beg end)) |
1534 (setq lines 0)) | 1536 (setq lines 0)) |
1535 lines | 1537 lines |
1536 )))) | 1538 )))) |
1537 | 1539 |
1538 ;; get number of lines from window end to region start | 1540 ;; get number of lines from window end to region start |
1539 (defun ediff-get-lines-to-region-start (buf-type &optional n ctl-buf) | 1541 (defun ediff-get-lines-to-region-start (buf-type &optional n ctl-buf) |
1540 (or n (setq n ediff-current-difference)) | 1542 (or n (setq n ediff-current-difference)) |
1541 (or ctl-buf (setq ctl-buf ediff-control-buffer)) | 1543 (or ctl-buf (setq ctl-buf ediff-control-buffer)) |
1542 (ediff-eval-in-buffer ctl-buf | 1544 (ediff-with-current-buffer ctl-buf |
1543 (let* ((buf (ediff-get-buffer buf-type)) | 1545 (let* ((buf (ediff-get-buffer buf-type)) |
1544 (wind (eval (intern (format "ediff-window-%S" buf-type)))) | 1546 (wind (eval (ediff-get-symbol-from-alist |
1547 buf-type ediff-window-alist))) | |
1545 (end (window-end wind)) | 1548 (end (window-end wind)) |
1546 (beg (ediff-get-diff-posn buf-type 'beg))) | 1549 (beg (ediff-get-diff-posn buf-type 'beg))) |
1547 (ediff-eval-in-buffer buf | 1550 (ediff-with-current-buffer buf |
1548 (if (< beg end) (count-lines beg end) 0)) | 1551 (if (< beg end) (count-lines beg end) 0)) |
1549 ))) | 1552 ))) |
1550 | 1553 |
1551 | 1554 |
1552 ;; region size coefficient is a coefficient by which to adjust scrolling | 1555 ;; region size coefficient is a coefficient by which to adjust scrolling |
1555 ;; that it won't happen that one diff region is scrolled off while the other is | 1558 ;; that it won't happen that one diff region is scrolled off while the other is |
1556 ;; still seen. | 1559 ;; still seen. |
1557 ;; | 1560 ;; |
1558 ;; If the difference region is invalid, the coefficient is 1 | 1561 ;; If the difference region is invalid, the coefficient is 1 |
1559 (defun ediff-get-region-size-coefficient (buf-type op &optional n ctl-buf) | 1562 (defun ediff-get-region-size-coefficient (buf-type op &optional n ctl-buf) |
1560 (ediff-eval-in-buffer (or ctl-buf ediff-control-buffer) | 1563 (ediff-with-current-buffer (or ctl-buf ediff-control-buffer) |
1561 (if (ediff-valid-difference-p n) | 1564 (if (ediff-valid-difference-p n) |
1562 (let* ((func (cond ((eq op 'scroll-down) | 1565 (let* ((func (cond ((eq op 'scroll-down) |
1563 'ediff-get-lines-to-region-start) | 1566 'ediff-get-lines-to-region-start) |
1564 ((eq op 'scroll-up) | 1567 ((eq op 'scroll-up) |
1565 'ediff-get-lines-to-region-end) | 1568 'ediff-get-lines-to-region-end) |
1682 in the specified buffer." | 1685 in the specified buffer." |
1683 (interactive "P") | 1686 (interactive "P") |
1684 (ediff-barf-if-not-control-buffer) | 1687 (ediff-barf-if-not-control-buffer) |
1685 (let* ((buf-type (ediff-char-to-buftype last-command-char)) | 1688 (let* ((buf-type (ediff-char-to-buftype last-command-char)) |
1686 (buffer (ediff-get-buffer buf-type)) | 1689 (buffer (ediff-get-buffer buf-type)) |
1687 (pt (ediff-eval-in-buffer buffer (point))) | 1690 (pt (ediff-with-current-buffer buffer (point))) |
1688 (diff-no (ediff-diff-at-point buf-type nil (if arg 'after))) | 1691 (diff-no (ediff-diff-at-point buf-type nil (if arg 'after))) |
1689 (past-last-diff (< ediff-number-of-differences diff-no)) | 1692 (past-last-diff (< ediff-number-of-differences diff-no)) |
1690 (beg (if past-last-diff | 1693 (beg (if past-last-diff |
1691 (ediff-eval-in-buffer buffer (point-max)) | 1694 (ediff-with-current-buffer buffer (point-max)) |
1692 (ediff-get-diff-posn buf-type 'beg (1- diff-no)))) | 1695 (ediff-get-diff-posn buf-type 'beg (1- diff-no)))) |
1693 ctl-wind wind-A wind-B wind-C | 1696 ctl-wind wind-A wind-B wind-C |
1694 shift) | 1697 shift) |
1695 (if past-last-diff | 1698 (if past-last-diff |
1696 (ediff-jump-to-difference -1) | 1699 (ediff-jump-to-difference -1) |
1699 wind-A ediff-window-A | 1702 wind-A ediff-window-A |
1700 wind-B ediff-window-B | 1703 wind-B ediff-window-B |
1701 wind-C ediff-window-C) | 1704 wind-C ediff-window-C) |
1702 (if arg | 1705 (if arg |
1703 (progn | 1706 (progn |
1704 (ediff-eval-in-buffer buffer | 1707 (ediff-with-current-buffer buffer |
1705 (setq shift (- beg pt))) | 1708 (setq shift (- beg pt))) |
1706 (select-window wind-A) | 1709 (select-window wind-A) |
1707 (if past-last-diff (goto-char (point-max))) | 1710 (if past-last-diff (goto-char (point-max))) |
1708 (condition-case nil | 1711 (condition-case nil |
1709 (backward-char shift) ; noerror, if beginning of buffer | 1712 (backward-char shift) ; noerror, if beginning of buffer |
1743 (prev-beg 0) | 1746 (prev-beg 0) |
1744 (prev-end 0) | 1747 (prev-end 0) |
1745 (beg 0) | 1748 (beg 0) |
1746 (end 0)) | 1749 (end 0)) |
1747 | 1750 |
1748 (ediff-eval-in-buffer buffer | 1751 (ediff-with-current-buffer buffer |
1749 (setq pos (or pos (point))) | 1752 (setq pos (or pos (point))) |
1750 (while (and (or (< pos prev-beg) (> pos beg)) | 1753 (while (and (or (< pos prev-beg) (> pos beg)) |
1751 (< diff-no max-dif-num)) | 1754 (< diff-no max-dif-num)) |
1752 (setq diff-no (1+ diff-no)) | 1755 (setq diff-no (1+ diff-no)) |
1753 (setq prev-beg beg | 1756 (setq prev-beg beg |
1871 (setq saved-p nil) ; don't copy identical buffers | 1874 (setq saved-p nil) ; don't copy identical buffers |
1872 ;; seems ok to copy | 1875 ;; seems ok to copy |
1873 (if (or batch-invocation (ediff-test-save-region n to-buf-type)) | 1876 (if (or batch-invocation (ediff-test-save-region n to-buf-type)) |
1874 (condition-case conds | 1877 (condition-case conds |
1875 (progn | 1878 (progn |
1876 (ediff-eval-in-buffer to-buf | 1879 (ediff-with-current-buffer to-buf |
1877 ;; to prevent flags from interfering if buffer is writable | 1880 ;; to prevent flags from interfering if buffer is writable |
1878 (let ((inhibit-read-only (null buffer-read-only))) | 1881 (let ((inhibit-read-only (null buffer-read-only))) |
1879 | 1882 |
1880 (goto-char reg-to-delete-end) | 1883 (goto-char reg-to-delete-end) |
1881 (insert reg-to-copy) | 1884 (insert reg-to-copy) |
1975 | 1978 |
1976 (setq reg-beg (ediff-get-diff-posn buf-type 'beg n ediff-control-buffer)) | 1979 (setq reg-beg (ediff-get-diff-posn buf-type 'beg n ediff-control-buffer)) |
1977 (setq reg-end (ediff-get-diff-posn buf-type 'end n ediff-control-buffer)) | 1980 (setq reg-end (ediff-get-diff-posn buf-type 'end n ediff-control-buffer)) |
1978 | 1981 |
1979 (condition-case conds | 1982 (condition-case conds |
1980 (ediff-eval-in-buffer buf | 1983 (ediff-with-current-buffer buf |
1981 (let ((inhibit-read-only (null buffer-read-only))) | 1984 (let ((inhibit-read-only (null buffer-read-only))) |
1982 | 1985 |
1983 (goto-char reg-end) | 1986 (goto-char reg-end) |
1984 (insert saved-diff) | 1987 (insert saved-diff) |
1985 | 1988 |
2157 (if (ediff-valid-difference-p n) | 2160 (if (ediff-valid-difference-p n) |
2158 (let* ((ctl-buf ediff-control-buffer) | 2161 (let* ((ctl-buf ediff-control-buffer) |
2159 (regex-A ediff-regexp-focus-A) | 2162 (regex-A ediff-regexp-focus-A) |
2160 (regex-B ediff-regexp-focus-B) | 2163 (regex-B ediff-regexp-focus-B) |
2161 (regex-C ediff-regexp-focus-C) | 2164 (regex-C ediff-regexp-focus-C) |
2162 (reg-A-match (ediff-eval-in-buffer ediff-buffer-A | 2165 (reg-A-match (ediff-with-current-buffer ediff-buffer-A |
2163 (save-restriction | 2166 (save-restriction |
2164 (narrow-to-region | 2167 (narrow-to-region |
2165 (ediff-get-diff-posn 'A 'beg n ctl-buf) | 2168 (ediff-get-diff-posn 'A 'beg n ctl-buf) |
2166 (ediff-get-diff-posn 'A 'end n ctl-buf)) | 2169 (ediff-get-diff-posn 'A 'end n ctl-buf)) |
2167 (goto-char (point-min)) | 2170 (goto-char (point-min)) |
2168 (re-search-forward regex-A nil t)))) | 2171 (re-search-forward regex-A nil t)))) |
2169 (reg-B-match (ediff-eval-in-buffer ediff-buffer-B | 2172 (reg-B-match (ediff-with-current-buffer ediff-buffer-B |
2170 (save-restriction | 2173 (save-restriction |
2171 (narrow-to-region | 2174 (narrow-to-region |
2172 (ediff-get-diff-posn 'B 'beg n ctl-buf) | 2175 (ediff-get-diff-posn 'B 'beg n ctl-buf) |
2173 (ediff-get-diff-posn 'B 'end n ctl-buf)) | 2176 (ediff-get-diff-posn 'B 'end n ctl-buf)) |
2174 (re-search-forward regex-B nil t)))) | 2177 (re-search-forward regex-B nil t)))) |
2175 (reg-C-match (if ediff-3way-comparison-job | 2178 (reg-C-match (if ediff-3way-comparison-job |
2176 (ediff-eval-in-buffer ediff-buffer-C | 2179 (ediff-with-current-buffer ediff-buffer-C |
2177 (save-restriction | 2180 (save-restriction |
2178 (narrow-to-region | 2181 (narrow-to-region |
2179 (ediff-get-diff-posn 'C 'beg n ctl-buf) | 2182 (ediff-get-diff-posn 'C 'beg n ctl-buf) |
2180 (ediff-get-diff-posn 'C 'end n ctl-buf)) | 2183 (ediff-get-diff-posn 'C 'end n ctl-buf)) |
2181 (re-search-forward regex-C nil t)))))) | 2184 (re-search-forward regex-C nil t)))))) |
2198 (if (ediff-valid-difference-p n) | 2201 (if (ediff-valid-difference-p n) |
2199 (let* ((ctl-buf ediff-control-buffer) | 2202 (let* ((ctl-buf ediff-control-buffer) |
2200 (regex-A ediff-regexp-hide-A) | 2203 (regex-A ediff-regexp-hide-A) |
2201 (regex-B ediff-regexp-hide-B) | 2204 (regex-B ediff-regexp-hide-B) |
2202 (regex-C ediff-regexp-hide-C) | 2205 (regex-C ediff-regexp-hide-C) |
2203 (reg-A-match (ediff-eval-in-buffer ediff-buffer-A | 2206 (reg-A-match (ediff-with-current-buffer ediff-buffer-A |
2204 (save-restriction | 2207 (save-restriction |
2205 (narrow-to-region | 2208 (narrow-to-region |
2206 (ediff-get-diff-posn 'A 'beg n ctl-buf) | 2209 (ediff-get-diff-posn 'A 'beg n ctl-buf) |
2207 (ediff-get-diff-posn 'A 'end n ctl-buf)) | 2210 (ediff-get-diff-posn 'A 'end n ctl-buf)) |
2208 (goto-char (point-min)) | 2211 (goto-char (point-min)) |
2209 (re-search-forward regex-A nil t)))) | 2212 (re-search-forward regex-A nil t)))) |
2210 (reg-B-match (ediff-eval-in-buffer ediff-buffer-B | 2213 (reg-B-match (ediff-with-current-buffer ediff-buffer-B |
2211 (save-restriction | 2214 (save-restriction |
2212 (narrow-to-region | 2215 (narrow-to-region |
2213 (ediff-get-diff-posn 'B 'beg n ctl-buf) | 2216 (ediff-get-diff-posn 'B 'beg n ctl-buf) |
2214 (ediff-get-diff-posn 'B 'end n ctl-buf)) | 2217 (ediff-get-diff-posn 'B 'end n ctl-buf)) |
2215 (goto-char (point-min)) | 2218 (goto-char (point-min)) |
2216 (re-search-forward regex-B nil t)))) | 2219 (re-search-forward regex-B nil t)))) |
2217 (reg-C-match (if ediff-3way-comparison-job | 2220 (reg-C-match (if ediff-3way-comparison-job |
2218 (ediff-eval-in-buffer ediff-buffer-C | 2221 (ediff-with-current-buffer ediff-buffer-C |
2219 (save-restriction | 2222 (save-restriction |
2220 (narrow-to-region | 2223 (narrow-to-region |
2221 (ediff-get-diff-posn 'C 'beg n ctl-buf) | 2224 (ediff-get-diff-posn 'C 'beg n ctl-buf) |
2222 (ediff-get-diff-posn 'C 'end n ctl-buf)) | 2225 (ediff-get-diff-posn 'C 'end n ctl-buf)) |
2223 (goto-char (point-min)) | 2226 (goto-char (point-min)) |
2293 (window-frame ediff-window-A)) | 2296 (window-frame ediff-window-A)) |
2294 ((window-live-p ediff-window-B) | 2297 ((window-live-p ediff-window-B) |
2295 (window-frame ediff-window-B)) | 2298 (window-frame ediff-window-B)) |
2296 (t (next-frame)))))) | 2299 (t (next-frame)))))) |
2297 (condition-case nil | 2300 (condition-case nil |
2298 (ediff-eval-in-buffer ediff-buffer-A | 2301 (ediff-with-current-buffer ediff-buffer-A |
2299 (setq ediff-this-buffer-ediff-sessions | 2302 (setq ediff-this-buffer-ediff-sessions |
2300 (delq control-buffer ediff-this-buffer-ediff-sessions)) | 2303 (delq control-buffer ediff-this-buffer-ediff-sessions)) |
2301 (kill-local-variable 'mode-line-buffer-identification) | 2304 (kill-local-variable 'mode-line-buffer-identification) |
2302 (kill-local-variable 'mode-line-format) | 2305 (kill-local-variable 'mode-line-format) |
2303 ) | 2306 ) |
2304 (error)) | 2307 (error)) |
2305 | 2308 |
2306 (condition-case nil | 2309 (condition-case nil |
2307 (ediff-eval-in-buffer ediff-buffer-B | 2310 (ediff-with-current-buffer ediff-buffer-B |
2308 (setq ediff-this-buffer-ediff-sessions | 2311 (setq ediff-this-buffer-ediff-sessions |
2309 (delq control-buffer ediff-this-buffer-ediff-sessions)) | 2312 (delq control-buffer ediff-this-buffer-ediff-sessions)) |
2310 (kill-local-variable 'mode-line-buffer-identification) | 2313 (kill-local-variable 'mode-line-buffer-identification) |
2311 (kill-local-variable 'mode-line-format) | 2314 (kill-local-variable 'mode-line-format) |
2312 ) | 2315 ) |
2313 (error)) | 2316 (error)) |
2314 | 2317 |
2315 (condition-case nil | 2318 (condition-case nil |
2316 (ediff-eval-in-buffer ediff-buffer-C | 2319 (ediff-with-current-buffer ediff-buffer-C |
2317 (setq ediff-this-buffer-ediff-sessions | 2320 (setq ediff-this-buffer-ediff-sessions |
2318 (delq control-buffer ediff-this-buffer-ediff-sessions)) | 2321 (delq control-buffer ediff-this-buffer-ediff-sessions)) |
2319 (kill-local-variable 'mode-line-buffer-identification) | 2322 (kill-local-variable 'mode-line-buffer-identification) |
2320 (kill-local-variable 'mode-line-format) | 2323 (kill-local-variable 'mode-line-format) |
2321 ) | 2324 ) |
2322 (error)) | 2325 (error)) |
2323 | 2326 |
2324 (condition-case nil | 2327 (condition-case nil |
2325 (ediff-eval-in-buffer ediff-ancestor-buffer | 2328 (ediff-with-current-buffer ediff-ancestor-buffer |
2326 (setq ediff-this-buffer-ediff-sessions | 2329 (setq ediff-this-buffer-ediff-sessions |
2327 (delq control-buffer ediff-this-buffer-ediff-sessions)) | 2330 (delq control-buffer ediff-this-buffer-ediff-sessions)) |
2328 (kill-local-variable 'mode-line-buffer-identification) | 2331 (kill-local-variable 'mode-line-buffer-identification) |
2329 (kill-local-variable 'mode-line-format) | 2332 (kill-local-variable 'mode-line-format) |
2330 ) | 2333 ) |
2492 (setq merge-store-file | 2495 (setq merge-store-file |
2493 (read-file-name "Save the merge buffer in file: ")) | 2496 (read-file-name "Save the merge buffer in file: ")) |
2494 (ediff-write-merge-buffer-and-maybe-kill | 2497 (ediff-write-merge-buffer-and-maybe-kill |
2495 ediff-buffer-C merge-store-file nil save-and-continue)) | 2498 ediff-buffer-C merge-store-file nil save-and-continue)) |
2496 ((and (ediff-buffer-live-p ediff-meta-buffer) | 2499 ((and (ediff-buffer-live-p ediff-meta-buffer) |
2497 (ediff-eval-in-buffer ediff-meta-buffer | 2500 (ediff-with-current-buffer ediff-meta-buffer |
2498 (ediff-merge-metajob))) | 2501 (ediff-merge-metajob))) |
2499 ;; This case shouldn't occur, as the parent metajob must pass on | 2502 ;; This case shouldn't occur, as the parent metajob must pass on |
2500 ;; a file name, ediff-merge-store-file, where to save the result | 2503 ;; a file name, ediff-merge-store-file, where to save the result |
2501 ;; of the merge. | 2504 ;; of the merge. |
2502 ;; Ask where to save anyway--will decide what to do here later. | 2505 ;; Ask where to save anyway--will decide what to do here later. |
2509 ;; write merge buffer. If the optional argument save-and-continue is non-nil, | 2512 ;; write merge buffer. If the optional argument save-and-continue is non-nil, |
2510 ;; then don't kill the merge buffer | 2513 ;; then don't kill the merge buffer |
2511 (defun ediff-write-merge-buffer-and-maybe-kill (buf file | 2514 (defun ediff-write-merge-buffer-and-maybe-kill (buf file |
2512 &optional | 2515 &optional |
2513 show-file save-and-continue) | 2516 show-file save-and-continue) |
2514 (ediff-eval-in-buffer buf | 2517 (ediff-with-current-buffer buf |
2515 (if (or (not (file-exists-p file)) | 2518 (if (or (not (file-exists-p file)) |
2516 (y-or-n-p (format "File %s exists, overwrite? " file))) | 2519 (y-or-n-p (format "File %s exists, overwrite? " file))) |
2517 (progn | 2520 (progn |
2518 (write-region (point-min) (point-max) file) | 2521 (write-region (point-min) (point-max) file) |
2519 (if show-file | 2522 (if show-file |
2603 (ediff-skip-unsuitable-frames)) | 2606 (ediff-skip-unsuitable-frames)) |
2604 (with-output-to-temp-buffer ediff-msg-buffer | 2607 (with-output-to-temp-buffer ediff-msg-buffer |
2605 (raise-frame (selected-frame)) | 2608 (raise-frame (selected-frame)) |
2606 (princ (ediff-version)) | 2609 (princ (ediff-version)) |
2607 (princ "\n\n") | 2610 (princ "\n\n") |
2608 (ediff-eval-in-buffer ediff-buffer-A | 2611 (ediff-with-current-buffer ediff-buffer-A |
2609 (if buffer-file-name | 2612 (if buffer-file-name |
2610 (princ | 2613 (princ |
2611 (format "File A = %S\n" buffer-file-name)) | 2614 (format "File A = %S\n" buffer-file-name)) |
2612 (princ | 2615 (princ |
2613 (format "Buffer A = %S\n" (buffer-name))))) | 2616 (format "Buffer A = %S\n" (buffer-name))))) |
2614 (ediff-eval-in-buffer ediff-buffer-B | 2617 (ediff-with-current-buffer ediff-buffer-B |
2615 (if buffer-file-name | 2618 (if buffer-file-name |
2616 (princ | 2619 (princ |
2617 (format "File B = %S\n" buffer-file-name)) | 2620 (format "File B = %S\n" buffer-file-name)) |
2618 (princ | 2621 (princ |
2619 (format "Buffer B = %S\n" (buffer-name))))) | 2622 (format "Buffer B = %S\n" (buffer-name))))) |
2620 (if ediff-3way-job | 2623 (if ediff-3way-job |
2621 (ediff-eval-in-buffer ediff-buffer-C | 2624 (ediff-with-current-buffer ediff-buffer-C |
2622 (if buffer-file-name | 2625 (if buffer-file-name |
2623 (princ | 2626 (princ |
2624 (format "File C = %S\n" buffer-file-name)) | 2627 (format "File C = %S\n" buffer-file-name)) |
2625 (princ | 2628 (princ |
2626 (format "Buffer C = %S\n" (buffer-name)))))) | 2629 (format "Buffer C = %S\n" (buffer-name)))))) |
2633 (if (ediff-buffer-live-p ediff-diff-buffer) | 2636 (if (ediff-buffer-live-p ediff-diff-buffer) |
2634 (concat "\tin buffer " | 2637 (concat "\tin buffer " |
2635 (buffer-name ediff-diff-buffer)) | 2638 (buffer-name ediff-diff-buffer)) |
2636 " is not available"))) | 2639 " is not available"))) |
2637 | 2640 |
2638 (let* ((A-line (ediff-eval-in-buffer ediff-buffer-A | 2641 (let* ((A-line (ediff-with-current-buffer ediff-buffer-A |
2639 (1+ (count-lines (point-min) (point))))) | 2642 (1+ (count-lines (point-min) (point))))) |
2640 (B-line (ediff-eval-in-buffer ediff-buffer-B | 2643 (B-line (ediff-with-current-buffer ediff-buffer-B |
2641 (1+ (count-lines (point-min) (point))))) | 2644 (1+ (count-lines (point-min) (point))))) |
2642 C-line) | 2645 C-line) |
2643 (princ (format "\Buffer A's point is on line %d\n" A-line)) | 2646 (princ (format "\Buffer A's point is on line %d\n" A-line)) |
2644 (princ (format "Buffer B's point is on line %d\n" B-line)) | 2647 (princ (format "Buffer B's point is on line %d\n" B-line)) |
2645 (if ediff-3way-job | 2648 (if ediff-3way-job |
2646 (progn | 2649 (progn |
2647 (setq C-line (ediff-eval-in-buffer ediff-buffer-C | 2650 (setq C-line (ediff-with-current-buffer ediff-buffer-C |
2648 (1+ (count-lines (point-min) (point))))) | 2651 (1+ (count-lines (point-min) (point))))) |
2649 (princ (format "Buffer C's point is on line %d\n" C-line))))) | 2652 (princ (format "Buffer C's point is on line %d\n" C-line))))) |
2650 | 2653 |
2651 (princ (format "\nCurrent difference number = %S\n" | 2654 (princ (format "\nCurrent difference number = %S\n" |
2652 (cond ((< ediff-current-difference 0) 'start) | 2655 (cond ((< ediff-current-difference 0) 'start) |
2778 (or (eq flag 'unselect-only) | 2781 (or (eq flag 'unselect-only) |
2779 (ediff-select-difference n)) | 2782 (ediff-select-difference n)) |
2780 (setq ediff-current-difference n) | 2783 (setq ediff-current-difference n) |
2781 ) ; end protected section | 2784 ) ; end protected section |
2782 | 2785 |
2783 (ediff-eval-in-buffer control-buf (ediff-refresh-mode-lines)) | 2786 (ediff-with-current-buffer control-buf (ediff-refresh-mode-lines)) |
2784 ))) | 2787 ))) |
2785 | 2788 |
2786 | 2789 |
2787 (defun ediff-read-file-name (prompt default-dir default-file) | 2790 (defun ediff-read-file-name (prompt default-dir default-file) |
2788 ; This is a modified version of a similar function in `emerge.el'. | 2791 ; This is a modified version of a similar function in `emerge.el'. |
2859 ;; If a file with the orig name exists, add some random stuff | 2862 ;; If a file with the orig name exists, add some random stuff |
2860 ;; to it. | 2863 ;; to it. |
2861 (t (make-temp-name f)))) | 2864 (t (make-temp-name f)))) |
2862 | 2865 |
2863 ;; create the file | 2866 ;; create the file |
2864 (ediff-eval-in-buffer buff | 2867 (ediff-with-current-buffer buff |
2865 (write-region (if start start (point-min)) | 2868 (write-region (if start start (point-min)) |
2866 (if end end (point-max)) | 2869 (if end end (point-max)) |
2867 f | 2870 f |
2868 nil ; don't append---erase | 2871 nil ; don't append---erase |
2869 'no-message) | 2872 'no-message) |
2924 Without an argument, it saves customized diff argument, if available | 2927 Without an argument, it saves customized diff argument, if available |
2925 \(and plain output, if customized output was not generated\)." | 2928 \(and plain output, if customized output was not generated\)." |
2926 (interactive "P") | 2929 (interactive "P") |
2927 (ediff-barf-if-not-control-buffer) | 2930 (ediff-barf-if-not-control-buffer) |
2928 (ediff-compute-custom-diffs-maybe) | 2931 (ediff-compute-custom-diffs-maybe) |
2929 (ediff-eval-in-buffer | 2932 (ediff-with-current-buffer |
2930 (cond ((memq last-command-char '(?a ?b ?c)) | 2933 (cond ((memq last-command-char '(?a ?b ?c)) |
2931 (ediff-get-buffer | 2934 (ediff-get-buffer |
2932 (ediff-char-to-buftype last-command-char))) | 2935 (ediff-char-to-buftype last-command-char))) |
2933 ((eq last-command-char ?d) | 2936 ((eq last-command-char ?d) |
2934 (message "Saving diff output ...") | 2937 (message "Saving diff output ...") |
2981 (beep) | 2984 (beep) |
2982 (message "Output from `diff' not found") | 2985 (message "Output from `diff' not found") |
2983 nil)))) | 2986 nil)))) |
2984 (if buf | 2987 (if buf |
2985 (progn | 2988 (progn |
2986 (ediff-eval-in-buffer buf | 2989 (ediff-with-current-buffer buf |
2987 (goto-char (point-min))) | 2990 (goto-char (point-min))) |
2988 (switch-to-buffer buf) | 2991 (switch-to-buffer buf) |
2989 (raise-frame (selected-frame))))) | 2992 (raise-frame (selected-frame))))) |
2990 (if (frame-live-p ediff-control-frame) | 2993 (if (frame-live-p ediff-control-frame) |
2991 (ediff-reset-mouse ediff-control-frame)) | 2994 (ediff-reset-mouse ediff-control-frame)) |
3030 ((ediff-3way-comparison-job) | 3033 ((ediff-3way-comparison-job) |
3031 (while (cond ((memq answer possibilities) | 3034 (while (cond ((memq answer possibilities) |
3032 (setq possibilities (delq answer possibilities)) | 3035 (setq possibilities (delq answer possibilities)) |
3033 (setq bufA | 3036 (setq bufA |
3034 (eval | 3037 (eval |
3035 (intern (format "ediff-buffer-%c" answer)))) | 3038 (ediff-get-symbol-from-alist |
3039 answer ediff-buffer-alist))) | |
3036 nil) | 3040 nil) |
3037 ((equal answer "")) | 3041 ((equal answer "")) |
3038 (t (beep 1) | 3042 (t (beep 1) |
3039 (message | 3043 (message |
3040 "Valid values are %s" | 3044 "Valid values are %s" |
3048 (setq answer "") ; silence error msg | 3052 (setq answer "") ; silence error msg |
3049 (while (cond ((memq answer possibilities) | 3053 (while (cond ((memq answer possibilities) |
3050 (setq possibilities (delq answer possibilities)) | 3054 (setq possibilities (delq answer possibilities)) |
3051 (setq bufB | 3055 (setq bufB |
3052 (eval | 3056 (eval |
3053 (intern (format "ediff-buffer-%c" answer)))) | 3057 (ediff-get-symbol-from-alist |
3058 answer ediff-buffer-alist))) | |
3054 nil) | 3059 nil) |
3055 ((equal answer "")) | 3060 ((equal answer "")) |
3056 (t (beep 1) | 3061 (t (beep 1) |
3057 (message | 3062 (message |
3058 "Valid values are %s" | 3063 "Valid values are %s" |
3066 (t ; 2way comparison | 3071 (t ; 2way comparison |
3067 (setq bufA ediff-buffer-A | 3072 (setq bufA ediff-buffer-A |
3068 bufB ediff-buffer-B | 3073 bufB ediff-buffer-B |
3069 possibilities nil))) | 3074 possibilities nil))) |
3070 | 3075 |
3071 (ediff-eval-in-buffer bufA | 3076 (ediff-with-current-buffer bufA |
3072 (or (mark t) | 3077 (or (mark t) |
3073 (error "You forgot to specify a region in buffer %s" (buffer-name))) | 3078 (error "You forgot to specify a region in buffer %s" (buffer-name))) |
3074 (setq begA (region-beginning) | 3079 (setq begA (region-beginning) |
3075 endA (region-end)) | 3080 endA (region-end)) |
3076 (goto-char begA) | 3081 (goto-char begA) |
3078 (setq begA (point)) | 3083 (setq begA (point)) |
3079 (goto-char endA) | 3084 (goto-char endA) |
3080 (end-of-line) | 3085 (end-of-line) |
3081 (or (eobp) (forward-char)) ; include the newline char | 3086 (or (eobp) (forward-char)) ; include the newline char |
3082 (setq endA (point))) | 3087 (setq endA (point))) |
3083 (ediff-eval-in-buffer bufB | 3088 (ediff-with-current-buffer bufB |
3084 (or (mark t) | 3089 (or (mark t) |
3085 (error "You forgot to specify a region in buffer %s" (buffer-name))) | 3090 (error "You forgot to specify a region in buffer %s" (buffer-name))) |
3086 (setq begB (region-beginning) | 3091 (setq begB (region-beginning) |
3087 endB (region-end)) | 3092 endB (region-end)) |
3088 (goto-char begB) | 3093 (goto-char begB) |
3095 | 3100 |
3096 (ediff-unselect-and-select-difference | 3101 (ediff-unselect-and-select-difference |
3097 ediff-current-difference 'unselect-only) | 3102 ediff-current-difference 'unselect-only) |
3098 (ediff-paint-background-regions 'unhighlight) | 3103 (ediff-paint-background-regions 'unhighlight) |
3099 | 3104 |
3100 (ediff-eval-in-buffer bufA | 3105 (ediff-with-current-buffer bufA |
3101 (goto-char begA) | 3106 (goto-char begA) |
3102 (set-mark endA) | 3107 (set-mark endA) |
3103 (narrow-to-region begA endA) | 3108 (narrow-to-region begA endA) |
3104 ;; (ediff-activate-mark) | 3109 ;; (ediff-activate-mark) |
3105 ) | 3110 ) |
3106 ;; (sit-for 0) | 3111 ;; (sit-for 0) |
3107 (ediff-eval-in-buffer bufB | 3112 (ediff-with-current-buffer bufB |
3108 (goto-char begB) | 3113 (goto-char begB) |
3109 (set-mark endB) | 3114 (set-mark endB) |
3110 (narrow-to-region begB endB) | 3115 (narrow-to-region begB endB) |
3111 ;; (ediff-activate-mark) | 3116 ;; (ediff-activate-mark) |
3112 ) | 3117 ) |
3114 | 3119 |
3115 ;; At this point, possibilities contains either the window char A/B/C | 3120 ;; At this point, possibilities contains either the window char A/B/C |
3116 ;; that was not selected, or it is nil. We delete the window that is not | 3121 ;; that was not selected, or it is nil. We delete the window that is not |
3117 ;; selected. | 3122 ;; selected. |
3118 (if possibilities | 3123 (if possibilities |
3119 (ediff-eval-in-buffer ctl-buf | 3124 (ediff-with-current-buffer ctl-buf |
3120 (let* ((wind-to-delete (eval | 3125 (let* ((wind-to-delete (eval |
3121 (intern | 3126 (ediff-get-symbol-from-alist |
3122 (format | 3127 (car possibilities) |
3123 "ediff-window-%c" (car possibilities))))) | 3128 ediff-window-alist))) |
3124 (frame (window-frame wind-to-delete))) | 3129 (frame (window-frame wind-to-delete))) |
3125 (delete-window wind-to-delete) | 3130 (delete-window wind-to-delete) |
3126 (select-frame frame) | 3131 (select-frame frame) |
3127 (balance-windows)))) | 3132 (balance-windows)))) |
3128 (or (y-or-n-p | 3133 (or (y-or-n-p |
3129 "Please check regions selected for comparison. Continue? ") | 3134 "Please check regions selected for comparison. Continue? ") |
3130 (setq quit-now t)) | 3135 (setq quit-now t)) |
3131 | 3136 |
3132 (ediff-eval-in-buffer bufA | 3137 (ediff-with-current-buffer bufA |
3133 (widen)) | 3138 (widen)) |
3134 (ediff-eval-in-buffer bufB | 3139 (ediff-with-current-buffer bufB |
3135 (widen)) | 3140 (widen)) |
3136 (if quit-now | 3141 (if quit-now |
3137 (ediff-eval-in-buffer ctl-buf | 3142 (ediff-with-current-buffer ctl-buf |
3138 (ediff-recenter) | 3143 (ediff-recenter) |
3139 (sit-for 0) | 3144 (sit-for 0) |
3140 (error "All right. Make up your mind and come back..."))) | 3145 (error "All right. Make up your mind and come back..."))) |
3141 | 3146 |
3142 (ediff-regions-internal | 3147 (ediff-regions-internal |
3149 )) | 3154 )) |
3150 | 3155 |
3151 | 3156 |
3152 | 3157 |
3153 (defun ediff-remove-flags-from-buffer (buffer overlay) | 3158 (defun ediff-remove-flags-from-buffer (buffer overlay) |
3154 (ediff-eval-in-buffer buffer | 3159 (ediff-with-current-buffer buffer |
3155 (let ((inhibit-read-only t)) | 3160 (let ((inhibit-read-only t)) |
3156 (if ediff-xemacs-p | 3161 (if ediff-xemacs-p |
3157 (ediff-overlay-put overlay 'begin-glyph nil) | 3162 (ediff-overlay-put overlay 'begin-glyph nil) |
3158 (ediff-overlay-put overlay 'before-string nil)) | 3163 (ediff-overlay-put overlay 'before-string nil)) |
3159 | 3164 |
3163 ))) | 3168 ))) |
3164 | 3169 |
3165 | 3170 |
3166 | 3171 |
3167 (defun ediff-place-flags-in-buffer (buf-type buffer ctl-buffer diff) | 3172 (defun ediff-place-flags-in-buffer (buf-type buffer ctl-buffer diff) |
3168 (ediff-eval-in-buffer buffer | 3173 (ediff-with-current-buffer buffer |
3169 (ediff-place-flags-in-buffer1 buf-type ctl-buffer diff))) | 3174 (ediff-place-flags-in-buffer1 buf-type ctl-buffer diff))) |
3170 | 3175 |
3171 | 3176 |
3172 (defun ediff-place-flags-in-buffer1 (buf-type ctl-buffer diff-no) | 3177 (defun ediff-place-flags-in-buffer1 (buf-type ctl-buffer diff-no) |
3173 (let* ((curr-overl (ediff-eval-in-buffer ctl-buffer | 3178 (let* ((curr-overl (ediff-with-current-buffer ctl-buffer |
3174 (ediff-get-diff-overlay diff-no buf-type))) | 3179 (ediff-get-diff-overlay diff-no buf-type))) |
3175 (before (ediff-get-diff-posn buf-type 'beg diff-no ctl-buffer)) | 3180 (before (ediff-get-diff-posn buf-type 'beg diff-no ctl-buffer)) |
3176 after beg-of-line flag) | 3181 after beg-of-line flag) |
3177 | 3182 |
3178 ;; insert flag before the difference | 3183 ;; insert flag before the difference |
3179 (goto-char before) | 3184 (goto-char before) |
3180 (setq beg-of-line (bolp)) | 3185 (setq beg-of-line (bolp)) |
3181 | 3186 |
3182 (setq flag (ediff-eval-in-buffer ctl-buffer | 3187 (setq flag (ediff-with-current-buffer ctl-buffer |
3183 (if (eq ediff-highlighting-style 'ascii) | 3188 (if (eq ediff-highlighting-style 'ascii) |
3184 (if beg-of-line | 3189 (if beg-of-line |
3185 ediff-before-flag-bol ediff-before-flag-mol)))) | 3190 ediff-before-flag-bol ediff-before-flag-mol)))) |
3186 | 3191 |
3187 ;; insert the flag itself | 3192 ;; insert the flag itself |
3193 ;; `after' must be set here, after the before-flag was inserted | 3198 ;; `after' must be set here, after the before-flag was inserted |
3194 (setq after (ediff-get-diff-posn buf-type 'end diff-no ctl-buffer)) | 3199 (setq after (ediff-get-diff-posn buf-type 'end diff-no ctl-buffer)) |
3195 (goto-char after) | 3200 (goto-char after) |
3196 (setq beg-of-line (bolp)) | 3201 (setq beg-of-line (bolp)) |
3197 | 3202 |
3198 (setq flag (ediff-eval-in-buffer ctl-buffer | 3203 (setq flag (ediff-with-current-buffer ctl-buffer |
3199 (if (eq ediff-highlighting-style 'ascii) | 3204 (if (eq ediff-highlighting-style 'ascii) |
3200 (if beg-of-line | 3205 (if beg-of-line |
3201 ediff-after-flag-eol ediff-after-flag-mol)))) | 3206 ediff-after-flag-eol ediff-after-flag-mol)))) |
3202 | 3207 |
3203 ;; insert the flag itself | 3208 ;; insert the flag itself |
3220 (defun ediff-get-diff-posn (buf-type pos &optional n control-buf) | 3225 (defun ediff-get-diff-posn (buf-type pos &optional n control-buf) |
3221 (let (diff-overlay) | 3226 (let (diff-overlay) |
3222 (or control-buf | 3227 (or control-buf |
3223 (setq control-buf (current-buffer))) | 3228 (setq control-buf (current-buffer))) |
3224 | 3229 |
3225 (ediff-eval-in-buffer control-buf | 3230 (ediff-with-current-buffer control-buf |
3226 (or n (setq n ediff-current-difference)) | 3231 (or n (setq n ediff-current-difference)) |
3227 (if (or (< n 0) (>= n ediff-number-of-differences)) | 3232 (if (or (< n 0) (>= n ediff-number-of-differences)) |
3228 (if (> ediff-number-of-differences 0) | 3233 (if (> ediff-number-of-differences 0) |
3229 (error ediff-BAD-DIFF-NUMBER | 3234 (error ediff-BAD-DIFF-NUMBER |
3230 this-command (1+ n) ediff-number-of-differences) | 3235 this-command (1+ n) ediff-number-of-differences) |
3239 | 3244 |
3240 | 3245 |
3241 ;; Restore highlighting to what it should be according to ediff-use-faces, | 3246 ;; Restore highlighting to what it should be according to ediff-use-faces, |
3242 ;; ediff-highlighting-style, and ediff-highlight-all-diffs variables. | 3247 ;; ediff-highlighting-style, and ediff-highlight-all-diffs variables. |
3243 (defun ediff-restore-highlighting (&optional ctl-buf) | 3248 (defun ediff-restore-highlighting (&optional ctl-buf) |
3244 (ediff-eval-in-buffer (or ctl-buf (current-buffer)) | 3249 (ediff-with-current-buffer (or ctl-buf (current-buffer)) |
3245 (if (and (ediff-has-face-support-p) | 3250 (if (and (ediff-has-face-support-p) |
3246 ediff-use-faces | 3251 ediff-use-faces |
3247 ediff-highlight-all-diffs) | 3252 ediff-highlight-all-diffs) |
3248 (ediff-paint-background-regions)) | 3253 (ediff-paint-background-regions)) |
3249 (ediff-select-difference ediff-current-difference))) | 3254 (ediff-select-difference ediff-current-difference))) |
3279 ;; If BUFF is not a live buffer, then return nil; otherwise, return the | 3284 ;; If BUFF is not a live buffer, then return nil; otherwise, return the |
3280 ;; newly created overlay. | 3285 ;; newly created overlay. |
3281 (defun ediff-make-bullet-proof-overlay (beg end buff) | 3286 (defun ediff-make-bullet-proof-overlay (beg end buff) |
3282 (if (ediff-buffer-live-p buff) | 3287 (if (ediff-buffer-live-p buff) |
3283 (let (overl) | 3288 (let (overl) |
3284 (ediff-eval-in-buffer buff | 3289 (ediff-with-current-buffer buff |
3285 (or (number-or-marker-p beg) | 3290 (or (number-or-marker-p beg) |
3286 (setq beg (eval beg))) | 3291 (setq beg (eval beg))) |
3287 (or (number-or-marker-p end) | 3292 (or (number-or-marker-p end) |
3288 (setq end (eval end))) | 3293 (setq end (eval end))) |
3289 (setq overl | 3294 (setq overl |
3352 (while (get-buffer (format "%s<%d>%s" prefix n suffix)) | 3357 (while (get-buffer (format "%s<%d>%s" prefix n suffix)) |
3353 (setq n (1+ n))) | 3358 (setq n (1+ n))) |
3354 (format "%s<%d>%s" prefix n suffix)))) | 3359 (format "%s<%d>%s" prefix n suffix)))) |
3355 | 3360 |
3356 | 3361 |
3357 ;; splits at a white space, returns a list | |
3358 (defun ediff-split-string (string) | |
3359 (let ((start 0) | |
3360 (result '()) | |
3361 substr) | |
3362 (while (string-match "[ \t]+" string start) | |
3363 (let ((match (string-match "[ \t]+" string start))) | |
3364 (setq substr (substring string start match)) | |
3365 (if (> (length substr) 0) | |
3366 (setq result (cons substr result))) | |
3367 (setq start (match-end 0)))) | |
3368 (setq substr (substring string start nil)) | |
3369 (if (> (length substr) 0) | |
3370 (setq result (cons substr result))) | |
3371 (nreverse result))) | |
3372 | |
3373 (defun ediff-submit-report () | 3362 (defun ediff-submit-report () |
3374 "Submit bug report on Ediff." | 3363 "Submit bug report on Ediff." |
3375 (interactive) | 3364 (interactive) |
3376 (ediff-barf-if-not-control-buffer) | 3365 (ediff-barf-if-not-control-buffer) |
3377 (let ((reporter-prompt-for-summary-p t) | 3366 (let ((reporter-prompt-for-summary-p t) |
3457 'delete-other-windows | 3446 'delete-other-windows |
3458 salutation)) | 3447 salutation)) |
3459 (bury-buffer) | 3448 (bury-buffer) |
3460 (beep 1)(message "Bug report aborted") | 3449 (beep 1)(message "Bug report aborted") |
3461 (if (ediff-buffer-live-p ctl-buf) | 3450 (if (ediff-buffer-live-p ctl-buf) |
3462 (ediff-eval-in-buffer ctl-buf | 3451 (ediff-with-current-buffer ctl-buf |
3463 (ediff-recenter 'no-rehighlight)))) | 3452 (ediff-recenter 'no-rehighlight)))) |
3464 )) | 3453 )) |
3465 | 3454 |
3466 | 3455 |
3467 (defun ediff-deactivate-mark () | 3456 (defun ediff-deactivate-mark () |
3509 (set (car vars) (cdr (assoc (car vars) assoc-list))) | 3498 (set (car vars) (cdr (assoc (car vars) assoc-list))) |
3510 (setq vars (cdr vars)))) | 3499 (setq vars (cdr vars)))) |
3511 | 3500 |
3512 (defun ediff-change-saved-variable (var value buf-type) | 3501 (defun ediff-change-saved-variable (var value buf-type) |
3513 (let* ((assoc-list | 3502 (let* ((assoc-list |
3514 (symbol-value (intern | 3503 (symbol-value (ediff-get-symbol-from-alist |
3515 (concat "ediff-buffer-values-orig-" | 3504 buf-type |
3516 (symbol-name buf-type))))) | 3505 ediff-buffer-values-orig-alist))) |
3517 (assoc-elt (assoc var assoc-list))) | 3506 (assoc-elt (assoc var assoc-list))) |
3518 (if assoc-elt | 3507 (if assoc-elt |
3519 (setcdr assoc-elt value)))) | 3508 (setcdr assoc-elt value)))) |
3520 | 3509 |
3521 | 3510 |
3522 ;; must execute in control buf | 3511 ;; must execute in control buf |
3523 (defun ediff-save-protected-variables () | 3512 (defun ediff-save-protected-variables () |
3524 (setq ediff-buffer-values-orig-A | 3513 (setq ediff-buffer-values-orig-A |
3525 (ediff-eval-in-buffer ediff-buffer-A | 3514 (ediff-with-current-buffer ediff-buffer-A |
3526 (ediff-save-variables ediff-protected-variables))) | 3515 (ediff-save-variables ediff-protected-variables))) |
3527 (setq ediff-buffer-values-orig-B | 3516 (setq ediff-buffer-values-orig-B |
3528 (ediff-eval-in-buffer ediff-buffer-B | 3517 (ediff-with-current-buffer ediff-buffer-B |
3529 (ediff-save-variables ediff-protected-variables))) | 3518 (ediff-save-variables ediff-protected-variables))) |
3530 (if ediff-3way-comparison-job | 3519 (if ediff-3way-comparison-job |
3531 (setq ediff-buffer-values-orig-C | 3520 (setq ediff-buffer-values-orig-C |
3532 (ediff-eval-in-buffer ediff-buffer-C | 3521 (ediff-with-current-buffer ediff-buffer-C |
3533 (ediff-save-variables ediff-protected-variables)))) | 3522 (ediff-save-variables ediff-protected-variables)))) |
3534 (if (ediff-buffer-live-p ediff-ancestor-buffer) | 3523 (if (ediff-buffer-live-p ediff-ancestor-buffer) |
3535 (setq ediff-buffer-values-orig-Ancestor | 3524 (setq ediff-buffer-values-orig-Ancestor |
3536 (ediff-eval-in-buffer ediff-ancestor-buffer | 3525 (ediff-with-current-buffer ediff-ancestor-buffer |
3537 (ediff-save-variables ediff-protected-variables))))) | 3526 (ediff-save-variables ediff-protected-variables))))) |
3538 | 3527 |
3539 ;; must execute in control buf | 3528 ;; must execute in control buf |
3540 (defun ediff-restore-protected-variables () | 3529 (defun ediff-restore-protected-variables () |
3541 (let ((values-A ediff-buffer-values-orig-A) | 3530 (let ((values-A ediff-buffer-values-orig-A) |
3542 (values-B ediff-buffer-values-orig-B) | 3531 (values-B ediff-buffer-values-orig-B) |
3543 (values-C ediff-buffer-values-orig-C) | 3532 (values-C ediff-buffer-values-orig-C) |
3544 (values-Ancestor ediff-buffer-values-orig-Ancestor)) | 3533 (values-Ancestor ediff-buffer-values-orig-Ancestor)) |
3545 (ediff-eval-in-buffer ediff-buffer-A | 3534 (ediff-with-current-buffer ediff-buffer-A |
3546 (ediff-restore-variables ediff-protected-variables values-A)) | 3535 (ediff-restore-variables ediff-protected-variables values-A)) |
3547 (ediff-eval-in-buffer ediff-buffer-B | 3536 (ediff-with-current-buffer ediff-buffer-B |
3548 (ediff-restore-variables ediff-protected-variables values-B)) | 3537 (ediff-restore-variables ediff-protected-variables values-B)) |
3549 (if ediff-3way-comparison-job | 3538 (if ediff-3way-comparison-job |
3550 (ediff-eval-in-buffer ediff-buffer-C | 3539 (ediff-with-current-buffer ediff-buffer-C |
3551 (ediff-restore-variables ediff-protected-variables values-C))) | 3540 (ediff-restore-variables ediff-protected-variables values-C))) |
3552 (if (ediff-buffer-live-p ediff-ancestor-buffer) | 3541 (if (ediff-buffer-live-p ediff-ancestor-buffer) |
3553 (ediff-eval-in-buffer ediff-ancestor-buffer | 3542 (ediff-with-current-buffer ediff-ancestor-buffer |
3554 (ediff-restore-variables ediff-protected-variables values-Ancestor))) | 3543 (ediff-restore-variables ediff-protected-variables values-Ancestor))) |
3555 )) | 3544 )) |
3556 | 3545 |
3557 ;; save BUFFER in FILE. used in hooks. | 3546 ;; save BUFFER in FILE. used in hooks. |
3558 (defun ediff-save-buffer-in-file (buffer file) | 3547 (defun ediff-save-buffer-in-file (buffer file) |
3559 (ediff-eval-in-buffer buffer | 3548 (ediff-with-current-buffer buffer |
3560 (write-file file))) | 3549 (write-file file))) |
3561 | 3550 |
3562 | 3551 |
3563 ;;; Debug | 3552 ;;; Debug |
3564 | 3553 |
3696 (run-hooks 'ediff-load-hook) | 3685 (run-hooks 'ediff-load-hook) |
3697 | 3686 |
3698 | 3687 |
3699 ;;; Local Variables: | 3688 ;;; Local Variables: |
3700 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) | 3689 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) |
3701 ;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) | 3690 ;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1) |
3702 ;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body)) | 3691 ;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body)) |
3703 ;;; End: | 3692 ;;; End: |
3704 | 3693 |
3705 ;;; ediff-util.el ends here | 3694 ;;; ediff-util.el ends here |