org-rainbow-tags icon indicating copy to clipboard operation
org-rainbow-tags copied to clipboard

Colorize org tags automatically to make them visually distinguishable.

#+TITLE: Org Rainbow Tags

[[https://www.gnu.org/software/emacs/][file:https://github.com/minad/corfu/blob/screenshots/emacs.svg?raw=true]] [[https://melpa.org/#/org-rainbow-tags][file:https://melpa.org/packages/org-rainbow-tags-badge.svg]]

This package adds random colors to your org tags. In order to make colors random but consistent between same tags, colors are generated from the hash of the tag names.

Since it's random, results may not make you happy, but there are some custom fields that you can use as ~seed~ to generate different colors. If you are really picky, there is already a built-in solution for you, please see [[https://orgmode.org/manual/Tags.html][org-tag-faces]]. This package aims to get rid of setting and updating ~org-tag-faces~ manually for each tag you use.

  • Contents :TOC:
  • [[#screenshots][Screenshots]]
  • [[#installation][Installation]]
    • [[#manual][Manual]]
    • [[#using-straightel-and-use-package][Using ~straight.el~ and ~use-package~]]
    • [[#melpa][MELPA]]
      • [[#interactively][Interactively]]
      • [[#with-initel-or-emacs][With ~init.el~ or ~.emacs~]]
      • [[#with-use-package][With ~use-package~]]
  • [[#usage][Usage]]
  • [[#known-issues][Known Issues]]
  • Screenshots Default theme without ~org-rainbow-tags~: [[./screenshots/default_theme_without_org_rainbow_tags.png]]

Default theme with ~org-rainbow-tags~: [[./screenshots/default_theme_with_org_rainbow_tags.png]]

Modus vivendi with ~org-rainbow-tags~: [[./screenshots/modus_vivendi_with_org_rainbow_tags.png]]

Modus operandi with ~org-rainbow-tags~: [[./screenshots/modus_operandi_with_org_rainbow_tags.png]]

Modus vivendi with ~org-rainbow-tags~ (with a custom face) [[./screenshots/modus_vivendi_with_org_rainbow_tags_box.png]]

Modus operandi with ~org-rainbow-tags~ (with a custom face) [[./screenshots/modus_operandi_with_org_rainbow_tags_box.png]]

  • Installation ** Manual
  1. Clone this repository
  2. Add these two lines to your init file: #+BEGIN_SRC elisp (add-to-list 'load-path "/path/to/org-rainbow-tags/") (require 'org-rainbow-tags) #+END_SRC

** Using ~straight.el~ and ~use-package~ #+BEGIN_SRC emacs-lisp (use-package org-rainbow-tags :straight (:host github :repo "KaratasFurkan/org-rainbow-tags")) #+END_SRC

** MELPA You need to enable package installations from MELPA if you didn't already. /(See: https://melpa.org/#/getting-started)/ #+BEGIN_SRC emacs-lisp (require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (package-initialize) #+END_SRC

*** Interactively ~M-x package-install RET org-rainbow-tags RET~

*** With ~init.el~ or ~.emacs~ #+BEGIN_SRC emacs-lisp (unless (package-installed-p 'org-rainbow-tags) (package-install 'org-rainbow-tags)) (require 'org-rainbow-tags) #+END_SRC

*** With ~use-package~ #+BEGIN_SRC emacs-lisp (use-package org-rainbow-tags :ensure t) #+END_SRC

  • Usage You can run ~org-rainbow-tags-mode~ command in the buffer you wanna colorize the tags.

If you wanna run this minor mode on ~org~ files automatically, you can add a hook:

#+BEGIN_SRC emacs-lisp (add-hook 'org-mode-hook 'org-rainbow-tags-mode) #+END_SRC

To see customization options, you can run ~M-x customize-group RET org-rainbow-tags RET~ or you can check ~(defcustom ...)~ lines in ~org-rainbow-tags.el~.

If you don't like the auto-generated colors for your favorite tags, you can change the value of ~org-rainbow-tags-hash-start-index~ between 0-20. This variable decides which 12 characters of the hash of the tag should be taken to generate the color.

Example: #+BEGIN_SRC emacs-lisp (setq org-rainbow-tags-hash-start-index 10) #+END_SRC

Full ~use-package~ example: #+BEGIN_SRC emacs-lisp (use-package org-rainbow-tags :ensure t :custom (org-rainbow-tags-hash-start-index 10) (org-rainbow-tags-extra-face-attributes ;; Default is '(:weight 'bold) '(:inverse-video t :box t :weight 'bold)) :hook (org-mode . org-rainbow-tags-mode)) #+END_SRC

  • Known Issues ~org-rainbow-tags-mode~ colorizes org tags when it's activated and also when a new tag is added/updated with ~org-set-tags-command~ or with ~C-c C-c~ on the headline. However, colors will not updated when you edit the tags manually. If you wanna update colors in every circumstances, you can add this line to your configuration:

#+BEGIN_SRC emacs-lisp (add-hook 'org-mode-hook (lambda () (add-hook 'post-command-hook 'org-rainbow-tags--apply-overlays nil t))) #+END_SRC

This is not default because it may cause performance issues on org files. You can try it and decide if it's okay or not.