;;; +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