Emacs: Strike through headlines for DONE tasks in Org

| emacs, 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

You can view 14 comments or e-mail me at sacha@sachachua.com.

14 comments

Nice !

Anonymous Coward

2012-12-25T03:34:31Z

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!

Helpful. Thanks! =)

Leo Ufimtsev

2015-04-09T18:58:34Z

thank you for posting1=

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

Mathias Dahl

2013-01-03T14:56:04Z

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.

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.

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

Mathias Dahl

2013-01-06T02:17:52Z

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

2013-01-24T19:50:46Z

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)

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

Jeremy LeJyBy

2013-01-25T13:51:06Z

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 :)

Jeremy 'LeJyBy' Barbay

2013-01-27T15:49:22Z

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...

Hi! With the auto-fill-mode, only the first line of the checkbox is striked. What should I do? Thank you