diff --git a/configuration.org b/configuration.org index 6ca5799..784e340 100644 --- a/configuration.org +++ b/configuration.org @@ -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~