summaryrefslogtreecommitdiff
path: root/config/files/config-files-backup-on-save-hook.el
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2022-07-03 23:20:44 -0400
committerJohn Turner <jturner.usa@gmail.com>2022-07-03 23:20:44 -0400
commitc284f5b2c4e4ed72a2a060cb91353408f5a2b416 (patch)
tree9902357b42b23071df6b6aa2668aac14e805f6be /config/files/config-files-backup-on-save-hook.el
parent250b3ef0d5c3cbc39129ce632838994a17f57fa2 (diff)
downloademacs.d-c284f5b2c4e4ed72a2a060cb91353408f5a2b416.tar.gz
moved non-config functions into a new lisp directory
We will now put non-config related functions (any elisp libraries or snippets that I write) into a new ".emacs.d/lisp" directory and separate them from the config code in the ".emacs.d/config" directory. During the transition I decided to move and rewrite the logic that adds all of the libraries to load-path. Now this logic is in two top level files (load-config.el load-local-lisp.el). I needed to remove the config-programming-languages module because it conflicted with the new load-path logic (it was mostly useless anyways). The man advice functions are deleted in this commit but they will be added into the new ".emacs.d/lisp" directory soon.
Diffstat (limited to 'config/files/config-files-backup-on-save-hook.el')
-rw-r--r--config/files/config-files-backup-on-save-hook.el50
1 files changed, 0 insertions, 50 deletions
diff --git a/config/files/config-files-backup-on-save-hook.el b/config/files/config-files-backup-on-save-hook.el
deleted file mode 100644
index 53b96d1..0000000
--- a/config/files/config-files-backup-on-save-hook.el
+++ /dev/null
@@ -1,50 +0,0 @@
-(defvar config-files-backup-directory (file-name-concat user-emacs-directory "backups"))
-
-(unless (file-exists-p config-files-backup-directory)
- (mkdir config-files-backup-directory))
-
-(defun config-files-format-backup-path (path number)
- (format "%s.~%s~" path number))
-
-(defun config-files-backup-extension (path)
- (let* ((i (string-search "." (reverse path)))
- (extension (substring path (- (length path) i))))
- extension))
-
-(defun config-files-backup-no-extension (path)
- (let* ((i (string-search "." (reverse path)))
- (no-extension (substring path 0 (- (length path) (+ i 1)))))
- no-extension))
-
-(defun config-files-backup-number (path)
- (let* ((extension (config-files-backup-extension path))
- (extracted (substring extension 1 (- (length extension) 1)))
- (as-number (unless (zerop (length extracted))
- (string-to-number extracted))))
- as-number))
-
-(defun config-files-shift-path (path)
- (let* ((without-extension (config-files-backup-no-extension path))
- (number (config-files-backup-number path))
- (next-number (+ number 1))
- (shifted-path (config-files-format-backup-path
- without-extension
- next-number)))
- shifted-path))
-
-(defun config-files-shift-backup (path)
- (let ((next-path (config-files-shift-path path)))
- (when (file-exists-p next-path)
- (config-files-shift-backup next-path))
- (rename-file path next-path)))
-
-(defun config-files-backup-before-save ()
- (unless backup-inhibited
- (let* ((path (buffer-file-name))
- (backup-path (config-files-format-backup-path path 0)))
- (when (file-exists-p path)
- (when (file-exists-p backup-path)
- (config-files-shift-backup backup-path))
- (copy-file path backup-path)))))
-
-(add-hook 'before-save-hook 'config-files-backup-before-save)