From e1cb8353421d573c404975c3a752a17f251fc9dc Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Mon, 24 Feb 2014 23:16:12 +0100 Subject: Programmatically generate colors for todo and tags --- .emacs.d/site-lisp/org-init.el | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to '.emacs.d/site-lisp') diff --git a/.emacs.d/site-lisp/org-init.el b/.emacs.d/site-lisp/org-init.el index 4ca88bd..a65321d 100644 --- a/.emacs.d/site-lisp/org-init.el +++ b/.emacs.d/site-lisp/org-init.el @@ -37,14 +37,22 @@ (autoload 'org-clocking-p "org-clock") -(eval-after-load "org-crypt" - '(org-crypt-use-before-save-magic)) +(with-eval-after-load 'org-crypt + (org-crypt-use-before-save-magic)) (defun tagify (str) "Remove dots, replace - with _ in STR." (replace-regexp-in-string "-" "_" (replace-regexp-in-string "\\." "" (downcase str)))) +(defun oni:color-for (object) + "Generate a hex color by taking the first 6 characters of OBJECT's MD5 sum." + (format "#%s" (substring (md5 object) 0 6))) + +(defun oni:org-colors-for (names) + "Create an alist for NAMES with corresponding colors." + (mapcar (lambda (name) (cons name (oni:color-for name))) names)) + (defun oni:note-template () (concat "* %<%c>\n" @@ -139,17 +147,20 @@ (setq org-tags-column (- 70)) (setq org-tags-exclude-from-inheritance '("crypt")) (setq org-todo-keyword-faces - '(("TODO" 'font-lock-constant-face) - ("HOLD" 'font-lock-keyword-face) - ("WIP" 'font-lock-variable-name-face) - ("REVIEW" 'font-lock-builtin-face) - ("DONE" 'font-lock-function-name-face) - ("CANCELLED" 'font-lock-comment-face) - ("FAILED" 'font-lock-type-face) - ("ACQUIRE" 'font-lock-constant-face) - ("IGNORED" 'font-lock-comment-face) - ("COMMENT" 'font-lock-comment-delimiter-face) - ("GOT" 'font-lock-function-name-face))) + (oni:org-colors-for '("TODO" "WIP" "DONE" "CANCELLED" "FAILED" + "ACQUIRE" "IGNORED" "COMMENT" "GOT"))) +(setq org-tag-faces + (oni:org-colors-for '("aethon" "noexport" "tv" "myaethon2" + "dailies" "ex" "maintenance" "housework" + "cdispass" "clark" "emacsd" "eye_on_manga" + "kaarvok" "silbot" "myaethon" "hypo" + "unconfirmed" "gitto" "urxvt_modeline" + "scrumli" "clark_conkeror" + "git_auto_commit_mode" "mode_icons" + "dispassel" "hypo_emacs" "hypo_cli" + "conkeror" "transient_navigation" "pkgbuilds" + "edocs" "cask" "fiplr" "avandu" + "gitolite_admin" "yoshi_theme" "dvdroid"))) (setq org-use-fast-todo-selection t) (setq org-agenda-skip-function-global 'org-init-skip-tags) (setq org-use-property-inheritance '("slug")) -- cgit v1.2.3-54-g00ecf