;;; ediff-util.el --- the core commands and utilities of ediff
-;; Copyright (C) 1994-2012 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2013 Free Software Foundation, Inc.
;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
;; Package: ediff
(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
;; 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
(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)
(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
(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)
(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)