+(declare-function diff-sentinel "diff" (code))
+
+(defun ibuffer-diff-buffer-with-file-1 (buffer)
+ (let ((bufferfile (buffer-local-value 'buffer-file-name buffer))
+ (tempfile (make-temp-file "buffer-content-")))
+ (when bufferfile
+ (unwind-protect
+ (progn
+ (with-current-buffer buffer
+ (write-region nil nil tempfile nil 'nomessage))
+ (let* ((old (expand-file-name bufferfile))
+ (new (expand-file-name tempfile))
+ (oldtmp (file-local-copy old))
+ (newtmp (file-local-copy new))
+ (switches diff-switches)
+ (command
+ (mapconcat
+ 'identity
+ `(,diff-command
+ ;; Use explicitly specified switches
+ ,@(if (listp switches) switches (list switches))
+ ,@(if (or old new)
+ (list "-L" (shell-quote-argument old)
+ "-L" (shell-quote-argument
+ (format "Buffer %s" (buffer-name buffer)))))
+ ,(shell-quote-argument (or oldtmp old))
+ ,(shell-quote-argument (or newtmp new)))
+ " "))
+ proc)
+ (let ((inhibit-read-only t))
+ (insert command "\n")
+ (diff-sentinel
+ (call-process shell-file-name nil
+ (current-buffer) nil
+ shell-command-switch command)))
+ (insert "\n"))))
+ (sit-for 0)
+ (when (file-exists-p tempfile)
+ (delete-file tempfile)))))
+