Created
May 6, 2018 05:24
-
-
Save travisbhartwell/7c8156660033eb12b41203661a894072 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
(defun tbh/setup-org-layout () | |
"Arrange the buffers in the custom Org layout defined in the built-in layer" | |
(interactive) | |
;; Switch to the perspective | |
(spacemacs/custom-perspective-@Org) | |
;; Reset to just one window | |
(delete-other-windows) | |
(let* | |
;; Open worklog | |
((worklog-buffer (find-file (f-join org-directory "worklog.org"))) | |
;; Open inbox | |
(inbox-buffer (find-file (f-join org-directory "inbox.org"))) | |
;; Find the heading for today, if it exists | |
(day-heading-string (format-time-string "%a %Y-%m-%d")) | |
(headline-pos (org-find-exact-headline-in-buffer day-heading-string worklog-buffer)) | |
;; The top window will be 1 / 3 frame height | |
(new-window-height (floor (/ (frame-height) 3)))) | |
;; Create the bottom window | |
(split-window nil new-window-height 'below) | |
;; Show the worklog in the lower window | |
(switch-to-buffer-other-window worklog-buffer) | |
;; If a headline for today exists | |
(if headline-pos | |
;; Make a new indirect buffer showing just today's worklog. | |
(progn | |
(goto-char headline-pos) | |
(org-tree-to-indirect-buffer)) | |
(message "No heading exists for today."))) | |
(goto-char (point-max))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment