Merge from emacs-24; up to 2012-12-06T01:39:03Z!monnier@iro.umontreal.ca
[bpt/emacs.git] / lisp / vc / ediff-util.el
index 5d7d245..2456d6e 100644 (file)
@@ -1,6 +1,6 @@
 ;;; ediff-util.el --- the core commands and utilities of ediff
 
-;; Copyright (C) 1994-201 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2013 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 ;; Package: ediff
@@ -1907,8 +1907,8 @@ in the specified buffer."
 
       (cond ((eq which-diff 'after) (1+ diff-no))
            ((eq which-diff 'before) diff-no)
-           ((< (abs (count-lines pos (max 1 prev-end)))
-               (abs (count-lines pos (max 1 beg))))
+           ((< (abs (count-lines pos (max (point-min) prev-end)))
+               (abs (count-lines pos (max (point-min) beg))))
             diff-no)       ; choose prev difference
            (t
             (1+ diff-no))) ; choose next difference
@@ -2635,7 +2635,7 @@ delete this buffer in another session as well."
     ))
 
 ;; Kill the variant buffer, according to user directives (ask, kill
-;; unconditionaly, keep)
+;; unconditionally, keep)
 ;; BUFF is the buffer, BUFF-TYPE is either 'A, or 'B, 'C, 'Ancestor
 (defun ediff-dispose-of-variant-according-to-user (buff bufftype ask keep-variants)
   ;; if this is indirect buffer, kill it and substitute with direct buf
@@ -3103,7 +3103,7 @@ Hit \\[ediff-recenter] to reset the windows afterward."
 ;; according to context.
 ;; If DEFAULT-FILE is set, it should be used as the default value.
 ;; If DEFAULT-DIR is non-nil, use it as the default directory.
-;; Otherwise, use the value of Emacs' variable `default-directory.'
+;; Otherwise, use the value of `default-directory.'
 (defun ediff-read-file-name (prompt default-dir default-file &optional no-dirs)
   ;; hack default-dir if it is not set
   (setq default-dir
@@ -3378,10 +3378,18 @@ Without an argument, it saves customized diff argument, if available
     (set-window-buffer wind cloned-buff)
     cloned-buff))
 
-(defun ediff-clone-buffer-for-current-diff-comparison (buff buf-type reg-name)
-  (let ((cloned-buff (ediff-make-cloned-buffer buff reg-name))
-       (reg-start (ediff-get-diff-posn buf-type 'beg))
-       (reg-end (ediff-get-diff-posn buf-type 'end)))
+(defun ediff-buffer-type (buffer)
+  (cond ((eq buffer ediff-buffer-A) 'A)
+        ((eq buffer ediff-buffer-B) 'B)
+        ((eq buffer ediff-buffer-C) 'C)
+        ((eq buffer ediff-ancestor-buffer) 'Ancestor)
+        (t nil)))
+
+(defun ediff-clone-buffer-for-current-diff-comparison (buff reg-name)
+  (let* ((cloned-buff (ediff-make-cloned-buffer buff reg-name))
+         (buf-type (ediff-buffer-type buff))
+         (reg-start (ediff-get-diff-posn buf-type 'beg))
+         (reg-end (ediff-get-diff-posn buf-type 'end)))
     (ediff-with-current-buffer cloned-buff
       ;; set region to be the current diff region
       (goto-char reg-start)
@@ -3466,7 +3474,7 @@ Without an argument, it saves customized diff argument, if available
 
 (defun ediff-inferior-compare-regions ()
   "Compare regions in an active Ediff session.
-Like ediff-regions-linewise but is called from under an active Ediff session on
+Like `ediff-regions-linewise' but is called from under an active Ediff session on
 the files that belong to that session.
 
 After quitting the session invoked via this function, type C-l to the parent
@@ -3555,7 +3563,7 @@ Ediff Control Panel to restore highlighting."
 
     (setq bufA (if use-current-diff-p
                   (ediff-clone-buffer-for-current-diff-comparison
-                   bufA 'A "-Region.A-")
+                   bufA "-Region.A-")
                 (ediff-clone-buffer-for-region-comparison bufA "-Region.A-")))
     (ediff-with-current-buffer bufA
       (setq begA (region-beginning)
@@ -3570,7 +3578,7 @@ Ediff Control Panel to restore highlighting."
 
     (setq bufB (if use-current-diff-p
                   (ediff-clone-buffer-for-current-diff-comparison
-                   bufB 'B "-Region.B-")
+                   bufB "-Region.B-")
                 (ediff-clone-buffer-for-region-comparison bufB "-Region.B-")))
     (ediff-with-current-buffer bufB
       (setq begB (region-beginning)
@@ -3811,7 +3819,7 @@ Ediff Control Panel to restore highlighting."
         ;; later, and nconc above will break it. Either this or use slow
         ;; append instead of nconc
         (selected-buffers (ediff-get-selected-buffers))
-        (prefered-buffer (car all-buffers))
+        (preferred-buffer (car all-buffers))
         visible-dired-buffers
         (excl-buff-name-list
          (mapcar
@@ -3841,7 +3849,7 @@ Ediff Control Panel to restore highlighting."
             (cond ((member (buffer-name x) excl-buff-name-list) nil)
                   ((memq x selected-buffers) x)
                   ((not (ediff-get-visible-buffer-window x)) nil)
-                  ((eq x prefered-buffer) x)
+                  ((eq x preferred-buffer) x)
                   ;; if prev selected buffer is dired, look only at
                   ;; dired.
                   ((eq use-dired-major-mode 'yes)