Emacs: Strike through headlines for DONE tasks in Org

I wanted a quick way to visually distinguish DONE tasks from tasks I still need to do. This handy snippet from the Emacs Org-mode mailing list does the trick by striking through the headlines for DONE tasks.

image

Here’s the code:

(setq org-fontify-done-headline t)
(custom-set-faces
 '(org-done ((t (:foreground "PaleGreen"   
                 :weight normal
                 :strike-through t))))
 '(org-headline-done 
            ((((class color) (min-colors 16) (background dark)) 
               (:foreground "LightSalmon" :strike-through t)))))

View my Emacs configuration

  • http://gravatar.com/ispinfx ispinfx

    Nice !

  • Anonymous Coward

    To explicitly set only the strike-through attribute mentioned (and without custom):

    (set-face-attribute ‘org-done nil :strike-through t)
    (set-face-attribute ‘org-headline-done nil :strike-through t)

    You will still need the initial setq.

    Thanks for the tip!

    • http://sachachua.com Sacha Chua

      Helpful. Thanks! =)

  • aap

    Cute, but the shiny green DONE is enough for me.

  • Mathias Dahl

    I had to place the needed stuff in a function and add that to one of the org hooks, like this:

    (defun modify-org-done-face ()
    (setq org-fontify-done-headline t)
    (set-face-attribute ‘org-done nil :strike-through t)
    (set-face-attribute ‘org-headline-done nil :strike-through t))

    (eval-after-load “org”
    (add-hook ‘org-add-hook ‘modify-org-done-face))

    Otherwise Emacs complains about undefined stuff at startup. At least for me, I cannot say if a more recent Emacs has other autoloads or whatever that makes it work better.

  • http://sachachua.com Sacha Chua

    Oh! Sorry, I always load Org because I use the Emacs Starter Kit and because I start with my agenda view. =) You might be able to get away with doing it in the eval-after-load instead of setting it up as a hook.

  • http://sachachua.com Sacha Chua

    (… don’t forget to quote the argument to eval-after-load so that it doesn’t get run right away. =) )

  • Mathias Dahl

    Not sure why I have the extra function to wrap the other function calls, but I guess I sometime needed that and stuck with that pattern. Does not hurt anyway ;)

  • Jeremy LeJyBy

    It seems to work in org-files but not in the agenda: is it the desired effect?

    (I was more interested in having a stroke over DONE tasks in the agenda than in the org files)

    • http://sachachua.com Sacha Chua

      Try M-x customize-face RET org-agenda-done and set strikethrough to true. =)

  • Jeremy LeJyBy

    Sacha: thanks a lot!

    If I may complete your answer for those who prefer to enter manually their preferences in their .emacs:

    (custom-set-faces
    ‘(org-agenda-done ((t (:foreground “dim gray” :strike-through “lawn green”))))
    )

    Now I will be able to leave the DONE and CANC tasks visible, and see how many things I accomplished :)

  • http://users.dcc.uchile.cl/~jbarbay/ Jeremy ‘LeJyBy’ Barbay

    One odd thing though:

    Repeated actions (such as Habits, but not only) which are cancelled or done
    – will indeed be shown as CANC or DONE (albeit in their respective file they cycled back to the first active TODO keyword), but
    – will not be stroke (as opposed to non repeated actions), and
    – will disapear on reload of the agenda.

    It is not the behavior I expected, but on the bright side, one can see it as a way to distinguish between tasks done once-for-all and Sisyphus tasks done only for today…