My Technical Notes

Wednesday, 1 June 2016

Emacs Org Mode: Adding PROG Keyword

In Emacs Org Mode, by default you do not have a keyword to represent tasks that have started. For this, I have added a `PROG` keyword. Paste the below code in the `init.el`/`.emacs`:


(setq org-todo-keywords '((sequencep "TODO" "PROG(!)" "DONE")))

Therefore, when cycling through the keywords, we have `PROG` replacing `TODO` to represent that the task has started. The exclamation character means that the state change will be recorded too.

To set the colors of the keywords, paste the following code:


(setq org-todo-keyword-faces '(("TODO" . "#ff1a1a") ("PROG" . "orange") ("DONE" . "green")))

To add code which will color the keyword `PROG` as orange (but will also make `TODO` red and `DONE` green), paste the following code in:


(defun org-latex-format-headline-colored-keywords-function
    (todo todo-type priority text tags info)
  (concat
   (cond ((string= todo "TODO")(and todo (format "{\\color{red}\\bfseries\\sffamily %s} " todo)))
  ((string= todo "DONE")(and todo (format "{\\color{green}\\bfseries\\sffamily %s} " todo)))
  ((string= todo "PROG")(and todo (format "{\\color{orange}\\bfseries\\sffamily %s} " todo))))
   (and priority (format "\\framebox{\\#%c} " priority))
   text
   (and tags
 (format "\\hfill{}\\textsc{%s}"
  (mapconcat (lambda (tag) (org-latex-plain-text tag info))
      tags ":")))))

(setq org-latex-format-headline-function 'org-latex-format-headline-colored-keywords-function)

Note that you need the following in your org file to make it work:


#+LATEX_HEADER: \usepackage{xcolor}

No comments: