(defgroup reftex): Update home page url-link.
[bpt/emacs.git] / lisp / ediff-mult.el
index 2c192c1..b33ad7c 100644 (file)
@@ -1,7 +1,7 @@
 ;;; ediff-mult.el --- support for multi-file/multi-buffer processing in Ediff
 
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-;;   2003, 2004, 2005 Free Software Foundation, Inc.
+;;   2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 
 
 ;;; Code:
 
-(provide 'ediff-mult)
 
 (defgroup ediff-mult nil
   "Multi-file and multi-buffer processing in Ediff."
 ;; end pacifier
 
 (require 'ediff-init)
-(require 'ediff-util)
 
 ;; meta-buffer
 (ediff-defvar-local ediff-meta-buffer nil "")
@@ -176,7 +174,7 @@ directories.")
 
 (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)
 
@@ -219,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
@@ -242,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."
@@ -363,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)
@@ -650,8 +648,8 @@ behavior."
           (mapcar
            (lambda (elt)
              (ediff-make-new-meta-list-element
-              (concat auxdir1 elt)
-              (concat auxdir2 elt)
+              (expand-file-name (concat auxdir1 elt))
+              (expand-file-name (concat auxdir2 elt))
               (if lis3
                   (progn
                     ;; The following is done because: In merging with
@@ -662,7 +660,7 @@ behavior."
                     ;; the second case, we insert nil.
                     (setq elt (ediff-add-slash-if-directory auxdir3 elt))
                     (if (file-exists-p (concat auxdir3 elt))
-                        (concat auxdir3 elt))))))
+                        (expand-file-name (concat auxdir3 elt)))))))
            common)))
     ;; return result
     (cons common-part difflist)
@@ -718,7 +716,7 @@ behavior."
                                      auxdir1 nil nil
                                      merge-autostore-dir nil)
      (mapcar (lambda (elt) (ediff-make-new-meta-list-element
-                           (concat auxdir1 elt) nil nil))
+                           (expand-file-name (concat auxdir1 elt)) nil nil))
             common))
     ))
 
@@ -1314,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)))
@@ -1340,7 +1338,10 @@ Useful commands:
        ;; update ediff-meta-list by direct modification
        (nconc meta-list
               (list (ediff-make-new-meta-list-element
-                     otherfile1 otherfile2 otherfile3)))
+                     (expand-file-name otherfile1)
+                     (expand-file-name otherfile2)
+                     (if otherfile3
+                         (expand-file-name otherfile3)))))
       )
     (ediff-update-meta-buffer meta-buf 'must-redraw)
   ))
@@ -1473,6 +1474,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))))
 
@@ -1624,7 +1626,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
@@ -1643,7 +1645,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)
@@ -1657,22 +1659,26 @@ This operation is defined only for `ediff-directories' and
 multifile patches.  For `ediff-directory-revisions', we insist that
 all marked sessions must be active."
   (interactive)
-  (or (ediff-buffer-live-p ediff-meta-diff-buffer)
-      (setq ediff-meta-diff-buffer
-           (get-buffer-create
-            (ediff-unique-buffer-name "*Ediff Multifile Diffs" "*"))))
-  (ediff-with-current-buffer ediff-meta-diff-buffer
-    (setq buffer-read-only nil)
-    (erase-buffer))
-  (if (> (ediff-operate-on-marked-sessions 'ediff-append-custom-diff) 0)
-      ;; did something
-      (progn
-       (display-buffer ediff-meta-diff-buffer 'not-this-window)
-       (ediff-with-current-buffer ediff-meta-diff-buffer
-         (set-buffer-modified-p nil)
-         (setq buffer-read-only t)))
-    (beep)
-    (message "No marked sessions found")))
+  (let ((coding-system-for-read ediff-coding-system-for-read))
+    (or (ediff-buffer-live-p ediff-meta-diff-buffer)
+       (setq ediff-meta-diff-buffer
+             (get-buffer-create
+              (ediff-unique-buffer-name "*Ediff Multifile Diffs" "*"))))
+    (ediff-with-current-buffer ediff-meta-diff-buffer
+                              (setq buffer-read-only nil)
+                              (erase-buffer))
+    (if (> (ediff-operate-on-marked-sessions 'ediff-append-custom-diff) 0)
+       ;; did something
+       (progn
+         (display-buffer ediff-meta-diff-buffer 'not-this-window)
+         (ediff-with-current-buffer ediff-meta-diff-buffer
+                                    (set-buffer-modified-p nil)
+                                    (setq buffer-read-only t))
+         (if (fboundp 'diff-mode)
+             (with-current-buffer ediff-meta-diff-buffer
+               (diff-mode))))
+      (beep)
+      (message "No marked sessions found"))))
 
 (defun ediff-meta-show-patch ()
   "Show the multi-file patch associated with this group session."
@@ -1691,7 +1697,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"))))
@@ -2331,8 +2338,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))
@@ -2383,6 +2390,8 @@ last-command-char is used to decide which action to take."
     ))
 
 
+(provide 'ediff-mult)
+
 
 ;;; Local Variables:
 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)