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-diff.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-diff.el')
-rw-r--r-- | lisp/ediff-diff.el | 127 |
1 files changed, 67 insertions, 60 deletions
diff --git a/lisp/ediff-diff.el b/lisp/ediff-diff.el index df3d7d203bb..7815e632502 100644 --- a/lisp/ediff-diff.el +++ b/lisp/ediff-diff.el @@ -1,8 +1,8 @@ ;;; ediff-diff.el --- diff-related utilities -;; Copyright (C) 1994, 1995, 1996, 1997 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> ;; This file is part of GNU Emacs. @@ -29,6 +29,7 @@ ;; compiler pacifier (defvar ediff-default-variant) +(defvar null-device) (eval-when-compile (let ((load-path (cons (expand-file-name ".") load-path))) @@ -83,13 +84,13 @@ Must produce output compatible with Unix's diff3 program." ;; make sure that mandatory options are added even if the user changes ;; ediff-diff-options or ediff-diff3-options in the customization widget (defun ediff-reset-diff-options (symb val) - (let* ((diff-program - (if (eq symb 'ediff-diff-options) + (let* ((diff-program + (if (eq symb 'ediff-diff-options) ediff-diff-program ediff-diff3-program)) (mandatory-option (ediff-diff-mandatory-option diff-program)) (spacer (if (string-equal mandatory-option "") "" " "))) - (set symb + (set symb (if (string-match mandatory-option val) val (concat mandatory-option spacer val))) @@ -102,11 +103,12 @@ Must produce output compatible with Unix's diff3 program." shell-file-name) ; no standard name on MS-DOS ((memq system-type '(vax-vms axp-vms)) "*dcl*") ; VMS (t "sh")) ; UNIX - "*The shell used to run diff and patch. If user's .profile or -.cshrc files are set up correctly, any shell will do. However, some people -set $prompt or other things incorrectly, which leads to undesirable output -messages. These may cause Ediff to fail. In such a case, set ediff-shell -to a shell that you are not using or, better, fix your shell's startup file." + "*The shell used to run diff and patch. +If user's .profile or .cshrc files are set up correctly, any shell +will do. However, some people set $prompt or other things +incorrectly, which leads to undesirable output messages. These may +cause Ediff to fail. In such a case, set `ediff-shell' to a shell that +you are not using or, better, fix your shell's startup file." :type 'string :group 'ediff-diff) @@ -119,13 +121,13 @@ It must return code 0, if its arguments are identical files." (defcustom ediff-cmp-options nil "*Options to pass to `ediff-cmp-program'. If GNU diff is used as `ediff-cmp-program', then the most useful options -are `-I RE', to ignore changes whose lines all match the regexp RE." +are `-I REGEXP', to ignore changes whose lines match the REGEXP." :type '(repeat string) :group 'ediff-diff) (defcustom ediff-diff-options "" "*Options to pass to `ediff-diff-program'. -If diff\(1\) is used as `ediff-diff-program', then the most useful options are +If Unix diff is used as `ediff-diff-program', then the most useful options are `-w', to ignore space, and `-i', to ignore case of letters. At present, the option `-c' is not allowed." :set 'ediff-reset-diff-options @@ -146,7 +148,7 @@ This output is not used by Ediff internally." (defvar ediff-match-diff3-line "^====\\(.?\\)\C-m?$" "Pattern to match lines produced by diff3 that describe differences.") -(defcustom ediff-diff3-options "" +(defcustom ediff-diff3-options "" "*Options to pass to `ediff-diff3-program'." :set 'ediff-reset-diff-options :type 'string @@ -163,7 +165,7 @@ Lines that do not match are assumed to be error messages." (ediff-defvar-local ediff-diff-status "" "") -;;; Fine differences +;;; Fine differences (ediff-defvar-local ediff-auto-refine (if (ediff-has-face-support-p) 'on 'nix) "If `on', Ediff auto-highlights fine diffs for the current diff region. @@ -183,7 +185,7 @@ Use `setq-default' if setting it in .emacs") ;;; General -(defvar ediff-diff-ok-lines-regexp +(defvar ediff-diff-ok-lines-regexp (concat "^\\(" "[0-9,]+[acd][0-9,]+\C-m?$" @@ -348,7 +350,7 @@ one optional arguments, diff-number to refine.") (ediff-skip-unsuitable-frames) (switch-to-buffer error-buf) (ediff-kill-buffer-carefully ctl-buf) - (error "Errors in diff output. Diff output is in %S" diff-buff)))) + (error "Errors in diff output. Diff output is in %S" diff-buff)))) ;; BOUNDS specifies visibility bounds to use. ;; WORD-MODE tells whether we are in the word-mode or not. @@ -374,7 +376,7 @@ one optional arguments, diff-number to refine.") (setq shift-A (ediff-overlay-start (ediff-get-value-according-to-buffer-type 'A bounds)) - shift-B + shift-B (ediff-overlay-start (ediff-get-value-according-to-buffer-type 'B bounds)))) @@ -430,7 +432,7 @@ one optional arguments, diff-number to refine.") ;; compute main diff vector (if word-mode ;; make diff-list contain word numbers - (setq diff-list + (setq diff-list (nconc diff-list (list (if (ediff-buffer-live-p C-buffer) @@ -474,7 +476,7 @@ one optional arguments, diff-number to refine.") (forward-line (- c-end c-begin)) (setq c-end-pt (point) c-prev c-end))) - (setq diff-list + (setq diff-list (nconc diff-list (list @@ -495,7 +497,7 @@ one optional arguments, diff-number to refine.") nil nil ; dummy ancestor nil nil ; dummy state of diff & merge nil ; dummy state of ancestor - ))) + ))) ))) ))) ; end ediff-with-current-buffer @@ -538,7 +540,7 @@ one optional arguments, diff-number to refine.") (ediff-get-value-according-to-buffer-type buf-type ediff-narrow-bounds))) (limit (ediff-overlay-end - (ediff-get-value-according-to-buffer-type + (ediff-get-value-according-to-buffer-type buf-type ediff-narrow-bounds))) diff-overlay-list list-element total-diffs begin end pt-saved overlay state-of-diff) @@ -615,7 +617,7 @@ one optional arguments, diff-number to refine.") ;; if `flag' is 'noforce then make fine-diffs only if this region's fine ;; diffs have not been computed before. ;; if `flag' is 'skip then don't compute fine diffs for this region. -(defun ediff-make-fine-diffs (&optional n flag) +(defun ediff-make-fine-diffs (&optional n flag) (or n (setq n ediff-current-difference)) (if (< ediff-number-of-differences 1) @@ -651,13 +653,13 @@ one optional arguments, diff-number to refine.") (if ediff-3way-comparison-job (ediff-message-if-verbose "Region %d is empty in all buffers but %S" - (1+ n) + (1+ n) (cond ((not empty-A) 'A) ((not empty-B) 'B) ((not empty-C) 'C))) (ediff-message-if-verbose "Region %d in buffer %S is empty" - (1+ n) + (1+ n) (cond (empty-A 'A) (empty-B 'B) (empty-C 'C))) @@ -772,7 +774,7 @@ one optional arguments, diff-number to refine.") "in buffers A & C") (whitespace-C (ediff-mark-diff-as-space-only n 'C) "in buffers A & B")))) - (t + (t (ediff-mark-diff-as-space-only n nil))) ) ) ; end cond @@ -812,7 +814,7 @@ one optional arguments, diff-number to refine.") (defun ediff-set-fine-diff-properties-in-one-buffer (buf-type n &optional default) (let ((fine-diff-vector (ediff-get-fine-diff-vector n buf-type)) - (face (if default + (face (if default 'default (face-name (ediff-get-symbol-from-alist @@ -896,11 +898,19 @@ delimiter regions")) ) ; while ;; convert the list of difference information into a vector ;; for fast access - (ediff-set-fine-diff-vector + (ediff-set-fine-diff-vector region-num buf-type (vconcat diff-overlay-list)) ))) +(defsubst ediff-convert-fine-diffs-to-overlays (diff-list region-num) + (ediff-set-fine-overlays-in-one-buffer 'A diff-list region-num) + (ediff-set-fine-overlays-in-one-buffer 'B diff-list region-num) + (if ediff-3way-job + (ediff-set-fine-overlays-in-one-buffer 'C diff-list region-num) + )) + + ;; Stolen from emerge.el (defun ediff-get-diff3-group (file) ;; This save-excursion allows ediff-get-diff3-group to be called for the @@ -958,10 +968,10 @@ delimiter regions")) (setq shift-A (ediff-overlay-start (ediff-get-value-according-to-buffer-type 'A bounds)) - shift-B + shift-B (ediff-overlay-start (ediff-get-value-according-to-buffer-type 'B bounds)) - shift-C + shift-C (if three-way-comp (ediff-overlay-start (ediff-get-value-according-to-buffer-type 'C bounds))))) @@ -1026,7 +1036,7 @@ delimiter regions")) ;; compute main diff vector (if word-mode ;; make diff-list contain word numbers - (setq diff-list + (setq diff-list (nconc diff-list (list (vector (- a-begin a-prev) (- a-end a-begin) @@ -1066,7 +1076,7 @@ delimiter regions")) (forward-line (- c-or-anc-end c-or-anc-begin)) (setq anc-end-pt (point) anc-prev c-or-anc-end))) - (setq diff-list + (setq diff-list (nconc diff-list ;; if comparing with ancestor, then there also is a @@ -1200,7 +1210,7 @@ delimiter regions")) (delete-process process)))) -;;; Word functions used to refine the current diff +;;; Word functions used to refine the current diff (defvar ediff-forward-word-function 'ediff-forward-word "*Function to call to move to the next word. @@ -1210,10 +1220,11 @@ Used for splitting difference regions into individual words.") "*Characters constituting white space. These characters are ignored when differing regions are split into words.") -(defvar ediff-word-1 "a-zA-Z---_" +(defvar ediff-word-1 + (ediff-cond-compile-for-xemacs-or-emacs "a-zA-Z---_" "-[:word:]_") "*Characters that constitute words of type 1. More precisely, [ediff-word-1] is a regexp that matches type 1 words. -See `ediff-forward-word' for more details.") +See `ediff-forward-word' for more details.") (defvar ediff-word-2 "0-9.," "*Characters that constitute words of type 2. @@ -1229,7 +1240,7 @@ See `ediff-forward-word' for more details.") (concat "^" ediff-word-1 ediff-word-2 ediff-word-3 ediff-whitespace) "*Characters that constitute words of type 4. More precisely, [ediff-word-4] is a regexp that matches type 4 words. -See `ediff-forward-word' for more details.") +See `ediff-forward-word' for more details.") ;; Split region along word boundaries. Each word will be on its own line. ;; Output to buffer out-buffer. @@ -1249,7 +1260,14 @@ arguments to `skip-chars-forward'." (defun ediff-wordify (beg end in-buffer out-buffer &optional control-buf) - (let (inbuf-syntax-tbl sv-point diff-string) + (let ((forward-word-function + ;; eval in control buf to let user create local versions for + ;; different invocations + (if control-buf + (ediff-with-current-buffer control-buf + ediff-forward-word-function) + ediff-forward-word-function)) + inbuf-syntax-tbl sv-point diff-string) (save-excursion (set-buffer in-buffer) (setq inbuf-syntax-tbl @@ -1271,29 +1289,18 @@ arguments to `skip-chars-forward'." (delete-region (point-min) (point)) (while (not (eobp)) - ;; eval in control buf to let user create local versions for - ;; different invocations - (if control-buf - (funcall - (ediff-with-current-buffer control-buf - ediff-forward-word-function)) - (funcall ediff-forward-word-function)) + (funcall forward-word-function) (setq sv-point (point)) (skip-chars-forward ediff-whitespace) (delete-region sv-point (point)) (insert "\n"))))) -;; copy string from BEG END from IN-BUF to OUT-BUF +;; copy string specified as BEG END from IN-BUF to OUT-BUF (defun ediff-copy-to-buffer (beg end in-buffer out-buffer) - (let (string) - (save-excursion - (set-buffer in-buffer) - (setq string (buffer-substring beg end)) - - (set-buffer out-buffer) - (erase-buffer) - (insert string) - (goto-char (point-min))))) + (with-current-buffer out-buffer + (erase-buffer) + (insert-buffer-substring in-buffer beg end) + (goto-char (point-min)))) ;; goto word #n starting at current position in buffer `buf' @@ -1305,18 +1312,18 @@ arguments to `skip-chars-forward'." (syntax-tbl ediff-syntax-table)) (ediff-with-current-buffer buf (skip-chars-forward ediff-whitespace) - (while (> n 1) - (ediff-with-syntax-table syntax-tbl - (funcall fwd-word-fun)) - (skip-chars-forward ediff-whitespace) - (setq n (1- n))) + (ediff-with-syntax-table syntax-tbl + (while (> n 1) + (funcall fwd-word-fun) + (skip-chars-forward ediff-whitespace) + (setq n (1- n)))) (if (and flag (> n 0)) (funcall fwd-word-fun)) (point)))) (defun ediff-same-file-contents (f1 f2) - "T if F1 and F2 have identical contents." - (let ((res + "Return t if F1 and F2 have identical contents." + (let ((res (apply 'call-process ediff-cmp-program nil nil nil (append ediff-cmp-options (list f1 f2))))) (and (numberp res) (eq res 0)))) |