about summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
authorCase Duckworth2022-07-07 23:07:18 -0500
committerCase Duckworth2022-07-07 23:07:18 -0500
commitfde7b61089d3acc8a0ac06e30fe58fb169c2a1af (patch)
tree1652def34c66ccd76440e08af39c0071782428da /lisp
parentUpdate README (diff)
downloademacs-fde7b61089d3acc8a0ac06e30fe58fb169c2a1af.tar.gz
emacs-fde7b61089d3acc8a0ac06e30fe58fb169c2a1af.zip
Add burly
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+burly.el63
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.
19If ARG is passed, ask for the bookmark's name; otherwise, just
20use `+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.
28ARG 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.
36This 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.
46ARG 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.
57The 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