diff options
author | Michael Kifer <kifer@cs.stonybrook.edu> | 2005-02-19 04:46:24 +0000 |
---|---|---|
committer | Michael Kifer <kifer@cs.stonybrook.edu> | 2005-02-19 04:46:24 +0000 |
commit | 17561e4ffa9a46cf3149cd299cc7e4a5354007b7 (patch) | |
tree | 2e54ef22cdc4f99ed116f18f226c27f53c7d86c1 /lisp | |
parent | 91c212f159577c0be32ec8fcc1f8e6a23777ee6d (diff) | |
download | emacs-17561e4ffa9a46cf3149cd299cc7e4a5354007b7.tar.gz |
* ediff.el (ediff-set-diff-overlays-in-one-buffer,
ediff-set-fine-overlays-in-one-buffer,ediff-goto-word) make sure
we use the syntax table of the correct buffer.
(ediff-same-file-contents,ediff-same-contents): enhancements thanks to
Felix Gatzemeier.
* ediff-init.el (ediff-hide-face): checks for definedness of functions.
(ediff-file-remote-p): make synonymous with file-remote-p.
In all deffaces ediff-*-face-*, use min-colors.
* ediff-mult.el (ediff-meta-mark-equal-files): make use of
ediff-recurse-to-subdirectories.
(ediff-mark-if-equal): check that the arguments are strings, use
ediff-same-contents (after to Felix Gatzemeier).
* ediff.el (ediff-merge-on-startup): don't set buffer-modified-p to
nil.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ChangeLog | 20 | ||||
-rw-r--r-- | lisp/ediff-diff.el | 84 | ||||
-rw-r--r-- | lisp/ediff-init.el | 10 | ||||
-rw-r--r-- | lisp/ediff-mult.el | 17 | ||||
-rw-r--r-- | lisp/ediff.el | 13 |
5 files changed, 114 insertions, 30 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7207d267f2c..1a162ee9168 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,23 @@ +2005-02-19 Michael Kifer <kifer@cs.stonybrook.edu> + + * ediff.el (ediff-set-diff-overlays-in-one-buffer, + ediff-set-fine-overlays-in-one-buffer,ediff-goto-word) make sure + we use the syntax table of the correct buffer. + (ediff-same-file-contents,ediff-same-contents): enhancements thanks to + Felix Gatzemeier. + + * ediff-init.el (ediff-hide-face): checks for definedness of functions. + (ediff-file-remote-p): make synonymous with file-remote-p. + In all deffaces ediff-*-face-*, use min-colors. + + * ediff-mult.el (ediff-meta-mark-equal-files): make use of + ediff-recurse-to-subdirectories. + (ediff-mark-if-equal): check that the arguments are strings, use + ediff-same-contents (after to Felix Gatzemeier). + + * ediff.el (ediff-merge-on-startup): don't set buffer-modified-p to + nil. + 2005-02-18 Stefan Monnier <monnier@iro.umontreal.ca> * log-view.el (log-view-message-re): Fix up Subversion regexp. diff --git a/lisp/ediff-diff.el b/lisp/ediff-diff.el index 4ba4ab316f8..c41d733aaca 100644 --- a/lisp/ediff-diff.el +++ b/lisp/ediff-diff.el @@ -534,6 +534,7 @@ one optional arguments, diff-number to refine.") (defun ediff-set-diff-overlays-in-one-buffer (buf-type diff-list) (let* ((current-diff -1) (buff (ediff-get-buffer buf-type)) + (ctl-buf ediff-control-buffer) ;; ediff-extract-diffs puts the type of diff-list as the first elt ;; of this list. The type is either 'points or 'words (diff-list-type (car diff-list)) @@ -580,8 +581,9 @@ one optional arguments, diff-number to refine.") (if (eq diff-list-type 'words) (progn (ediff-with-current-buffer buff (goto-char pt-saved)) - (setq begin (ediff-goto-word (1+ begin) buff) - end (ediff-goto-word end buff 'end)) + (ediff-with-current-buffer ctl-buf + (setq begin (ediff-goto-word (1+ begin) buff) + end (ediff-goto-word end buff 'end))) (if (> end limit) (setq end limit)) (if (> begin end) (setq begin end)) (setq pt-saved (ediff-with-current-buffer buff (point))))) @@ -864,6 +866,7 @@ delimiter regions")) (let* ((current-diff -1) (reg-start (ediff-get-diff-posn buf-type 'beg region-num)) (buff (ediff-get-buffer buf-type)) + (ctl-buf ediff-control-buffer) combined-merge-diff-list diff-overlay-list list-element begin end overlay) @@ -892,8 +895,9 @@ delimiter regions")) () ; skip this diff ;; Put overlays at appropriate places in buffers ;; convert lines to points, if necessary - (setq begin (ediff-goto-word (1+ begin) buff) - end (ediff-goto-word end buff 'end)) + (ediff-with-current-buffer ctl-buf + (setq begin (ediff-goto-word (1+ begin) buff) + end (ediff-goto-word end buff 'end))) (setq overlay (ediff-make-bullet-proof-overlay begin end buff)) ;; record all overlays for this difference region (setq diff-overlay-list (nconc diff-overlay-list (list overlay)))) @@ -1326,17 +1330,73 @@ arguments to `skip-chars-forward'." (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)) + (setq n (1- n))) + (if (and flag (> n 0)) + (funcall fwd-word-fun))) (point)))) (defun ediff-same-file-contents (f1 f2) - "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)))) + "Return t if files F1 and F2 have identical contents." + (if (and (not (file-directory-p f1)) + (not (file-directory-p f2))) + (let ((res + (apply 'call-process ediff-cmp-program nil nil nil + (append ediff-cmp-options (list f1 f2))))) + (and (numberp res) (eq res 0)))) + ) + + +(defun ediff-same-contents (d1 d2 &optional filter-re) + "Returns t iff D1 and D2 have the same content. +D1 and D2 can either be both directories or both regular files. +Symlinks and the likes are not handled. +If FILTER-RE is non-nil, recursive checking in directories +affects only files whose names match the expression." + ;; Normalize empty filter RE to nil. + (unless (length filter-re) (setq filter-re nil)) + ;; Indicate progress + (message "Comparing '%s' and '%s' modulo '%s'" d1 d2 filter-re) + (cond + ;; D1 & D2 directories => recurse + ((and (file-directory-p d1) + (file-directory-p d2)) + (if (null ediff-recurse-to-subdirectories) + (if (y-or-n-p "Compare subdirectories recursively? ") + (setq ediff-recurse-to-subdirectories 'yes) + (setq ediff-recurse-to-subdirectories 'no))) + (if (eq ediff-recurse-to-subdirectories 'yes) + (let* ((all-entries-1 (directory-files d1 t filter-re)) + (all-entries-2 (directory-files d2 t filter-re)) + (entries-1 (remove-if (lambda (s) + (string-match "^\\.\\.?$" + (file-name-nondirectory s))) + all-entries-1)) + (entries-2 (remove-if (lambda (s) + (string-match "^\\.\\.?$" + (file-name-nondirectory s))) + all-entries-2)) + ) + ;; First, check only the names (works quickly and ensures a + ;; precondition for subsequent code) + (if (and (= (length entries-1) (length entries-2)) + (every (lambda (a b) (equal (file-name-nondirectory a) + (file-name-nondirectory b))) + entries-1 entries-2)) + ;; With name equality established, compare the entries + ;; through recursion. + (every (lambda (a b) + (ediff-same-contents a b filter-re)) + entries-1 entries-2) + ) + )) + ) ; end of the directories case + ;; D1 & D2 are both files => compare directly + ((and (file-regular-p d1) + (file-regular-p d2)) + (ediff-same-file-contents d1 d2)) + ;; Otherwise => false: unequal contents + ) + ) ;;; Local Variables: diff --git a/lisp/ediff-init.el b/lisp/ediff-init.el index 80beb4a872d..46e94e935f7 100644 --- a/lisp/ediff-init.el +++ b/lisp/ediff-init.el @@ -895,7 +895,8 @@ to temp files when Ediff needs to find fine differences." (sit-for 1))))) (defun ediff-hide-face (face) - (if (and (ediff-has-face-support-p) (boundp 'add-to-list) + (if (and (ediff-has-face-support-p) + (boundp 'add-to-list) (boundp 'facemenu-unlisted-faces)) (add-to-list 'facemenu-unlisted-faces face))) @@ -1404,7 +1405,7 @@ This property can be toggled interactively." ;;; Misc ;; if nil, this silences some messages -(defvar ediff-verbose-p t) +(defconst ediff-verbose-p t) (defcustom ediff-autostore-merges 'group-jobs-only "*Save the results of merge jobs automatically. @@ -1473,11 +1474,8 @@ This default should work without changes." (ediff-defvar-local ediff-temp-file-C nil "") -;; If file-remote-p is defined (as in XEmacs, use it. Otherwise, check -;; if find-file-name-handler is defined for 'file-local-copy (defun ediff-file-remote-p (file-name) - (or (and (fboundp 'file-remote-p) (file-remote-p file-name)) - (find-file-name-handler file-name 'file-local-copy))) + (file-remote-p file-name)) ;; File for which we can get attributes, such as size or date (defun ediff-listable-file (file-name) diff --git a/lisp/ediff-mult.el b/lisp/ediff-mult.el index cf6edc2d129..41a7699cfdc 100644 --- a/lisp/ediff-mult.el +++ b/lisp/ediff-mult.el @@ -1,6 +1,6 @@ ;;; ediff-mult.el --- support for multi-file/multi-buffer processing in Ediff -;; Copyright (C) 1995, 96, 97, 98, 99, 2000, 01, 02 Free Software Foundation, Inc. +;; Copyright (C) 1995, 96, 97, 98, 99, 2000, 01, 02, 05 Free Software Foundation, Inc. ;; Author: Michael Kifer <kifer@cs.stonybrook.edu> @@ -167,6 +167,9 @@ directories.") ;; buffer used to collect custom diffs from individual sessions in the group (ediff-defvar-local ediff-meta-diff-buffer nil "") +;; t means recurse into subdirs when deciding which files have same contents +(ediff-defvar-local ediff-recurse-to-subdirectories nil "") + ;; history var to use for filtering groups of files (defvar ediff-filtering-regexp-history nil "") @@ -2349,6 +2352,7 @@ last-command-char is used to decide which action to take." )) (setq list (cdr list))) (message "Comparing files ... Done")) + (setq ediff-recurse-to-subdirectories nil) (ediff-update-meta-buffer (current-buffer) 'must-redraw)) ;; mark files 1 and 2 as equal, if they are. @@ -2356,12 +2360,11 @@ last-command-char is used to decide which action to take." (defun ediff-mark-if-equal (fileinfo1 fileinfo2) (let ((f1 (car fileinfo1)) (f2 (car fileinfo2))) - (cond ((file-directory-p f1) nil) - ((file-directory-p f2) nil) - ((ediff-same-file-contents f1 f2) - (ediff-set-file-eqstatus fileinfo1 t) - (ediff-set-file-eqstatus fileinfo2 t) - t)) + (if (and (stringp f1) (stringp f2) (ediff-same-contents f1 f2)) + (progn + (ediff-set-file-eqstatus fileinfo1 t) + (ediff-set-file-eqstatus fileinfo2 t) + )) )) diff --git a/lisp/ediff.el b/lisp/ediff.el index c98974923f1..2a2b481ec59 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, 02, 03 Free Software Foundation, Inc. +;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02, 03, 05 Free Software Foundation, Inc. ;; Author: Michael Kifer <kifer@cs.stonybrook.edu> ;; Created: February 2, 1994 ;; Keywords: comparing, merging, patching, tools, unix -(defconst ediff-version "2.78" "The current version of Ediff") -(defconst ediff-date "May 18, 2003" "Date of last update") +(defconst ediff-version "2.80" "The current version of Ediff") +(defconst ediff-date "February 19, 2005" "Date of last update") ;; This file is part of GNU Emacs. @@ -1080,8 +1080,11 @@ lines. For small regions, use `ediff-regions-wordwise'." (defsubst ediff-merge-on-startup () (ediff-do-merge 0) - (ediff-with-current-buffer ediff-buffer-C - (set-buffer-modified-p nil))) + ;; Can't remember why this is here, but it may cause the automatically merged + ;; buffer to be lost. So, keep the buffer modified. + ;;(ediff-with-current-buffer ediff-buffer-C + ;; (set-buffer-modified-p nil)) + ) ;;;###autoload (defun ediff-merge-files (file-A file-B |