21

Is there an easy way to create a list of "to-do" items on-the-fly when writing code? For example, suppose that I am writing a function write-this-now when I realize that I am also going to need to write a support function write-this-later.

(defun write-this-now ()
  (unless (write-this-later) ...

Instead of pausing to go create write-this-later, I charge ahead as if it already existed. However, I also want to make a note for myself that I still need to come back later and create it.

One solution that I have used in the past is to add a comment with the word TODO

(defun write-this-now ()
  (unless (write-this-later) nil))  ; TODO create function `write-this-later`

Now I can come back at some later time and search the file for occurences of the word TODO, and I will find this little note that I left for myself.

Are there any packages or extensions out there to facilitate easy creation and tracking of TODO items within a file or project?

Can I aggregate all of my TODO items from the current project into a single to-do list? Can I add bookmarks in my to-do list that link back to the locations where I wrote the TODO items?

1
  • 2
    A simple but efficient way to do this is to use projectile's project grep/awk/ack for TODO. This is what I typically do Commented Oct 15, 2014 at 22:59

3 Answers 3

18

You might want to try using org capture. When you initiate org-capture from your source file it will insert a TODO item into an org-mode file with a link to the relevant area in the source code. org-capture is smart enough to capture context-sensitive links--for instance, if you invoke it within a message in GNUS, it will capture a link directly to that message.

2
  • 1
    That looks amazingly similar to what I described. Maybe I used org capture in another life.
    – nispio
    Commented Oct 15, 2014 at 23:30
  • If you work your code file, what would be the fastest way to see all todo notes associated with this file (without manually copying the filename and searching your org file(s) created by org capture)?
    – student
    Commented Jan 23, 2021 at 21:36
17

fixmee-mode offers highlighting of such notes and navigation.

It is easily installed from MELPA and supports varying priorities of todo items.

1
  • 1
    That is an interesting approach. Really no key bindings to memorize if you don't want to. The main advantage I see over just grepping for TODO items is that you can assign them priority by appending characters.
    – nispio
    Commented Oct 16, 2014 at 0:30
2

Whilst not entirely on-topic for emacs, I use the simple trick of creating the stub of the method/property/whatever when I hit that 'to do' moment, containing nothing more than an assertion that says "Write Me!" or similar.

The code then compiles cleanly, and tells me at runtime where my TODO items are.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.