Function: ediff-find-file
ediff-find-file is a byte-compiled function defined in ediff.el.gz.
Signature
(ediff-find-file FILE &optional LAST-DIR)
Documentation
Visit FILE and arrange its buffer to Ediff's liking.
FILE is the file name.
LAST-DIR is the directory variable symbol where FILE's
directory name should be returned. May push to ediff--startup-hook
functions to be executed after ediff-startup is finished.
ediff-find-file arranges that the temp files it might create will be
deleted.
Returns the buffer into which the file is visited.
Also sets ediff--magic-file-name to indicate where the file's content
has been saved (if not in buffer-file-name(var)/buffer-file-name(fun)).
Source Code
;; Defined in /usr/src/emacs/lisp/vc/ediff.el.gz
(defun ediff-find-file (file &optional last-dir)
"Visit FILE and arrange its buffer to Ediff's liking.
FILE is the file name.
LAST-DIR is the directory variable symbol where FILE's
directory name should be returned. May push to `ediff--startup-hook'
functions to be executed after `ediff-startup' is finished.
`ediff-find-file' arranges that the temp files it might create will be
deleted.
Returns the buffer into which the file is visited.
Also sets `ediff--magic-file-name' to indicate where the file's content
has been saved (if not in `buffer-file-name')."
(let* ((file-magic (ediff-filename-magic-p file))
(temp-file-name-prefix (file-name-nondirectory file)))
(cond ((not (file-readable-p file))
(user-error "File `%s' does not exist or is not readable" file))
((file-directory-p file)
(user-error "File `%s' is a directory" file)))
;; some of the commands, below, require full file name
(setq file (expand-file-name file))
;; Record the directory of the file
(if last-dir
(set last-dir (expand-file-name (file-name-directory file))))
;; Setup the buffer
(with-current-buffer (find-file-noselect file)
(widen) ; Make sure the entire file is seen
(setq ediff--magic-file-name nil)
(cond (file-magic ; File has a handler, such as jka-compr-handler or
; ange-ftp-hook-function--arrange for temp file
(ediff-verify-file-buffer 'magic)
(let ((file
(ediff-make-temp-file
(current-buffer) temp-file-name-prefix)))
(add-hook 'ediff--startup-hook (lambda () (delete-file file)))
(setq ediff--magic-file-name file)))
;; file processed via auto-mode-alist, a la uncompress.el
((not (equal (file-truename file)
(file-truename buffer-file-name)))
(let ((file
(ediff-make-temp-file
(current-buffer) temp-file-name-prefix)))
(add-hook 'ediff--startup-hook (lambda () (delete-file file)))
(setq ediff--magic-file-name file)))
(t ;; plain file---just check that the file matches the buffer
(ediff-verify-file-buffer)))
(current-buffer))))