From 129eebcf2afa8132c843e047cf86450d362f6c62 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 03:03:41 -0400 Subject: [PATCH] Only configure org-habit if in org-modules Rather than force org-habit even on folks that don't use it. --- modules/lang/org/config.el | 40 +++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 78121f800..8e37a6116 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -436,27 +436,6 @@ underlying, modified buffer. This fixes that." (variable . "revealjs-url=https://revealjs.com"))))) -(defun +org-init-habit-h () - "TODO" - (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'" - (require '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 () "Getting org to behave." ;; Open file links in current window, rather than new ones @@ -994,7 +973,6 @@ compelling reason, so..." #'+org-init-capture-frame-h #'+org-init-custom-links-h #'+org-init-export-h - #'+org-init-habit-h #'+org-init-hacks-h #'+org-init-keybinds-h #'+org-init-popup-rules-h @@ -1030,6 +1008,24 @@ compelling reason, so..." (setq org-id-track-globally 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 ;; writeable before trying to read/write to it. (defadvice! +org--fail-gracefully-a (&rest _)