First, for making sure the autosave files—the ones prefixed and suffixed by "#"—are cleaned up, ensure that delete-auto-save-files is non-nil (the default) and, if using Emacs 28 or later, set kill-buffer-delete-auto-save-files to non-nil (that would normally be t). As for the backup files ending in "~", those are created on saving a modified file by default and their creation is disabled by setting make-backup-files to a non-nil value.
All of this can be achieved, assuming you're using Emacs 28 or later, by adding
;; Disable backup files.
(setf make-backup-files nil)
;; Prompt to delete autosaves when killing buffers.
(setf kill-buffer-delete-auto-save-files t)
First, for making sure the autosave files—the ones prefixed and suffixed by "#"—are cleaned up, ensure that
delete-auto-save-files
is non-nil (the default) and, if using Emacs 28 or later, setkill-buffer-delete-auto-save-files
to non-nil (that would normally bet
). As for the backup files ending in "~", those are created on saving a modified file by default and their creation is disabled by settingmake-backup-files
to a non-nil value.All of this can be achieved, assuming you're using Emacs 28 or later, by adding
to your init file.