Function: ediff-inferior-compare-regions

ediff-inferior-compare-regions is an interactive and byte-compiled function defined in ediff-util.el.gz.

Signature

(ediff-inferior-compare-regions)

Documentation

Compare regions in an active Ediff session.

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 Ediff Control Panel to restore highlighting.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/vc/ediff-util.el.gz
(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 the files that belong to that session.

After quitting the session invoked via this function, type C-l to the parent
Ediff Control Panel to restore highlighting."
  (interactive)
  (let ((answer "")
	(possibilities (list ?A ?B ?C))
	use-current-diff-p
	begA begB endA endB bufA bufB)

    (if (ediff-valid-difference-p ediff-current-difference)
	(progn
	  (ediff-set-fine-diff-properties ediff-current-difference t)
	  (ediff-unhighlight-diff)))
    (ediff-paint-background-regions 'unhighlight)

    (cond ((ediff-merge-job)
	   ;; ask which buffer to compare to the merge buffer
	   (setq answer (read-multiple-choice
                         "Which buffer to compare?"
                         '((?a "A")
                           (?b "B"))))
           (if (eq (car answer) ?a)
               (setq bufA ediff-buffer-A)
             (setq bufA ediff-buffer-B))
           (setq bufB (if (and ediff-ancestor-buffer
                               (y-or-n-p (format "Compare %s against ancestor buffer?"
                                                 (cadr answer))))
                          ediff-ancestor-buffer
                        ediff-buffer-C)))

	  ((ediff-3way-comparison-job)
	   ;; ask which two buffers to compare
	   (while (cond ((memq answer possibilities)
			 (setq possibilities (delq answer possibilities))
			 (setq bufA
			       (symbol-value
				(ediff-get-symbol-from-alist
				 answer ediff-buffer-alist)))
			 nil)
			((equal answer ""))
			(t (beep 1)
			   (message
			    "Valid values are %s"
			    (mapconcat #'char-to-string possibilities " or "))
			   (sit-for 2)
			   t))
	     (let ((cursor-in-echo-area t))
	       (message "Enter the 1st buffer you want to compare (%s): "
			(mapconcat #'char-to-string possibilities " or "))
	       (setq answer (capitalize (read-char-exclusive)))))
	   (setq answer "") ; silence error msg
	   (while (cond ((memq answer possibilities)
			 (setq possibilities (delq answer possibilities))
			 (setq bufB
			       (symbol-value
				(ediff-get-symbol-from-alist
				 answer ediff-buffer-alist)))
			 nil)
			((equal answer ""))
			(t (beep 1)
			   (message
			    "Valid values are %s"
			    (mapconcat #'char-to-string possibilities " or "))
			   (sit-for 2)
			   t))
	     (let ((cursor-in-echo-area t))
	       (message "Enter the 2nd buffer you want to compare (%s): "
			(mapconcat #'char-to-string possibilities "/"))
	       (setq answer (capitalize (read-char-exclusive))))))
	  (t ; 2way comparison
	   (setq bufA ediff-buffer-A
		 bufB ediff-buffer-B
		 possibilities nil)))

    (if (and (ediff-valid-difference-p ediff-current-difference)
	     (y-or-n-p "Compare currently highlighted difference regions? "))
	(setq use-current-diff-p t))

    (setq bufA (if use-current-diff-p
		   (ediff-clone-buffer-for-current-diff-comparison
		    bufA "-Region.A-")
		 (ediff-clone-buffer-for-region-comparison bufA "-Region.A-")))
    (ediff-with-current-buffer bufA
      (setq begA (region-beginning)
	    endA (region-end))
      (goto-char begA)
      (beginning-of-line)
      (setq begA (point))
      (goto-char endA)
      (end-of-line)
      (or (eobp) (forward-char)) ; include the newline char
      (setq endA (point)))

    (setq bufB (if use-current-diff-p
		   (ediff-clone-buffer-for-current-diff-comparison
		    bufB "-Region.B-")
		 (ediff-clone-buffer-for-region-comparison bufB "-Region.B-")))
    (ediff-with-current-buffer bufB
      (setq begB (region-beginning)
	    endB (region-end))
      (goto-char begB)
      (beginning-of-line)
      (setq begB (point))
      (goto-char endB)
      (end-of-line)
      (or (eobp) (forward-char)) ; include the newline char
      (setq endB (point)))


    (ediff-regions-internal
     bufA begA endA bufB begB endB
     nil                        ; setup-hook
     (if use-current-diff-p	; job name
	 'ediff-regions-wordwise
       'ediff-regions-linewise)
     (if use-current-diff-p	; word mode, if diffing current diff
	 t nil)
     ;; setup param to pass to ediff-setup
     (list (cons 'ediff-split-window-function ediff-split-window-function)))
    ))