diff options
-rw-r--r-- | init.el | 5 | ||||
-rw-r--r-- | lisp/+burly.el | 63 |
2 files changed, 67 insertions, 1 deletions
diff --git a/init.el b/init.el index b057344..1b08fe7 100644 --- a/init.el +++ b/init.el | |||
@@ -54,7 +54,6 @@ | |||
54 | "C-<backspace>" #'+backward-kill-word | 54 | "C-<backspace>" #'+backward-kill-word |
55 | "C-x TAB" #'+indent-rigidly | 55 | "C-x TAB" #'+indent-rigidly |
56 | "<f7>" #'flyspell-mode | 56 | "<f7>" #'flyspell-mode |
57 | "C-x C-c" #'+save-buffers-quit | ||
58 | "C-\\" nil ; original: toggle-input-method | 57 | "C-\\" nil ; original: toggle-input-method |
59 | "C-/" #'undo-only | 58 | "C-/" #'undo-only |
60 | "C-?" #'undo-redo) | 59 | "C-?" #'undo-redo) |
@@ -1137,6 +1136,10 @@ | |||
1137 | browse-kill-ring-separator "") | 1136 | browse-kill-ring-separator "") |
1138 | (:hook #'form-feed-mode)) | 1137 | (:hook #'form-feed-mode)) |
1139 | 1138 | ||
1139 | (setup (:straight burly) | ||
1140 | (:require burly +burly) | ||
1141 | (:global "C-x C-c" #'+burly-save-then-close-frame-remembering)) | ||
1142 | |||
1140 | (setup (:straight (cape :host github :repo "minad/cape")) | 1143 | (setup (:straight (cape :host github :repo "minad/cape")) |
1141 | (let | 1144 | (let |
1142 | ;; All available cape capfs listed here. Add them to the front since | 1145 | ;; All available cape capfs listed here. Add them to the front since |
diff --git a/lisp/+burly.el b/lisp/+burly.el new file mode 100644 index 0000000..a32bc97 --- /dev/null +++ b/lisp/+burly.el | |||
@@ -0,0 +1,63 @@ | |||
1 | ;;; +burly.el --- Bespoke burly add-ons -*- lexical-binding: t; -*- | ||
2 | |||
3 | ;;; Commentary: | ||
4 | |||
5 | ;;; Code: | ||
6 | |||
7 | (require 'burly) | ||
8 | |||
9 | (defgroup +burly nil | ||
10 | "Extra `burly' customizations." | ||
11 | :group 'burly | ||
12 | :prefix "+burly-") | ||
13 | |||
14 | (defcustom +burly-windows-bookmark-name "pre-close-window-config" | ||
15 | "The name of the window config bookmark pre-frame deletion.") | ||
16 | |||
17 | (defun +burly--get-name (arg) | ||
18 | "Get the name of a Burly bookmark to restore. | ||
19 | If ARG is passed, ask for the bookmark's name; otherwise, just | ||
20 | use `+burly-windows-bookmark-name'." | ||
21 | (if arg | ||
22 | (completing-read "Save Burly bookmark: " (burly-bookmark-names) | ||
23 | nil nil burly-bookmark-prefix) | ||
24 | +burly-windows-bookmark-name)) | ||
25 | |||
26 | (defun +burly-recover-windows-bookmark (&optional arg frame) | ||
27 | "Recover the window configuration from a previous bookmark. | ||
28 | ARG is passed to `+burly--get-name', which see." | ||
29 | (interactive (list current-prefix-arg | ||
30 | (selected-frame))) | ||
31 | (with-selected-frame frame | ||
32 | (burly-open-bookmark (+burly--get-name arg)))) | ||
33 | |||
34 | (defun +burly--recover-windows-on-new-frame (frame) | ||
35 | "Recover the current window configuration in a new frame. | ||
36 | This function removes itself from `after-make-frame-functions'." | ||
37 | ;; XXX: For some reason, *scratch* pops up. So I need to run this after a | ||
38 | ;; short delay, which sadly causes a flash of *scratch*. | ||
39 | (run-with-idle-timer 0.1 nil | ||
40 | (lambda (f) (+burly-recover-windows-bookmark nil f)) | ||
41 | frame) | ||
42 | (remove-hook 'after-make-frame-functions #'+burly--recover-windows-on-new-frame)) | ||
43 | |||
44 | (defun +burly-save-then-close-frame (&optional arg) | ||
45 | "Save window configuration and close the frame. | ||
46 | ARG is passed to `+burly--get-name', which see." | ||
47 | (interactive "P") | ||
48 | (if (not (frame-parameter nil 'client)) | ||
49 | (when (yes-or-no-p "Sure you want to quit? ") | ||
50 | (save-buffers-kill-emacs)) | ||
51 | (save-some-buffers t) | ||
52 | (burly-bookmark-windows (+burly--get-name arg)) | ||
53 | (delete-frame nil :force))) | ||
54 | |||
55 | (defun +burly-save-then-close-frame-remembering () | ||
56 | "Save window configurations and close the frame. | ||
57 | The next frame created will restore the window configuration." | ||
58 | (interactive) | ||
59 | (add-hook 'after-make-frame-functions #'+burly--recover-windows-on-new-frame 90) | ||
60 | (+burly-save-then-close-frame)) | ||
61 | |||
62 | (provide '+burly) | ||
63 | ;;; +burly.el ends here | ||