diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/+burly.el | 63 |
1 files changed, 63 insertions, 0 deletions
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 | ||