blob: a32bc97d6148ea3f00a6255d2e5dbc8d9a4ec6d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
;;; +burly.el --- Bespoke burly add-ons -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:
(require 'burly)
(defgroup +burly nil
"Extra `burly' customizations."
:group 'burly
:prefix "+burly-")
(defcustom +burly-windows-bookmark-name "pre-close-window-config"
"The name of the window config bookmark pre-frame deletion.")
(defun +burly--get-name (arg)
"Get the name of a Burly bookmark to restore.
If ARG is passed, ask for the bookmark's name; otherwise, just
use `+burly-windows-bookmark-name'."
(if arg
(completing-read "Save Burly bookmark: " (burly-bookmark-names)
nil nil burly-bookmark-prefix)
+burly-windows-bookmark-name))
(defun +burly-recover-windows-bookmark (&optional arg frame)
"Recover the window configuration from a previous bookmark.
ARG is passed to `+burly--get-name', which see."
(interactive (list current-prefix-arg
(selected-frame)))
(with-selected-frame frame
(burly-open-bookmark (+burly--get-name arg))))
(defun +burly--recover-windows-on-new-frame (frame)
"Recover the current window configuration in a new frame.
This function removes itself from `after-make-frame-functions'."
;; XXX: For some reason, *scratch* pops up. So I need to run this after a
;; short delay, which sadly causes a flash of *scratch*.
(run-with-idle-timer 0.1 nil
(lambda (f) (+burly-recover-windows-bookmark nil f))
frame)
(remove-hook 'after-make-frame-functions #'+burly--recover-windows-on-new-frame))
(defun +burly-save-then-close-frame (&optional arg)
"Save window configuration and close the frame.
ARG is passed to `+burly--get-name', which see."
(interactive "P")
(if (not (frame-parameter nil 'client))
(when (yes-or-no-p "Sure you want to quit? ")
(save-buffers-kill-emacs))
(save-some-buffers t)
(burly-bookmark-windows (+burly--get-name arg))
(delete-frame nil :force)))
(defun +burly-save-then-close-frame-remembering ()
"Save window configurations and close the frame.
The next frame created will restore the window configuration."
(interactive)
(add-hook 'after-make-frame-functions #'+burly--recover-windows-on-new-frame 90)
(+burly-save-then-close-frame))
(provide '+burly)
;;; +burly.el ends here
|