diff options
author | Case Duckworth | 2022-07-21 00:04:47 -0500 |
---|---|---|
committer | Case Duckworth | 2022-07-21 00:04:47 -0500 |
commit | cb9cfc5731d7f9e47d00fe5f3ff0077e99b668f7 (patch) | |
tree | 883ba8090c4890eff7471719993e7a56cad17e71 /lisp/user-save.el | |
parent | meh (diff) | |
download | emacs-cb9cfc5731d7f9e47d00fe5f3ff0077e99b668f7.tar.gz emacs-cb9cfc5731d7f9e47d00fe5f3ff0077e99b668f7.zip |
bleh
Diffstat (limited to 'lisp/user-save.el')
-rw-r--r-- | lisp/user-save.el | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lisp/user-save.el b/lisp/user-save.el index 1c04c9d..674abac 100644 --- a/lisp/user-save.el +++ b/lisp/user-save.el | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | (defgroup user-save nil | 21 | (defgroup user-save nil |
22 | "Group for `user-save-mode' customizations." | 22 | "Group for `user-save-mode' customizations." |
23 | :group 'emacs | 23 | :group 'files |
24 | :prefix "user-save-") | 24 | :prefix "user-save-") |
25 | 25 | ||
26 | (defcustom user-save-hook-into-kill-emacs nil | 26 | (defcustom user-save-hook-into-kill-emacs nil |
@@ -39,8 +39,13 @@ Each predicate will be called with no arguments, and if it | |||
39 | returns t, will inhibit `user-save-mode' from activating." | 39 | returns t, will inhibit `user-save-mode' from activating." |
40 | :type '(repeat function)) | 40 | :type '(repeat function)) |
41 | 41 | ||
42 | (defvar user-save-hook nil | 42 | (defcustom user-save-before-save-hook nil |
43 | "Hook to run when the user, not Emacs, saves the buffer.") | 43 | "Hook to run before the user, not Emacs, saves the buffer." |
44 | :type 'hook) | ||
45 | |||
46 | (defcustom user-save-after-save-hook nil | ||
47 | "Hook to run after the user, not Emacs, saves the buffer." | ||
48 | :type 'hook) | ||
44 | 49 | ||
45 | (defvar user-save-mode-map (let ((map (make-sparse-keymap))) | 50 | (defvar user-save-mode-map (let ((map (make-sparse-keymap))) |
46 | (define-key map (kbd "C-x C-s") #'user-save-buffer) | 51 | (define-key map (kbd "C-x C-s") #'user-save-buffer) |
@@ -49,11 +54,13 @@ returns t, will inhibit `user-save-mode' from activating." | |||
49 | "Keymap for `user-save-mode'. | 54 | "Keymap for `user-save-mode'. |
50 | This map shadows the default map for `save-buffer'.") | 55 | This map shadows the default map for `save-buffer'.") |
51 | 56 | ||
52 | (defun user-save-run-hooks (&rest _) | 57 | (defun user-save-run-hooks (which &rest _) |
53 | "Run the hooks in `user-save-hook'. | 58 | "Run the hooks in one of the user-save-hooks. |
59 | If WHICH is `'before', run `user-save-before-save-hook'; | ||
60 | if it's `after', run `user-save-after-save-hook'. | ||
54 | This does /not/ also save the buffer." | 61 | This does /not/ also save the buffer." |
55 | (with-demoted-errors "User-save-hook error: %S" | 62 | (with-demoted-errors "User-save-hook error: %S" |
56 | (run-hooks 'user-save-hook))) | 63 | (run-hooks (intern (format "user-save-%s-save-hook" which))))) |
57 | 64 | ||
58 | (defun user-save-non-file-buffer-p (&optional buffer-or-name) | 65 | (defun user-save-non-file-buffer-p (&optional buffer-or-name) |
59 | "Return whether BUFFER-OR-NAME is a non-file buffer. | 66 | "Return whether BUFFER-OR-NAME is a non-file buffer. |
@@ -74,8 +81,9 @@ run all the time, put them in `user-save-hook'. | |||
74 | ARG is passed directly to `save-buffer'." | 81 | ARG is passed directly to `save-buffer'." |
75 | (interactive '(called-interactively)) | 82 | (interactive '(called-interactively)) |
76 | (message "User-Saving the buffer...") | 83 | (message "User-Saving the buffer...") |
77 | (user-save-run-hooks) | 84 | (user-save-run-hooks 'before) |
78 | (save-buffer arg) | 85 | (save-buffer arg) |
86 | (user-save-run-hooks 'after) | ||
79 | (message "User-Saving the buffer...Done.")) | 87 | (message "User-Saving the buffer...Done.")) |
80 | 88 | ||
81 | (defun user-save-some-buffers (&optional pred) | 89 | (defun user-save-some-buffers (&optional pred) |