]> code.delx.au - gnu-emacs/blobdiff - lisp/vc/ediff.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / vc / ediff.el
index aba23b0653558e00a242974dde1550fe2c0f53b3..be4ced9b55f3d5eb6120c13e4fcb9f6e5587cd7f 100644 (file)
@@ -1,6 +1,6 @@
 ;;; ediff.el --- a comprehensive visual interface to diff & patch
 
-;; Copyright (C) 1994-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2016 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 ;; Created: February 2, 1994
@@ -12,8 +12,8 @@
 ;; filed in the Emacs bug reporting system against this file, a copy
 ;; of the bug report be sent to the maintainer's email address.
 
-(defconst ediff-version "2.81.4" "The current version of Ediff")
-(defconst ediff-date "December 7, 2009" "Date of last update")
+(defconst ediff-version "2.81.5" "The current version of Ediff")
+(defconst ediff-date "July 4, 2013" "Date of last update")
 
 
 ;; This file is part of GNU Emacs.
@@ -64,7 +64,7 @@
 ;; compressed files.  Details are given below.
 
 ;; Finally, Ediff supports directory-level comparison, merging and patching.
-;; See the on-line manual for details.
+;; See the Ediff manual for details.
 
 ;; This package builds upon the ideas borrowed from emerge.el and several
 ;; Ediff's functions are adaptations from emerge.el.  Much of the functionality
 
 ;; Compiler pacifier
 (eval-and-compile
-  (unless (fboundp 'declare-function) (defmacro declare-function (&rest  r))))
+  (unless (fboundp 'declare-function) (defmacro declare-function (&rest  _r))))
 
-
-(eval-when-compile
-  (require 'dired)
-  (require 'ediff-util)
-  (require 'ediff-ptch))
+(require 'ediff-util)
 ;; end pacifier
 
 (require 'ediff-init)
   (ediff-with-current-buffer ediff-buffer-A
     (setq buffer-read-only t)))
 
+(declare-function dired-get-filename "dired"
+                  (&optional localp no-error-if-not-filep))
+(declare-function dired-get-marked-files "dired"
+                  (&optional localp arg filter distinguish-one-marked))
+
 ;; Return a plausible default for ediff's first file:
 ;; In dired, return the file number FILENO (or 0) in the list
 ;; (all-selected-files, filename under the cursor), where directories are
@@ -366,8 +367,10 @@ deleted."
 This command can be used instead of `revert-buffer'.  If there is
 nothing to revert then this command fails."
   (interactive)
-  (unless (or revert-buffer-function
-              revert-buffer-insert-file-contents-function
+  ;; This duplicates code from menu-bar.el.
+  (unless (or (not (eq revert-buffer-function 'revert-buffer--default))
+              (not (eq revert-buffer-insert-file-contents-function
+                      'revert-buffer-insert-file-contents--default-function))
               (and buffer-file-number
                    (or (buffer-modified-p)
                        (not (verify-visited-file-modtime
@@ -960,7 +963,7 @@ If WIND-B is nil, use window next to WIND-A."
 ;;;###autoload
 (defun ediff-regions-wordwise (buffer-A buffer-B &optional startup-hooks)
   "Run Ediff on a pair of regions in specified buffers.
-Regions \(i.e., point and mark\) can be set in advance or marked interactively.
+Regions (i.e., point and mark) can be set in advance or marked interactively.
 This function is effective only for relatively small regions, up to 200
 lines.  For large regions, use `ediff-regions-linewise'."
   (interactive
@@ -1000,7 +1003,7 @@ 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 specified buffers.
-Regions \(i.e., point and mark\) can be set in advance or marked interactively.
+Regions (i.e., point and mark) can be set in advance or marked interactively.
 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'."
@@ -1291,7 +1294,7 @@ buffer."
   (let (rev1 rev2)
     (setq rev1
          (read-string
-          (format
+          (format-message
            "Version 1 to merge (default %s's working version): "
            (if (stringp file)
                (file-name-nondirectory file) "current buffer")))
@@ -1323,7 +1326,7 @@ buffer."
   (let (rev1 rev2 ancestor-rev)
     (setq rev1
          (read-string
-          (format
+          (format-message
            "Version 1 to merge (default %s's working version): "
            (if (stringp file)
                (file-name-nondirectory file) "current buffer")))
@@ -1335,7 +1338,7 @@ buffer."
                (file-name-nondirectory file) "current buffer")))
          ancestor-rev
          (read-string
-          (format
+          (format-message
            "Ancestor version (default %s's base revision): "
            (if (stringp file)
                (file-name-nondirectory file) "current buffer"))))
@@ -1345,6 +1348,12 @@ buffer."
      rev1 rev2 ancestor-rev startup-hooks merge-buffer-file)))
 
 ;;; Apply patch
+(defvar ediff-last-dir-patch)
+(defvar ediff-patch-default-directory)
+(declare-function ediff-get-patch-buffer "ediff-ptch"
+                  (&optional arg patch-buf))
+(declare-function ediff-dispatch-file-patching-job "ediff-ptch"
+                  (patch-buf filename &optional startup-hooks))
 
 ;;;###autoload
 (defun ediff-patch-file (&optional arg patch-buf)
@@ -1358,7 +1367,8 @@ buffer. If odd -- assume it is in a file."
     (require 'ediff-ptch)
     (setq patch-buf
          (ediff-get-patch-buffer
-          (if arg (prefix-numeric-value arg)) patch-buf))
+          (if arg (prefix-numeric-value arg))
+           (get-buffer patch-buf)))
     (setq source-dir (cond (ediff-use-last-dir ediff-last-dir-patch)
                           ((and (not ediff-patch-default-directory)
                                 (buffer-file-name patch-buf))
@@ -1373,6 +1383,9 @@ buffer. If odd -- assume it is in a file."
           source-dir nil nil (ediff-get-default-file-name)))
     (ediff-dispatch-file-patching-job patch-buf source-file)))
 
+(declare-function ediff-patch-buffer-internal "ediff-ptch"
+                  (patch-buf buf-to-patch-name &optional startup-hooks))
+
 ;;;###autoload
 (defun ediff-patch-buffer (&optional arg patch-buf)
   "Run Ediff by patching the buffer specified at prompt.
@@ -1389,9 +1402,8 @@ patch. If not given, the user is prompted according to the prefix argument."
         (if arg (prefix-numeric-value arg)) patch-buf))
   (ediff-patch-buffer-internal
    patch-buf
-   (read-buffer
-    "Which buffer to patch? "
-    (ediff-other-buffer patch-buf))))
+   (read-buffer "Which buffer to patch? " (ediff-other-buffer patch-buf)
+                'require-match)))
 
 
 ;;;###autoload
@@ -1464,14 +1476,14 @@ Uses `vc.el' or `rcs.el' depending on `ediff-version-control-package'."
   "Return string describing the version of Ediff.
 When called interactively, displays the version."
   (interactive)
-  ;; called-interactively-p - not in XEmacs
-  ;; (if (called-interactively-p 'interactive)
-  (if (interactive-p)
+  (if (if (featurep 'xemacs)
+          (interactive-p)
+        (called-interactively-p 'interactive))
       (message "%s" (ediff-version))
     (format "Ediff %s of %s" ediff-version ediff-date)))
 
 ;; info is run first, and will autoload info.el.
-(declare-function Info-goto-node "info" (nodename &optional fork))
+(declare-function Info-goto-node "info" (nodename &optional fork strict-case))
 
 ;;;###autoload
 (defun ediff-documentation (&optional node)
@@ -1489,7 +1501,7 @@ With optional NODE, goes to that node."
          (if node
              (Info-goto-node node)
            (message "Type `i' to search for a specific topic"))
-         (raise-frame (selected-frame)))
+         (raise-frame))
       (error (beep 1)
             (with-output-to-temp-buffer ediff-msg-buffer
               (ediff-with-current-buffer standard-output
@@ -1550,6 +1562,75 @@ With optional NODE, goes to that node."
   (add-to-list 'debug-ignored-errors mess))
 
 
+\f
+;;; Command line interface
+
+;;;###autoload
+(defun ediff-files-command ()
+  (let ((file-a (nth 0 command-line-args-left))
+       (file-b (nth 1 command-line-args-left)))
+    (setq command-line-args-left (nthcdr 2 command-line-args-left))
+    (ediff file-a file-b)))
+
+;;;###autoload
+(defun ediff3-files-command ()
+  (let ((file-a (nth 0 command-line-args-left))
+       (file-b (nth 1 command-line-args-left))
+       (file-c (nth 2 command-line-args-left)))
+    (setq command-line-args-left (nthcdr 3 command-line-args-left))
+    (ediff3 file-a file-b file-c)))
+
+;;;###autoload
+(defun ediff-merge-command ()
+  (let ((file-a (nth 0 command-line-args-left))
+       (file-b (nth 1 command-line-args-left)))
+    (setq command-line-args-left (nthcdr 2 command-line-args-left))
+    (ediff-merge-files file-a file-b)))
+
+;;;###autoload
+(defun ediff-merge-with-ancestor-command ()
+  (let ((file-a (nth 0 command-line-args-left))
+       (file-b (nth 1 command-line-args-left))
+       (ancestor (nth 2 command-line-args-left)))
+    (setq command-line-args-left (nthcdr 3 command-line-args-left))
+    (ediff-merge-files-with-ancestor file-a file-b ancestor)))
+
+;;;###autoload
+(defun ediff-directories-command ()
+  (let ((file-a (nth 0 command-line-args-left))
+       (file-b (nth 1 command-line-args-left))
+       (regexp (nth 2 command-line-args-left)))
+    (setq command-line-args-left (nthcdr 3 command-line-args-left))
+    (ediff-directories file-a file-b regexp)))
+
+;;;###autoload
+(defun ediff-directories3-command ()
+  (let ((file-a (nth 0 command-line-args-left))
+       (file-b (nth 1 command-line-args-left))
+       (file-c (nth 2 command-line-args-left))
+       (regexp (nth 3 command-line-args-left)))
+    (setq command-line-args-left (nthcdr 4 command-line-args-left))
+    (ediff-directories3 file-a file-b file-c regexp)))
+
+;;;###autoload
+(defun ediff-merge-directories-command ()
+  (let ((file-a (nth 0 command-line-args-left))
+       (file-b (nth 1 command-line-args-left))
+       (regexp (nth 2 command-line-args-left)))
+    (setq command-line-args-left (nthcdr 3 command-line-args-left))
+    (ediff-merge-directories file-a file-b regexp)))
+
+;;;###autoload
+(defun ediff-merge-directories-with-ancestor-command ()
+  (let ((file-a (nth 0 command-line-args-left))
+       (file-b (nth 1 command-line-args-left))
+       (ancestor (nth 2 command-line-args-left))
+       (regexp (nth 3 command-line-args-left)))
+    (setq command-line-args-left (nthcdr 4 command-line-args-left))
+    (ediff-merge-directories-with-ancestor file-a file-b ancestor regexp)))
+
+
+
 (require 'ediff-util)
 
 (run-hooks 'ediff-load-hook)