Exclude emacs files in Package.swift

This seems to be easy but I couldn’t figure out how to exclude emacs files (like main.swift~) in Package.swift files to get rid of the warnings when compiling. I tried variations of exclude: ["*.swift~"] but without any success yet. Thanks for any hint.

There isn't any support for globs in the package manifest, so you'll have to explicitly list any filenames.

1 Like

IMHO you should consider just configuring your emacs to not save backup files. They clutter up the file system and they're not really useful as long as you're already using some form of version control.

1 Like

i know this is a bit different from the OP’s problem, but i also frequently run into this with markdown (.md) files, especially with per-directory README.md files. i wish you could just exclude file extensions globally.

2 Likes

They are fairly common, so it would be nice if SwiftPM could handle it.

The backup files can be useful if the editor crashes (rare), the os crashes (rare?) or you run out of power/blackout, and you haven't saved in a while. I suspect that most programmers are compulsive savers, but there is a reason the editors generate the files.

Anyway, an alternative to disabling them is to move them to a dedicated folder:

                                        ; Move autosave/backup files elsewhere.
(setq auto-save-file-name-transforms '((".*" "~/.emacs-saves/" t)))
(setq lock-file-name-transforms '((".*" "~/.emacs-saves/" t)))
(setq backup-directory-alist '((".*" . "~/.emacs-saves/")))

And while I'm here, here's the same for vim:

set directory=/Users/username/.vim/swapfiles//
set backupdir=/Users/username/.vim/backups//
set undodir=/Users/username/.vim/undos//
set undofile
2 Likes

He, the backup files are very precious from time to time.

Saving them in a dedicated folder seems to be a practical solution. Perhaps I can figure out some project specific - I need to think about it.

1 Like

Too bad. I guess this is what is called PITA.

There is .dir-locals.el. Looks promising. See Per-Directory Local Variables in the friendly emacs manual.

1 Like