Save backup files under Emacs’ cache directory
This commit is contained in:
parent
fa6d517fe0
commit
96493792a3
@ -97,6 +97,19 @@ I set it up early so I can use it in ~use-package~ calls immediately.
|
||||
mult)))))
|
||||
#+END_SRC
|
||||
|
||||
*** Make a backup filename under ~user-emacs-cache-directory~
|
||||
|
||||
Taken from [[http://ergoemacs.org/emacs/emacs_set_backup_into_a_directory.html][Xah’s site]].
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun xah/backup-file-name (fpath)
|
||||
"Return a new file path for FPATH under `user-emacs-cache-directory'"
|
||||
(let* ((backup-root-dir (concat user-emacs-cache-directory "/backup"))
|
||||
(file-path (replace-regexp-in-string "[A-Za-z]:" ""))
|
||||
(backup-file-path (replace-regexp-in-string "//" "/" (concat backup-root-dir file-path "~"))))
|
||||
(make-directory (file-name-directory backup-file-path) (file-name-directory backup-file-path))
|
||||
backup-file-path))
|
||||
#+END_SRC
|
||||
** Check if we are running under Termux
|
||||
|
||||
We need to do things differently, if so.
|
||||
@ -1047,10 +1060,7 @@ Because I’m a sysadmin, too.
|
||||
(use-package files
|
||||
:ensure nil
|
||||
:config
|
||||
(setq backup-directory-alist
|
||||
`((".*" . ,temporary-file-directory)))
|
||||
(setq auto-save-file-name-transforms
|
||||
`((".*" ,temporary-file-directory t))))
|
||||
(setq make-backup-file-name-function 'xah/backup-file-name))
|
||||
#+END_SRC
|
||||
|
||||
** ~whitespace~
|
||||
|
Loading…
Reference in New Issue
Block a user