How do I make diff ignore temporary files like foo.c~? Is there a configuration file that will make ignoring temporaries the default?
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…
EDIT: OK, the short answer is
diff -ruN -x *~ ...
Is there a better answer? E.g., can this go in a configuration file?
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
You can also remove them all with a simple find command
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.