Created
April 22, 2014 17:57
-
-
Save jordonbiondo/11188542 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| ;; Win config stack | |
| ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| (defvar winstack-stack '() | |
| "A Stack holding window configurations. | |
| Use `winstack-push' and | |
| `winstack-pop' to modify it.") | |
| (defun winstack-push() | |
| "Push the current window configuration onto `winstack-stack'." | |
| (interactive) | |
| (if (and (window-configuration-p (first winstack-stack)) | |
| (compare-window-configurations (first winstack-stack) (current-window-configuration))) | |
| (message "Current config already pushed") | |
| (progn (push (current-window-configuration) winstack-stack) | |
| (message (concat "pushed " (number-to-string | |
| (length (window-list (selected-frame)))) " frame config"))))) | |
| (defun winstack-pop() | |
| "Pop the last window configuration off `winstack-stack' and apply it." | |
| (interactive) | |
| (if (first winstack-stack) | |
| (progn (set-window-configuration (pop winstack-stack)) | |
| (message "popped")) | |
| (message "End of window stack"))) | |
| ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| ;; Break taker | |
| ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| (defvar bt/enabled t | |
| "Whether or not to repeat breaks.") | |
| (defvar bt/last-break-minutes 60) | |
| (defvar bt/snooze-time 5 | |
| "Amount of time in minutes to use for snoozes") | |
| (defun bt/exit-and-repeat-last () | |
| (interactive) | |
| (winstack-pop) | |
| (break-taker bt/last-break-minutes)) | |
| (defun bt/exit () | |
| (interactive) | |
| (winstack-pop)) | |
| (defun bt/snooze () | |
| (interactive) | |
| (let ((old-time bt/last-break-minutes)) | |
| (break-taker bt/snooze-time) | |
| (setq bt/last-break-minutes old-time))) | |
| (defun bt/exit-and-snooze () | |
| (interactive) | |
| (bt/exit) | |
| (let ((old-time bt/last-break-minutes)) | |
| (break-taker bt/snooze-time) | |
| (setq bt/last-break-minutes old-time))) | |
| (defun break-taker (minutes) | |
| (interactive "NMinutes between breaks: ") | |
| (lexical-let ((minutes (abs minutes))) | |
| (setq bt/last-break-minutes minutes) | |
| (run-with-timer (* 60 minutes) nil | |
| (lambda(&rest args) | |
| (winstack-push) | |
| (switch-to-buffer "*Break Taker*") | |
| (read-only-mode t) | |
| (let ((inhibit-read-only t) | |
| (fill-column (frame-width))) | |
| (delete-other-windows) | |
| (delete-region (point-min) (point-max)) | |
| (insert "\n\n\n") | |
| (insert (propertize "Time to take a break, walk around a bit!" 'face | |
| `(:inherit font-lock-function-name-face))) | |
| (insert "\n\n\n") | |
| (insert "Press 'C-c C-k' to resume\n\n") | |
| (insert (format (concat "Press 'C-c C-c' to resume and take another break in %d minutes\n\n" | |
| "Press 'C-c C-w' to postpone your break %d minutes") minutes bt/snooze-time)) | |
| (set-justification-center (point-min) (point-max)) | |
| (with-current-buffer "*Break Taker*" | |
| (local-set-key (kbd "C-c C-k") 'bt/exit) | |
| (local-set-key (kbd "C-c C-c") 'bt/exit-and-repeat-last) | |
| (local-set-key (kbd "C-c C-w") 'bt/exit-and-snooze))))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment