From 6697d5af83649262fac7b6f194e8172bbe86e73b Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Thu, 28 Jan 2016 02:08:38 +0100 Subject: Dynamically generate keyword and tag faces --- emacs/.emacs.d/site-lisp/org-init.el | 52 ++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'emacs/.emacs.d/site-lisp/org-init.el') diff --git a/emacs/.emacs.d/site-lisp/org-init.el b/emacs/.emacs.d/site-lisp/org-init.el index bd35f41..9281c25 100644 --- a/emacs/.emacs.d/site-lisp/org-init.el +++ b/emacs/.emacs.d/site-lisp/org-init.el @@ -26,6 +26,7 @@ (require 'org-habit) (require 'org-crypt) +(require 'subr-x) (eval-when-compile (require 'desktop) @@ -133,6 +134,28 @@ predecessor if there is a non-DONE sibling defined before it." (point)) (point-max))) +(defun oni:org-generate-todo-keyword-faces () + "Create faces for all todo keywords in the current buffer." + (when-let ((keywords (cl-remove-if (lambda (tag) (assoc tag org-todo-keyword-faces)) + org-todo-keywords-1))) + (setq org-todo-keyword-faces + (append org-todo-keyword-faces + (mapcar (lambda (keyword) + (cons keyword (oni:color-for keyword))) + keywords))))) + +(defun oni:org-generate-tag-faces () + "Create faces for all tags in the current buffer." + (when-let ((tags (cl-remove-if (lambda (tag) (assoc (car tag) org-tag-faces)) + (org-get-buffer-tags)))) + (setq org-tag-faces + (append org-tag-faces + (mapcar (lambda (tag) + (let ((tag (car tag))) + (cons tag (oni:color-for tag)))) + tags))) + (org-set-tag-faces 'org-tag-faces org-tag-faces))) + (defun org-init-skip-tags () "Skip the \"ex\" and \"unconfirmed\" tags." (let ((tags (org-get-tags-at (point)))) @@ -230,29 +253,10 @@ predecessor if there is a non-DONE sibling defined before it." (setq org-tags-column (- 70)) (setq org-tags-exclude-from-inheritance '("crypt")) (setq org-todo-keyword-faces - (append '(("ADDED" . "#65a854") - ("CHANGED" . "#8d995c") - ("REMOVED" . "#a85454")) - (oni:org-colors-for '("TODO" "WIP" "DONE" "CANCELLED" "FAILED" - "ACQUIRE" "IGNORED" "COMMENT" "GOT" - "TOREAD" "READING" "READ" - "PLAY" "PLAYING" "PLAYED" - "LISTEN" "LISTENED")))) -(setq org-tag-faces - (oni:org-colors-for '("noexport" "tv" "dailies" "ex" "maintenance" - "housework" "cdispass" "clark" "emacsd" - "eye_on_manga" "kaarvok" "silbot" "hypo" - "unconfirmed" "gitto" "urxvt_modeline" - "scrumli" "clark_conkeror" - "git_auto_commit_mode" "mode_icons" - "dispassel" "hypo_emacs" "hypocli" - "conkeror" "transient_navigation" "pkgbuilds" - "edocs" "cask" "fiplr" "avandu" - "gitolite_admin" "yoshi_theme" "dvdroid" - "commit_check" "imsleepy" "indent_shift" - "work" "picturefix" "euler" "scss_imenu" - "bookmark" "blog" "shirtlobby" - "roterdamfestivals"))) + '(("ADDED" . "#65a854") + ("CHANGED" . "#8d995c") + ("REMOVED" . "#a85454"))) + (setq org-use-fast-todo-selection t) (setq org-agenda-skip-function-global 'org-init-skip-tags) (setq org-use-property-inheritance '("slug")) @@ -261,6 +265,8 @@ predecessor if there is a non-DONE sibling defined before it." (setq org-insert-heading-respect-content t) (setf (cdar org-blank-before-new-entry) t) +(add-hook 'org-mode-hook #'oni:org-generate-tag-faces) +(add-hook 'org-mode-hook #'oni:org-generate-todo-keyword-faces) (add-hook 'org-agenda-mode-hook 'org-agenda-to-appt) (add-to-list 'org-modules 'org-habit) -- cgit v1.2.3-54-g00ecf