Function: ediff-position-region
ediff-position-region is a byte-compiled function defined in
ediff-util.el.gz.
Signature
(ediff-position-region BEG END POS JOB-NAME)
Source Code
;; Defined in /usr/src/emacs/lisp/vc/ediff-util.el.gz
;;BEG, END show the region to be positioned.
;;JOB-NAME holds ediff-job-name. The ediff-windows job positions regions
;;differently.
(defun ediff-position-region (beg end pos _job-name)
(if (> end (point-max))
(setq end (point-max)))
(if ediff-windows-job
(if (pos-visible-in-window-p end)
() ; do nothing, wind is already positioned
;; at this point, windows are positioned at the beginning of the
;; file regions (not diff-regions) being compared.
(save-excursion
(move-to-window-line (- (window-height) 2))
(let ((amount (+ 2 (count-lines (point) end))))
(scroll-up amount))))
(set-window-start (selected-window) beg)
(if (pos-visible-in-window-p end)
;; Determine the number of lines that the region occupies
(let ((lines 0)
(prev-point 0))
(while ( and (> end (progn
(move-to-window-line lines)
(point)))
;; `end' may be beyond the window bottom, so check
;; that we are making progress
(< prev-point (point)))
(setq prev-point (point))
(setq lines (1+ lines)))
;; And position the beginning on the right line
(goto-char beg)
(recenter (/ (1+ (max (- (1- (window-height))
lines)
1)
)
2))))
(goto-char pos)
))