aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshton Wiersdorf <ashton.wiersdorf@pobox.com>2023-02-22 00:37:40 -0700
committerAshton Wiersdorf <ashton.wiersdorf@pobox.com>2023-02-22 00:37:40 -0700
commit411b56ffa3e082ab2dfdca6deccb1cb523d46b9e (patch)
tree21ad50ea45ebbd70296920e5029d3bff572ae50e
parent0d0d5ce95aec430c5848650dd12110eaa07d24af (diff)
Make backups go into ~/.emacs.d/emacs-backup/ instead of working dir
Closes #5
-rw-r--r--.gitignore1
-rw-r--r--init.el12
2 files changed, 13 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 663e6d4..20ce8bb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@
/transient/
/auto-save-list/
/eshell/
+/projects
diff --git a/init.el b/init.el
index 367a7e1..ff86a5c 100644
--- a/init.el
+++ b/init.el
@@ -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