Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save travisbhartwell/7c8156660033eb12b41203661a894072 to your computer and use it in GitHub Desktop.
Save travisbhartwell/7c8156660033eb12b41203661a894072 to your computer and use it in GitHub Desktop.
(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