Skip to content

Commit

Permalink
Make backups go into ~/.emacs.d/emacs-backup/ instead of working dir
Browse files Browse the repository at this point in the history
Closes #5
  • Loading branch information
ashton314 committed Feb 22, 2023
1 parent 0d0d5ce commit 411b56f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/transient/
/auto-save-list/
/eshell/
/projects
12 changes: 12 additions & 0 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@
;; Move through windows with Ctrl-<arrow keys>
(windmove-default-keybindings 'control) ; You can use other modifiers here

;; Don't litter filesystem with *~ backup files; put them all inside
;; ~/.emacs.d/backup or wherever
(defun bedrock--backup-file-name (fpath)
"Return a new file path of a given file path.
If the new path's directories does not exist, create them."
(let* ((backupRootDir "~/.emacs.d/emacs-backup/")
(filePath (replace-regexp-in-string "[A-Za-z]:" "" fpath )) ; remove Windows driver letter in path, for example, “C:”
(backupFilePath (replace-regexp-in-string "//" "/" (concat backupRootDir filePath "~") )))
(make-directory (file-name-directory backupFilePath) (file-name-directory backupFilePath))
backupFilePath))
(setq make-backup-file-name-function 'bedrock--backup-file-name)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Discovery aids
Expand Down

0 comments on commit 411b56f

Please sign in to comment.