Fix #3102: move org-habit init back into hook

This commit is contained in:
Henrik Lissner 2020-05-12 05:15:55 -04:00
parent 066119849d
commit bc5bbb1770
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -435,6 +435,26 @@ relative to `org-directory', unless it is an absolute path."
(variable . "revealjs-url=https://revealjs.com"))))) (variable . "revealjs-url=https://revealjs.com")))))
(defun +org-init-habit-h ()
(add-hook! 'org-agenda-mode-hook
(defun +org-habit-resize-graph-h ()
"Right align and resize the consistency graphs based on
`+org-habit-graph-window-ratio'"
(when (featurep 'org-habit)
(let* ((total-days (float (+ org-habit-preceding-days org-habit-following-days)))
(preceding-days-ratio (/ org-habit-preceding-days total-days))
(graph-width (floor (* (window-width) +org-habit-graph-window-ratio)))
(preceding-days (floor (* graph-width preceding-days-ratio)))
(following-days (- graph-width preceding-days))
(graph-column (- (window-width) (+ preceding-days following-days)))
(graph-column-adjusted (if (> graph-column +org-habit-min-width)
(- graph-column +org-habit-graph-padding)
nil)))
(setq-local org-habit-preceding-days preceding-days)
(setq-local org-habit-following-days following-days)
(setq-local org-habit-graph-column graph-column-adjusted))))))
(defun +org-init-hacks-h () (defun +org-init-hacks-h ()
"Getting org to behave." "Getting org to behave."
;; Open file links in current window, rather than new ones ;; Open file links in current window, rather than new ones
@ -972,6 +992,7 @@ compelling reason, so..."
#'+org-init-capture-frame-h #'+org-init-capture-frame-h
#'+org-init-custom-links-h #'+org-init-custom-links-h
#'+org-init-export-h #'+org-init-export-h
#'+org-init-habit-h
#'+org-init-hacks-h #'+org-init-hacks-h
#'+org-init-keybinds-h #'+org-init-keybinds-h
#'+org-init-popup-rules-h #'+org-init-popup-rules-h
@ -1007,24 +1028,6 @@ compelling reason, so..."
(setq org-id-track-globally t (setq org-id-track-globally t
org-id-locations-file-relative t) org-id-locations-file-relative t)
(add-hook! 'org-agenda-mode-hook
(defun +org-habit-resize-graph-h ()
"Right align and resize the consistency graphs based on
`+org-habit-graph-window-ratio'"
(when (featurep 'org-habit)
(let* ((total-days (float (+ org-habit-preceding-days org-habit-following-days)))
(preceding-days-ratio (/ org-habit-preceding-days total-days))
(graph-width (floor (* (window-width) +org-habit-graph-window-ratio)))
(preceding-days (floor (* graph-width preceding-days-ratio)))
(following-days (- graph-width preceding-days))
(graph-column (- (window-width) (+ preceding-days following-days)))
(graph-column-adjusted (if (> graph-column +org-habit-min-width)
(- graph-column +org-habit-graph-padding)
nil)))
(setq-local org-habit-preceding-days preceding-days)
(setq-local org-habit-following-days following-days)
(setq-local org-habit-graph-column graph-column-adjusted)))))
;; HACK `org-id' doesn't check if `org-id-locations-file' exists or is ;; HACK `org-id' doesn't check if `org-id-locations-file' exists or is
;; writeable before trying to read/write to it. ;; writeable before trying to read/write to it.
(defadvice! +org--fail-gracefully-a (&rest _) (defadvice! +org--fail-gracefully-a (&rest _)