;;; -*- lexical-binding: t; -*-

(require 'syd/constants)

(setq backup-directory-alist
      `(("." . ,(file-name-concat syd-data-dir "backup")))
      auto-save-list-file-prefix (let ((dir (file-name-concat syd-cache-dir
                                                              "autosave/")))
                                   (make-directory dir t)
                                   dir)
      ;; Nil means untracked files under VC won't get backed up.
      vc-make-backup-files t
      ;; Nil will clobber symlinks.
      backup-by-copying t
      ;; Use versioned backups.
      version-control t
      ;; Don't create ugly lockfiles.  See
      ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Interlocking.html#Interlocking
      ;; This is a good feature, but not very relevant to a single-user system.
      create-lockfiles nil
      auto-save-file-name-transforms
      ;; Good grief, girl...
      `(("\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'"
         ,(concat auto-save-list-file-prefix "tramp-\\2") t)
        (".*"
         ,(file-name-concat syd-cache-dir "autosave") t))
      kept-new-versions 5
      delete-old-versions t)

(provide 'syd/backup)
