<p>How do I make <code>diff</code> ignore temporary files like <code>foo.c~</code>? Is there a configuration file that will make ignoring temporaries the default?</p>

<p>More generally: what's the best way to generate a "clean" patch off a tarball? I do this rarely enough (submitting a bug fix to an OSS project by email) that I always struggle with it...</p>

<p>EDIT: OK, the short answer is</p>

<pre><code>diff -ruN -x *~ ...
</code></pre>

<p>Is there a better answer? E.g., can this go in a configuration file?</p>

This doesn't strictly answer your question, but you can avoid the problem by configuring Emacs to use a specific directory to keep the backup files in. There are different implementations for Emacs or XEmacs.
In GNU Emacs
```
(defvar user-temporary-file-directory
      (concat temporary-file-directory user-login-name "/"))
    (make-directory user-temporary-file-directory t)
    (setq backup-by-copying t)
    (setq backup-directory-alist
      `(("." . ,user-temporary-file-directory)
        (,tramp-file-name-regexp nil)))
    (setq auto-save-list-file-prefix
      (concat user-temporary-file-directory ".auto-saves-"))
    (setq auto-save-file-name-transforms
      `((".*" ,user-temporary-file-directory t)))
```
In XEmacs
```
(require 'auto-save) 
    (require 'backup-dir) 

    (defvar user-temporary-file-directory
      (concat (temp-directory) "/" (user-login-name)))
    (make-directory user-temporary-file-directory t)
    (setq backup-by-copying t)
    (setq auto-save-directory user-temporary-file-directory)
    (setq auto-save-list-file-prefix 
         (concat user-temporary-file-directory ".auto-saves-"))
    (setq bkup-backup-directory-info
      `((t ,user-temporary-file-directory full-path)))
```
You can also remove them all with a simple find command
```
find . -name “*~” -delete
```
Note that the asterisk and tilde are in double quotes to stop the shell expanding them.
By the way, these aren't strictly
temporary
files. They are a backup of the previous version of the file, so you can manually "undo" your last edit at any time in the future.