News for hackers. Stuff that matters.
Re:The Plain Text Project by mntmoss on Monday December 02, 2019 @05:05PM (#21687543)
Recently I decided that I was going to solve the problem of: I easily write inline TODO comments while I work on code, but then have difficulty keeping track of them and getting my head back into the state of things later. While there is IDE support for such things, it's usually not exactly the right interface I want.

So I made a tiny CLI app that scans the source for TODO and FIXME lines and presents a menu of files, containing the number of items to work on in each. Then I type in which file I want to work on and it instantly reports all relevant lines, plus successive comment lines. All I have to do is punch in the line number and start working.

I felt a kind of stress relief almost instantly after doing this. It's better than Trello for me.

If I need to add additional kinds of data sources, many syntaxes, etc. it might become a bit more complex, but still managable as long as there's an API to get some plaintext lines out. It's basically following up on the hypothesis of a lot of information tools today: it isn't the data generation that's the issue, but the filtering.

Re:The Plain Text Project by chch on Tuesday December 03, 2019 @12:28AM (#21690176)
Just be careful about Microsoft's Patent US6748582B1; it doesn't expire for another few months. ;)

From the patent (edited down a bit):

> According to various example implementations of the invention, a task list facilitates code development by assisting developers in keeping track of and managing a variety of tasks, such as errors to be corrected, opportunities for optimization, and other user-defined tasks. As the developer edits source code, warnings and coding errors are detected and inserted as tasks in a task list. The developer can also embed keywords known as comment tokens in the code. These comment tokens are detected and used to define tasks.

> [...]

> Tasks can also be identified using tokens or keywords. These tokens or keywords typically preface comment lines in the code and may include predefined labels such as, for example, “UNDONE,” “TODO,” or “HACK,” as well as labels that are defined by the individual developer. If the source code has no syntax errors, the parser [...] determines whether any of the keywords are present in the source code[.] If so, [it] extracts the comment from the source code and uses the tag to determine the priority of the task. The task is then inserted in the task list[.] For example, if the source code contains the comment, “/TODO: Need to add copyright text/”, the parser [...] adds the task “TODO: Need to add copyright text” to the task list with a priority rating assigned to the “TODO” tag. [1]

[1] http://patents.google.com/patent/US6748582B1/en

Re:The Plain Text Project by pulse7 on Tuesday December 03, 2019 @10:12AM (#21692898)
This patent is invalid! Look at the source code in HN comment https://news.ycombinator.com/item?id=21685660#21689915 bellow and see the TODO tags in files last modified on 13. November 1999 which predates the patent application by Microsoft.
Re:The Plain Text Project by JTbane on Tuesday December 03, 2019 @09:03AM (#21692289)
That is one of the dumbest patents I have ever seen.
Re:The Plain Text Project by thr0w__4w4y on Tuesday December 03, 2019 @10:24AM (#21693046)
Well.... [0]

I have a whole list of absurd patents... this is the classic go-to example of a patent that should have never been issued... basically, a patent issued saying that if you exercise a cat by moving a laser pointer around a floor, you're infringing on this patent.

[0] https://patents.google.com/patent/US5443036A/en

Re:The Plain Text Project by arminiusreturns on Tuesday December 03, 2019 @07:47AM (#21691834)
How is it you are aware of this? Affiliation with MS or a project that ran into it?

Wouldn't the key part:

"and in response to completion of a task, modifying the task list during the interactive code development session to indicate that the task has been completed."

mean it doesn't apply?

Worst case, just put a US exclusionary clause in the release so US copyright law doesn't apply. At least Europe is ahead of the US in this and doesn't allow such trivial patents and considers them invalid by definition.

Re:The Plain Text Project by chch on Tuesday December 03, 2019 @02:17PM (#21695593)
Someone discovered it years ago online, and it's done a couple rounds in the media[1] as an example of an "overreaching software patent", similar to the "pop-under" patent, which patents a pop-up ad that opens after a window is closed[3].

So no personal experience, but I definitely think it's pretty frivolous; I don't imagine its ever been tested in court. :)

[1] https://www.theinquirer.net/inquirer/news/1040068/microsoft-... from 2004 [2] https://www.geek.com/news/microsoft-granted-patent-covering-... from 2010 [3] https://en.wikipedia.org/wiki/Pop-up_ad#Patent_controversy

Re:The Plain Text Project by nojvek on Tuesday December 03, 2019 @09:10AM (#21692339)
I am an X-Microsoft employee. Pre-Nadella era, most teams had a patent budget. People would file patents for all sorts of reasons. The game was who can get away with vague-ish patents and collect the most cubes. There was a cube you got per patent.

Needless to say the number of cubes someone had, the more clout they had and it became a dick measuring contest.

There are VPs and distinguished engineers with 100s of cubes.

Re:The Plain Text Project by BMorearty on Monday December 02, 2019 @05:11PM (#21687600)
Nice idea. The JetBrains family of IDEs (RubyMine, IntelliJ, etc.) even have this as a built-in TODO panel that shows files with TODO and FIXME comments (syntax is configurable).
Re:The Plain Text Project by keyle on Monday December 02, 2019 @05:52PM (#21687945)
I use IntelliJ as well for years, but don't underestimate

   grep -r "# TODO" .
Re:The Plain Text Project by imjasonmiller on Monday December 02, 2019 @07:11PM (#21688549)
That’s great! Using ripgrep [1], I think it would even exclude all from your .gitignore by default.

I’ll give this a try before adding something to my .vimrc again.

1. https://github.com/BurntSushi/ripgrep

Re:The Plain Text Project by tyingq on Monday December 02, 2019 @06:42PM (#21688350)
grep -H "# TODO" file1 dir1/* file2

Is also useful, as it prints the filename and the matching lines.

Re:The Plain Text Project by asicsp on Tuesday December 03, 2019 @10:06AM (#21692832)
if you are using GNU grep, -H option gets enabled by default when there are multiple input files
Re:The Plain Text Project by tyingq on Tuesday December 03, 2019 @10:31AM (#21693149)
Hopefully only when stdout isatty().

Edit: Nope, writes l̶i̶n̶e̶ ̶n̶u̶m̶b̶e̶r̶s̶ file names to output regardless. Boo.

Re:The Plain Text Project by asicsp on Tuesday December 03, 2019 @10:35AM (#21693196)
you mean filename, not line numbers?

option -h will disable filename in output

Re:The Plain Text Project by sverhagen on Monday December 02, 2019 @09:16PM (#21689341)
This only works depending on how diligently you formatted those TODOs. Before you know it your regex explodes. I use IntelliJ as well, so I don't have to think about these problems.
Re:The Plain Text Project by microcolonel on Monday December 02, 2019 @09:41PM (#21689445)
I mean, how often do you place the four characters "TODO" in your code when you don't mean to mark a TODO? The only common English word I know of that contains that substring is "mastodon", and it'd have to be all-caps.
Re:The Plain Text Project by yakshaving_jgt on Tuesday December 03, 2019 @06:44AM (#21691588)
You could also include word boundaries if you cared enough.

    ag '\bTODO\b'
Re:The Plain Text Project by adrianN on Tuesday December 03, 2019 @01:20AM (#21690386)
Does IntelliJ do something smarter than a regex to find TODO?
Re:The Plain Text Project by yawgmoth on Monday December 02, 2019 @05:25PM (#21687738)
Visual Studio does the same ("Task List")
Re:The Plain Text Project by daveslash on Monday December 02, 2019 @05:29PM (#21687773)
I really like JetBrain's Resharper for Visual Studio -- they have a very nice, flexible, and configurable 'TODO' window. For example, on our team we try to put TODO followed by our name or initials. The TODO window can then partition those out into separate lists.
Re:The Plain Text Project by gregoryl on Monday December 02, 2019 @05:56PM (#21687980)
Give Rider a go. I'm a complete convert; previous attempts were very unpleasant, but its a complete experience now, very similar feel to VS + RS, without the awful latency.
Re:The Plain Text Project by keithnz on Monday December 02, 2019 @07:01PM (#21688477)
I cannot second this enough, Rider is so much nicer than VS these days. I too tried to convert to Rider previously and ended up not using it, but just a while ago I made the switch and spent some time watching some videos on what toys it has, and going through everything and configuring it how I like. It is a lot nicer and a lot quicker, and most importantly to me, has really good vim support (including easymotion / surround ).
Re:The Plain Text Project by daveslash on Tuesday December 03, 2019 @10:21AM (#21693006)
I've seen it, but never taken the plunge. Thank you for the encouragement -- I'll definitely give it a go. That said, it's going to be extremely difficult to actually incorporate this in my 9-5 environment, so it will probably end up being for my home projects only.
Re:The Plain Text Project by keithnz on Tuesday December 03, 2019 @03:17PM (#21696247)
out of interest, why do you think it'd be hard? It's what I did, just swapped over at work. Nearly everyone else is still using visual studio. It mostly is a zero friction change and you can swap back and forward between environments at any stage
Re:The Plain Text Project by daveslash on Wednesday December 04, 2019 @12:19PM (#21704245)
Because I work in a highly regulated industry. We have to qualify/verify/validate everything that we use, and we all have to be standardized on the same thing. I'm currently struggling to get unit tests working smoothly -- we have to validate the "plugin" that we use to execute the unit tests (MSTest... part of Visual Studio), which means that we need to write requirements and then test those requirements. We're writing requirements for MSTest.... I'm pushing to get a CI pipeline set up so that our unit tests can be run automatically with every check-in, but we'll have to write-up requirements for whatever CI tool, validate that it works with our existing source control, validate that the unit tests execute properly, document it all, review it all, sign off on it all within our document control system. etc... Switching to an entirely new IDE I think would make people's heads explode. Personally I think that we make things excessively hard on ourselves -- I'm endeavoring to reduce some of that pain.
Re:The Plain Text Project by gregoryl on Thursday December 05, 2019 @07:04PM (#21718061)
That sounds incredibly painful, I admire your tenacity.
Re:The Plain Text Project by skipants on Monday December 02, 2019 @06:21PM (#21688203)
Rails (or maybe it's just Rake) has `rake notes`
Re:The Plain Text Project by sevencolors on Monday December 02, 2019 @07:11PM (#21688552)
There's extension for VS Code - Todo Tree that organizes your files with TODO in the comments. Super helpful

https://marketplace.visualstudio.com/items?itemName=Gruntfug...

Re:The Plain Text Project by hboon on Monday December 02, 2019 @11:13PM (#21689865)
Related to this. I write comments for TODOs that I want completed before I commit with a special prefix like:

    //hhh I want this to be done before I commit.
Then have a git pre-commit hook that scans for "//hhh" and aborts if it's found.
Re:The Plain Text Project by nine_k on Monday December 02, 2019 @11:37PM (#21689960)
Same with XXX instead, which even gets auto-highlighted by many editors.
Re:The Plain Text Project by tekknolagi on Monday December 02, 2019 @05:16PM (#21687655)
Have you considered open-sourcing this CLI app? I would benefit immensely from this tool, I think. Right now I just kind of ack and hope for the best.
Re:The Plain Text Project by aeneasmackenzie on Monday December 02, 2019 @07:45PM (#21688788)
Re:The Plain Text Project by useragent86 on Monday December 02, 2019 @06:39PM (#21688331)
Emacs supports this with the package magit-todos.
Re:The Plain Text Project by wruza on Monday December 02, 2019 @10:49PM (#21689762)

  :set wildignore+=node_modules/**
  :nmap gr :vimgrep '' **/* \| copen 20<Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>
grTODO, enter.

Edit: <C-f>0wa may work instead of Lefts, but I always forget about it.

Re:The Plain Text Project by unkulunkulu on Tuesday December 03, 2019 @03:49AM (#21690878)
You reminded me of the time one cool guy and a respectable troll ran a script to create tons of issues on github for TODO comments in the code. He quickly got banned and the issues removed, but I for one was thankful to him. I think I asked the staff to get them back for my repo, but no :)
Re:The Plain Text Project by agustif on Tuesday December 03, 2019 @07:11AM (#21691693)
This could be a Great GitHub Actions though.

So user can enable/disable it per account/repo as they wish.

I think it exists, I've had it enabled in some repo when figuring out new gh actions

Re:The Plain Text Project by agustif on Tuesday December 03, 2019 @12:56PM (#21694733)
Re:The Plain Text Project by edwinyzh on Monday December 02, 2019 @11:26PM (#21689915)
Re:The Plain Text Project by yonilevy on Monday December 02, 2019 @08:04PM (#21688912)
I do something similar, but my flow is around feature branches: I create a branch, dumping TODOs in the code as I work out the feature, then progressively fix them before merging the branch. Wrote a little script to highlight TODOs created in current branch (vs base) if anyone's interested: https://github.com/yonilevy/branchtodo
Re:The Plain Text Project by jchook on Monday December 02, 2019 @05:41PM (#21687882)
eslint does this for JavaScript with the no-warning-comment rule. The general idea there goes something like "don't use code comments as a project management tool," but I tend to use eslint as a reminder to finish things for my current PR.

Also it occurred to me you could use grep or rg, something like...

  rg '\s*//\s*TODO'
Re:The Plain Text Project by jamiesonbecker on Monday December 02, 2019 @08:21PM (#21689036)
This will open all of the files with TODO in them in vim:

    alias todogrep="vim $(grep TODO . -rl)"
You can modify this easily, such as by using ripgrep, adding excludes, or doing regex to find TODO and FIXME together, but this is a quick one-liner to add to your `.bashrc`.
Re:The Plain Text Project by CDRdude on Monday December 02, 2019 @08:27PM (#21689075)
You can put the grep flags at the end? All these years, and I had no idea.
Re:The Plain Text Project by yencabulator on Tuesday December 03, 2019 @11:17AM (#21693677)
Depends on your grep. Reordering flags is typically a GNU getopts extension, not present in traditional UNIXes.