Function: smerge-diff
smerge-diff is a byte-compiled function defined in smerge-mode.el.gz.
Signature
(smerge-diff N1 N2)
Source Code
;; Defined in /usr/src/emacs/lisp/vc/smerge-mode.el.gz
(defun smerge-diff (n1 n2)
(smerge-match-conflict)
(smerge-ensure-match n1)
(smerge-ensure-match n2)
(let ((name1 (aref smerge-match-names n1))
(name2 (aref smerge-match-names n2))
;; Read them before the match-data gets clobbered.
(beg1 (match-beginning n1))
(end1 (match-end n1))
(beg2 (match-beginning n2))
(end2 (match-end n2))
(file1 (make-temp-file "smerge1"))
(file2 (make-temp-file "smerge2"))
(dir default-directory)
(file (if buffer-file-name (file-relative-name buffer-file-name)))
;; We would want to use `emacs-mule-unix' for read&write, but we
;; bump into problems with the coding-system used by diff to write
;; the file names and the time stamps in the header.
;; `buffer-file-coding-system' is not always correct either, but if
;; the OS/user uses only one coding-system, then it works.
(coding-system-for-read buffer-file-coding-system))
(write-region beg1 end1 file1 nil 'nomessage)
(write-region beg2 end2 file2 nil 'nomessage)
(unwind-protect
(save-current-buffer
(if-let (buffer (get-buffer smerge-diff-buffer-name))
(set-buffer buffer)
(set-buffer (get-buffer-create smerge-diff-buffer-name))
(setq buffer-read-only t))
(setq default-directory dir)
(let ((inhibit-read-only t))
(erase-buffer)
(let ((status
(apply 'call-process diff-command nil t nil
(append smerge-diff-switches
(and (diff-check-labels)
(list "--label"
(concat name1 "/" file)
"--label"
(concat name2 "/" file)))
(list file1 file2)))))
(if (eq status 0) (insert "No differences found.\n"))))
(goto-char (point-min))
(diff-mode)
(display-buffer (current-buffer) t))
(delete-file file1)
(delete-file file2))))