1
0
Fork 0

[oni-org] Automatically generate faces for priorities in org-mode

This commit is contained in:
Tom Willemse 2023-09-18 23:36:11 -07:00
parent 655ce45b2f
commit 64dd1938fd

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org> ;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local ;; Keywords: local
;; Version: 2023.0911.210345 ;; Version: 2023.0918.233520
;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-bullets org-edna diminish all-the-icons olivetti form-feed org-pretty-table ob-async) ;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-bullets org-edna diminish all-the-icons olivetti form-feed org-pretty-table ob-async)
;; This program is free software; you can redistribute it and/or modify ;; This program is free software; you can redistribute it and/or modify
@ -48,6 +48,7 @@
(require 'org-habit) (require 'org-habit)
(require 'org-protocol) (require 'org-protocol)
(require 'org-roam) (require 'org-roam)
(require 'range)
(require 'subr-x) (require 'subr-x)
(require 'yasnippet) (require 'yasnippet)
@ -282,6 +283,17 @@ located at the start of the line."
tags)) tags))
org-tag-faces)) org-tag-faces))
(defun oni-org-generate-priority-faces ()
"Create faces for all the priorities in the current buffer."
(let (new-faces)
(range-map
(lambda (x) (push (cons x (oni-org-color-for x)) new-faces))
(cons (min org-priority-highest
org-priority-lowest)
(max org-priority-lowest
org-priority-highest)))
new-faces))
(defun oni-org-set-todo-keyword-faces () (defun oni-org-set-todo-keyword-faces ()
"Set org-todo-keyword-faces to all different colors." "Set org-todo-keyword-faces to all different colors."
(setq org-todo-keyword-faces (oni-org-generate-todo-keyword-faces))) (setq org-todo-keyword-faces (oni-org-generate-todo-keyword-faces)))
@ -291,6 +303,11 @@ located at the start of the line."
(setq org-tag-faces (oni-org-generate-tag-faces)) (setq org-tag-faces (oni-org-generate-tag-faces))
(org-set-tag-faces 'org-tag-faces org-tag-faces)) (org-set-tag-faces 'org-tag-faces org-tag-faces))
(defun oni-org-set-priority-faces ()
"Set org-priority-faces to all different colors."
(setq org-priority-faces
(map-merge 'alist org-priority-faces (oni-org-generate-priority-faces))))
;;;###autoload(autoload 'oni-hydra-org/body "oni-org") ;;;###autoload(autoload 'oni-hydra-org/body "oni-org")
(defhydra oni-hydra-org (:color teal :hint nil) (defhydra oni-hydra-org (:color teal :hint nil)
" "
@ -521,6 +538,7 @@ also move point to the start of the heading."
(add-hook 'before-save-hook #'oni-org-update-all-dblocks-live) (add-hook 'before-save-hook #'oni-org-update-all-dblocks-live)
(add-hook 'org-mode-hook #'oni-org-set-tag-faces) (add-hook 'org-mode-hook #'oni-org-set-tag-faces)
(add-hook 'org-mode-hook #'oni-org-set-todo-keyword-faces) (add-hook 'org-mode-hook #'oni-org-set-todo-keyword-faces)
(add-hook 'org-mode-hook #'oni-org-set-priority-faces)
(add-hook 'org-mode-hook #'oni-org-set-yasnippet-condition) (add-hook 'org-mode-hook #'oni-org-set-yasnippet-condition)
(add-hook 'org-mode-hook 'electric-pair-local-mode) (add-hook 'org-mode-hook 'electric-pair-local-mode)
(add-hook 'org-mode-hook 'electric-quote-local-mode) (add-hook 'org-mode-hook 'electric-quote-local-mode)