]> code.delx.au - gnu-emacs/blobdiff - lisp/ediff-mult.el
(calc-embedded-make-info): Use `math-read-expr' when
[gnu-emacs] / lisp / ediff-mult.el
index a89902e8d3d24c9e9ee975866dc9de0ef21086ee..0bbd3298c7a0538a33f67473fdc8c5112eaaf3c0 100644 (file)
@@ -1,6 +1,7 @@
 ;;; 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, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+;;   2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 
@@ -18,8 +19,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
 
 ;;; Code:
 
-(provide 'ediff-mult)
 
 (defgroup ediff-mult nil
-  "Multi-file and multi-buffer processing in Ediff"
+  "Multi-file and multi-buffer processing in Ediff."
   :prefix "ediff-"
   :group 'ediff)
 
 ;; end pacifier
 
 (require 'ediff-init)
-(require 'ediff-util)
 
 ;; meta-buffer
 (ediff-defvar-local ediff-meta-buffer nil "")
@@ -167,12 +166,15 @@ 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 "")
 
 (defcustom ediff-default-filtering-regexp nil
   "The default regular expression used as a filename filter in multifile comparisons.
-Should be a sexp. For instance (car ediff-filtering-regexp-history) or nil."
+Should be a sexp.  For instance (car ediff-filtering-regexp-history) or nil."
   :type 'sexp
   :group 'ediff-mult)
 
@@ -200,8 +202,14 @@ Should be a sexp. For instance (car ediff-filtering-regexp-history) or nil."
 (defcustom ediff-meta-truncate-filenames t
   "*If non-nil, truncate long file names in the session group buffers.
 This can be toggled with `ediff-toggle-filename-truncation'."
+  :type 'boolean
+  :group 'ediff-mult)
+
+(defcustom ediff-meta-mode-hook nil
+  "*Hooks run just after setting up meta mode."
   :type 'hook
   :group 'ediff-mult)
+
 (defcustom ediff-registry-setup-hook nil
   "*Hooks run just after the registry control panel is set up."
   :type 'hook
@@ -209,9 +217,9 @@ This can be toggled with `ediff-toggle-filename-truncation'."
 
 (defcustom ediff-before-session-group-setup-hooks nil
   "*Hooks to run before Ediff arranges the window for group-level operations.
-It is used by commands such as ediff-directories.
+It is used by commands such as `ediff-directories'.
 This hook can be used to save the previous window config, which can be restored
-on ediff-quit, ediff-suspend, or ediff-quit-session-group-hook."
+on `ediff-quit', `ediff-suspend', or `ediff-quit-session-group-hook'."
   :type 'hook
   :group 'ediff-hook)
 (defcustom ediff-after-session-group-setup-hook nil
@@ -232,7 +240,7 @@ ediff-directories, is run."
   :type 'hook
   :group 'ediff-mult)
 (defcustom ediff-meta-buffer-keymap-setup-hook nil
-  "*Hooks run just after setting up the ediff-meta-buffer-map.
+  "*Hooks run just after setting up the `ediff-meta-buffer-map'.
 This keymap controls key bindings in the meta buffer and is a local variable.
 This means that you can set different bindings for different kinds of meta
 buffers."
@@ -353,7 +361,7 @@ buffers."
           (file-directory-p (ediff-get-session-objC-name session-info)) t)))
 
 ;; set up the keymap in the meta buffer
-(defun ediff-setup-meta-map()
+(defun ediff-setup-meta-map ()
   (setq ediff-meta-buffer-map (make-sparse-keymap))
   (suppress-keymap ediff-meta-buffer-map)
   (define-key ediff-meta-buffer-map "q" 'ediff-quit-meta-buffer)
@@ -407,7 +415,9 @@ Commands:
 \\{ediff-meta-buffer-map}"
   (kill-all-local-variables)
   (setq major-mode 'ediff-meta-mode)
-  (setq mode-name "MetaEdiff"))
+  (setq mode-name "MetaEdiff")
+  ;; don't use run-mode-hooks here!
+  (run-hooks 'ediff-meta-mode-hook))
 
 
 ;; the keymap for the buffer showing directory differences
@@ -557,17 +567,23 @@ behavior."
                           (ediff-add-slash-if-directory auxdir1 elt))
                         lis1)
          auxdir2       (file-name-as-directory dir2)
+         lis2          (directory-files auxdir2 nil regexp)
+         lis2          (delete "."  lis2)
+         lis2          (delete ".." lis2)
          lis2          (mapcar
                         (lambda (elt)
                           (ediff-add-slash-if-directory auxdir2 elt))
-                        (directory-files auxdir2 nil regexp)))
+                        lis2))
 
     (if (stringp dir3)
        (setq auxdir3   (file-name-as-directory dir3)
+             lis3      (directory-files auxdir3 nil regexp)
+             lis3      (delete "."  lis3)
+             lis3      (delete ".." lis3)
              lis3      (mapcar
                         (lambda (elt)
                           (ediff-add-slash-if-directory auxdir3 elt))
-                        (directory-files auxdir3 nil regexp))))
+                        lis3)))
 
     (if (ediff-nonempty-string-p merge-autostore-dir)
        (setq merge-autostore-dir
@@ -847,7 +863,7 @@ behavior."
         (session-info (ediff-overlay-get overl 'ediff-meta-info))
         (activity-marker (ediff-get-session-activity-marker session-info))
         buffer-read-only)
-    (or new-marker activity-marker (setq new-marker ?\ ))
+    (or new-marker activity-marker (setq new-marker ?\s))
     (goto-char (ediff-overlay-start overl))
     (if (eq (char-after (point)) new-marker)
        () ; if marker shown in buffer is the same as new-marker, do nothing
@@ -862,7 +878,7 @@ behavior."
         (session-info (ediff-overlay-get overl 'ediff-meta-info))
         (status (ediff-get-session-status session-info))
         buffer-read-only)
-    (setq new-status (or new-status status ?\ ))
+    (setq new-status (or new-status status ?\s))
     (goto-char (ediff-overlay-start overl))
     (forward-char 1) ; status is the second char in session record
     (if (eq (char-after (point)) new-status)
@@ -1296,7 +1312,7 @@ Useful commands:
         (if otherfile
             (or (file-exists-p otherfile)
                 (if (y-or-n-p
-                     (format "Copy %s to %s ? " file-abs otherfile))
+                     (format "Copy %s to %s? " file-abs otherfile))
                     (let* ((file-diff-record (assoc file-tail dir-diff-list))
                            (new-mem-code
                             (* (cdr file-diff-record) file-mem-code)))
@@ -1455,6 +1471,7 @@ Useful commands:
       (ediff-overlay-put overl 'highlight t))
     (ediff-overlay-put overl 'ediff-meta-info prop)
     (ediff-overlay-put overl 'invisible hidden)
+    (ediff-overlay-put overl 'follow-link t)
     (if (numberp session-number)
        (ediff-overlay-put overl 'ediff-meta-session-number session-number))))
 
@@ -1606,7 +1623,7 @@ Useful commands:
           (save-excursion
             (set-buffer meta-diff-buff)
             (goto-char (point-max))
-            (insert-buffer custom-diff-buf)
+            (insert-buffer-substring custom-diff-buf)
             (insert "\n")))
          ;; if ediff session is not live, run diff directly on the files
          ((memq metajob '(ediff-directories
@@ -1625,7 +1642,7 @@ Useful commands:
           (save-excursion
             (set-buffer meta-diff-buff)
             (goto-char (point-max))
-            (insert-buffer tmp-buf)
+            (insert-buffer-substring tmp-buf)
             (insert "\n")))
          (t
           (ediff-kill-buffer-carefully meta-diff-buff)
@@ -1673,7 +1690,8 @@ all marked sessions must be active."
               (ediff-get-session-objC-name info)))
            (set-buffer (get-buffer-create ediff-tmp-buffer))
            (erase-buffer)
-           (insert-buffer patchbuffer)
+           (insert-buffer-substring patchbuffer)
+           (goto-char (point-min))
            (display-buffer ediff-tmp-buffer 'not-this-window)
            ))
       (error "The patch buffer wasn't found"))))
@@ -1689,6 +1707,7 @@ all marked sessions must be active."
         (info (ediff-get-meta-info meta-buf pos))
         (session-buf (ediff-get-session-buffer info))
         (session-number (ediff-get-session-number-at-pos pos meta-buf))
+        (default-regexp (eval ediff-default-filtering-regexp))
         merge-autostore-dir file1 file2 file3 regexp)
 
     (setq file1 (ediff-get-session-objA-name info)
@@ -1717,8 +1736,16 @@ all marked sessions must be active."
             ;; do ediff/ediff-merge on subdirectories
             (if (ediff-buffer-live-p session-buf)
                 (ediff-show-meta-buffer session-buf)
-              (setq regexp (read-string "Filter through regular expression: "
-                                        nil 'ediff-filtering-regexp-history))
+              (setq regexp
+                    (read-string
+                     (if (stringp default-regexp)
+                         (format
+                          "Filter through regular expression (default %s): "
+                          default-regexp)
+                       "Filter through regular expression: ")
+                     nil
+                     'ediff-filtering-regexp-history
+                     (eval ediff-default-filtering-regexp)))
               (ediff-directories-internal
                file1 file2 file3 regexp
                ediff-session-action-function
@@ -2304,8 +2331,8 @@ If this is a session registry buffer then just bury it."
   "Run through the session list and mark identical files.
 This is used only for sessions that involve 2 or 3 files at the same time.
 ACTION is an optional argument that can be ?h, ?m, ?=, to mark for hiding, mark
-for operation, or simply indicate which are equal files. If it is nil, then
-last-command-char is used to decide which action to take."
+for operation, or simply indicate which are equal files.  If it is nil, then
+`last-command-char' is used to decide which action to take."
   (interactive)
   (if (null action)
       (setq action last-command-char))
@@ -2340,6 +2367,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.
@@ -2347,15 +2375,16 @@ 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)
+         ))
     ))
 
 
+(provide 'ediff-mult)
+
 
 ;;; Local Variables:
 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
@@ -2363,4 +2392,5 @@ last-command-char is used to decide which action to take."
 ;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body))
 ;;; End:
 
+;;; arch-tag: c8a76898-f96f-4d9c-be9d-129134017188
 ;;; ediff-mult.el ends here