diff options
author | Michael Kifer <kifer@cs.stonybrook.edu> | 2002-01-08 04:36:01 +0000 |
---|---|---|
committer | Michael Kifer <kifer@cs.stonybrook.edu> | 2002-01-08 04:36:01 +0000 |
commit | 50a07e18565cc4dd7162908197ac71e85c1781d7 (patch) | |
tree | 6f0a68647e226b1c14cf00b75444e9c9d54ad847 /lisp/ediff.el | |
parent | fbb70ad9e6e00f3f146b50d3bf433a6ec6ce26c9 (diff) | |
download | emacs-50a07e18565cc4dd7162908197ac71e85c1781d7.tar.gz |
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
* viper-init.el (viper-cond-compile-for-xemacs-or-emacs):
new macro that replaces viper-emacs-p and viper-xemacs-p in many
cases. Used to reduce the number of warnings.
* viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs.
(viper-standard-value): moved here from viper.el.
(viper-set-unread-command-events): moved to viper-util.el
(viper-check-minibuffer-overlay): make sure
viper-minibuffer-overlay is moved to cover the entire input field.
* viper-util.el: use viper-cond-compile-for-xemacs-or-emacs.
(viper-read-key-sequence, viper-set-unread-command-events,
viper-char-symbol-sequence-p, viper-char-array-p): moved here.
* viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs.
* viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p,
viper-event-vector-p): moved to viper-util.el
* viper.el (viper-standard-value): moved to viper-cmd.el.
Use viper-cond-compile-for-xemacs-or-emacs.
* ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new
macro designed to be used in many places where ediff-emacs-p or
ediff-xemacs-p was previously used. Reduces the number of
warnings.
Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue
of ediff-xemacs-p.
(ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer,
ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p,
ediff-whitespace-diff-region-p, ediff-get-region-contents):
moved to ediff-util.el.
(ediff-event-key): moved here.
* ediff-merge.el: got rid of unreferenced variables.
* ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs.
(ediff-cleanup-mess): improved the way windows are set up after
quitting ediff.
(ediff-janitor): use ediff-dispose-of-variant-according-to-user.
(ediff-dispose-of-variant-according-to-user): new function
designed to be smarter and also understands indirect buffers.
(ediff-highlight-diff-in-one-buffer,
ediff-unhighlight-diff-in-one-buffer,
ediff-unhighlight-diffs-totally-in-one-buffer,
ediff-highlight-diff, ediff-highlight-diff,
ediff-unhighlight-diff, ediff-unhighlight-diffs-totally,
ediff-empty-diff-region-p, ediff-whitespace-diff-region-p,
ediff-get-region-contents, ediff-make-current-diff-overlay):
moved here.
(ediff-format-bindings-of): new function by Hannu Koivisto
<azure@iki.fi>.
(ediff-setup): make sure the merge buffer is always widened and
modifiable.
(ediff-write-merge-buffer-and-maybe-kill): refuse to write the
result of a merge into a file visited by another buffer.
(ediff-arrange-autosave-in-merge-jobs): check if the merge file
is visited by another buffer and ask to save/delete that buffer.
(ediff-verify-file-merge-buffer): new function to do the above.
* ediff-vers.el: load ediff-init.el at compile time.
* ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs.
* ediff.el (ediff-windows, ediff-regions-wordwise,
ediff-regions-linewise): use indirect buffers to improve
robustness and make it possible to compare regions of the same
buffer (even overlapping regions).
(ediff-clone-buffer-for-region-comparison,
ediff-clone-buffer-for-window-comparison): new functions.
(ediff-files-internal): refuse to compare identical files.
(ediff-regions-internal): get rid of the warning about comparing
regions of the same buffer.
* ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here.
Plus the following fixes courtesy of Dave Love:
Doc fixes.
(ediff-word-1): Use word class and move - to the
front per regexp documentation.
(ediff-wordify): Bind forward-word-function outside loop.
(ediff-copy-to-buffer): Use insert-buffer-substring rather than
consing buffer contents.
(ediff-goto-word): Move syntax table setting outside loop.
Diffstat (limited to 'lisp/ediff.el')
-rw-r--r-- | lisp/ediff.el | 130 |
1 files changed, 91 insertions, 39 deletions
diff --git a/lisp/ediff.el b/lisp/ediff.el index a170d4b1a99..24698441c08 100644 --- a/lisp/ediff.el +++ b/lisp/ediff.el @@ -1,13 +1,13 @@ ;;; ediff.el --- a comprehensive visual interface to diff & patch -;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01 Free Software Foundation, Inc. +;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02 Free Software Foundation, Inc. -;; Author: Michael Kifer <kifer@cs.sunysb.edu> +;; Author: Michael Kifer <kifer@cs.stonybrook.edu> ;; Created: February 2, 1994 ;; Keywords: comparing, merging, patching, tools, unix -(defconst ediff-version "2.76" "The current version of Ediff") -(defconst ediff-date "July 18, 2001" "Date of last update") +(defconst ediff-version "2.76.1" "The current version of Ediff") +(defconst ediff-date "January 4, 2002" "Date of last update") ;; This file is part of GNU Emacs. @@ -172,7 +172,7 @@ (let ((current (dired-get-filename nil 'no-error)) (marked (condition-case nil (dired-get-marked-files 'no-dir) - (error))) + (error nil))) aux-list choices result) (or (integerp fileno) (setq fileno 0)) (if (stringp default) @@ -199,8 +199,10 @@ default-directory)) dir-B f) (list (setq f (ediff-read-file-name - "File A to compare" dir-A - (ediff-get-default-file-name))) + "File A to compare" + dir-A + (ediff-get-default-file-name) + 'no-dirs)) (ediff-read-file-name "File B to compare" (setq dir-B (if ediff-use-last-dir @@ -233,8 +235,10 @@ default-directory)) dir-B dir-C f ff) (list (setq f (ediff-read-file-name - "File A to compare" dir-A - (ediff-get-default-file-name))) + "File A to compare" + dir-A + (ediff-get-default-file-name) + 'no-dirs)) (setq ff (ediff-read-file-name "File B to compare" (setq dir-B (if ediff-use-last-dir @@ -332,6 +336,11 @@ (defun ediff-files-internal (file-A file-B file-C startup-hooks job-name &optional merge-buffer-file) (let (buf-A buf-B buf-C) + (if (string= file-A file-B) + (error "Files A and B are the same")) + (if (stringp file-C) + (or (and (string= file-A file-C) (error "Files A and C are the same")) + (and (string= file-B file-C) (error "Files B and C are the same")))) (message "Reading file %s ... " file-A) ;;(sit-for 0) (ediff-find-file 'file-A 'buf-A 'ediff-last-dir-A 'startup-hooks) @@ -828,14 +837,59 @@ If WIND-B is nil, use window next to WIND-A." (select-window wind-B) (setq beg-B (window-start) end-B (window-end)))) + (setq buffer-A + (ediff-clone-buffer-for-window-comparison + buffer-A wind-A "-Window1-") + buffer-B + (ediff-clone-buffer-for-window-comparison + buffer-B wind-B "-Window2-")) (ediff-regions-internal buffer-A beg-A end-A buffer-B beg-B end-B startup-hooks job-name word-mode nil))) +;; Suggested by Hannu Koivisto <azure@iki.fi> +(defun ediff-clone-buffer-for-region-comparison (buff-name region-name) + (let ((cloned-buff (ediff-make-indirect-buffer + buff-name + (concat buff-name region-name + (symbol-name (gensym))))) + (wind (ediff-get-visible-buffer-window buff-name))) + (ediff-with-current-buffer cloned-buff + (setq ediff-temp-indirect-buffer t)) + (if (window-live-p wind) + (set-window-buffer wind cloned-buff)) + (pop-to-buffer cloned-buff) + (message + "Mark a region in buffer %s; then type %s. Use %s to abort." + (buffer-name cloned-buff) + (ediff-format-bindings-of 'exit-recursive-edit) + (ediff-format-bindings-of 'abort-recursive-edit)) + (recursive-edit) + cloned-buff)) + +(defun ediff-clone-buffer-for-window-comparison (buff wind region-name) + (let ((cloned-buff (ediff-make-indirect-buffer + buff + (concat (buffer-name buff) + region-name (symbol-name (gensym)))))) + (ediff-with-current-buffer cloned-buff + (setq ediff-temp-indirect-buffer t)) + (set-window-buffer wind cloned-buff) + cloned-buff)) + +(defun ediff-make-indirect-buffer (base-buf indirect-buf-name) + (ediff-cond-compile-for-xemacs-or-emacs + (make-indirect-buffer base-buf indirect-buf-name) ; xemacs + (make-indirect-buffer base-buf indirect-buf-name 'clone) ; emacs + )) + ;;;###autoload (defun ediff-regions-wordwise (buffer-A buffer-B &optional startup-hooks) - "Run Ediff on a pair of regions in two different buffers. -Regions \(i.e., point and mark\) are assumed to be set in advance. + "Run Ediff on a pair of regions in specified buffers. +Regions \(i.e., point and mark\) are assumed to be set in advance except +for the second region in the case both regions are from the same buffer. +In such a case the user is asked to interactively establish the second +region. This function is effective only for relatively small regions, up to 200 lines. For large regions, use `ediff-regions-linewise'." (interactive @@ -855,7 +909,11 @@ lines. For large regions, use `ediff-regions-linewise'." (error "Buffer %S doesn't exist" buffer-B)) - (let (reg-A-beg reg-A-end reg-B-beg reg-B-end) + (let ((buffer-A + (ediff-clone-buffer-for-region-comparison buffer-A "-Region1-")) + (buffer-B + (ediff-clone-buffer-for-region-comparison buffer-B "-Region2-")) + reg-A-beg reg-A-end reg-B-beg reg-B-end) (save-excursion (set-buffer buffer-A) (setq reg-A-beg (region-beginning) @@ -871,8 +929,11 @@ lines. For large regions, use `ediff-regions-linewise'." ;;;###autoload (defun ediff-regions-linewise (buffer-A buffer-B &optional startup-hooks) - "Run Ediff on a pair of regions in two different buffers. -Regions \(i.e., point and mark\) are assumed to be set in advance. + "Run Ediff on a pair of regions in specified buffers. +Regions \(i.e., point and mark\) are assumed to be set in advance except +for the second region in the case both regions are from the same buffer. +In such a case the user is asked to interactively establish the second +region. Each region is enlarged to contain full lines. This function is effective for large regions, over 100-200 lines. For small regions, use `ediff-regions-wordwise'." @@ -892,7 +953,11 @@ lines. For small regions, use `ediff-regions-wordwise'." (if (not (ediff-buffer-live-p buffer-B)) (error "Buffer %S doesn't exist" buffer-B)) - (let (reg-A-beg reg-A-end reg-B-beg reg-B-end) + (let ((buffer-A + (ediff-clone-buffer-for-region-comparison buffer-A "-Region1-")) + (buffer-B + (ediff-clone-buffer-for-region-comparison buffer-B "-Region2-")) + reg-A-beg reg-A-end reg-B-beg reg-B-end) (save-excursion (set-buffer buffer-A) (setq reg-A-beg (region-beginning) @@ -941,25 +1006,6 @@ lines. For small regions, use `ediff-regions-wordwise'." (setq beg-B (move-marker (make-marker) beg-B) end-B (move-marker (make-marker) end-B))) - (if (and (eq buffer-A buffer-B) - (or (and (< beg-A end-B) (<= beg-B beg-A)) ; b-B b-A e-B - (and (< beg-B end-A) (<= end-A end-B)))) ; b-B e-A e-B - (progn - (with-output-to-temp-buffer ediff-msg-buffer - (ediff-with-current-buffer standard-output - (fundamental-mode)) - (princ " -You have requested to compare overlapping regions of the same buffer. - -In this case, Ediff's highlighting may be confusing---in the same window, -you may see highlighted regions that belong to different regions. - -Continue anyway? (y/n) ")) - - (if (y-or-n-p "Continue anyway? ") - () - (error "%S aborted" job-name)))) - ;; make file-A (if word-mode (ediff-wordify beg-A end-A buffer-A tmp-buffer) @@ -1011,8 +1057,10 @@ Continue anyway? (y/n) ")) default-directory)) dir-B f) (list (setq f (ediff-read-file-name - "File A to merge" dir-A - (ediff-get-default-file-name))) + "File A to merge" + dir-A + (ediff-get-default-file-name) + 'no-dirs)) (ediff-read-file-name "File B to merge" (setq dir-B (if ediff-use-last-dir @@ -1053,8 +1101,10 @@ Continue anyway? (y/n) ")) default-directory)) dir-B dir-ancestor f ff) (list (setq f (ediff-read-file-name - "File A to merge" dir-A - (ediff-get-default-file-name))) + "File A to merge" + dir-A + (ediff-get-default-file-name) + 'no-dirs)) (setq ff (ediff-read-file-name "File B to merge" (setq dir-B (if ediff-use-last-dir @@ -1221,6 +1271,7 @@ buffer." (intern (format "ediff-%S-merge-internal" ediff-version-control-package)) rev1 rev2 ancestor-rev startup-hooks merge-buffer-file))) +;; MK: Check. This function doesn't seem to be used any more by pcvs or pcl-cvs ;;;###autoload (defun run-ediff-from-cvs-buffer (pos) "Run Ediff-merge on appropriate revisions of the selected file. @@ -1306,7 +1357,8 @@ Uses `vc.el' or `rcs.el' depending on `ediff-version-control-package'." (if ediff-use-last-dir ediff-last-dir-A default-directory) - (ediff-get-default-file-name)))) + (ediff-get-default-file-name) + 'no-dirs))) (find-file file) (if (and (buffer-modified-p) (y-or-n-p (message "Buffer %s is modified. Save buffer? " |