reddit / emacs

Compile tags from code into an orgfile

LukeKrishna · 2022-07-19 16:46
Hey, I have a need for functionality I haven't been able to find, though I might just lack the proper terminology to find the solution. I am a emacs noob, using Doom Emacs mostly for JS/TS programming (the killer features I am in love in with are magit and the ease of being keyboard-only). So, my problem: I am currently working on the largest project I had ever done, and I would like to have some sort of automated system that would crawl through my code, find all the comments with tags (such as TODO, NOTE...), and compile them into an org file (for example notes.org) at the root of my project. It seems like a fairly simple problem, and I am almost certain there already is a solution, but I haven't really been able to find it. The reason I haven't written it yet is because while elisp is cool and I'd like to be able to understand it, I haven't had the time yet (and after I am done with work, I barely have the brain power to read a book, not to learn a wholly different language). Any pointers would be most appreciated! Thanks
akirakom · 2022-07-19 16:54
This is not an exact solution you are looking for, but [magit-todos](https://github.com/alphapapa/magit-todos) displays todos in `magit-status` buffers. If your repository is huge, this can slow down magit, so I don't know if you would use it. Alternatively, you can write a script which transforms an output from ripgrep and saves it to Org.
LukeKrishna · 2022-07-19 20:58
Thanks, I'll look into it!
Horrih · 2022-07-19 21:54
Silly answer here : why not simply write a bash command that does that for you ? I am much better at writing this kind of stuff with grep/sed and friends, and you can probably do that in a one liner or close. E. G : grep -Rine TODO my_folder > result.org Then you create a wrapper elisp function looking like this (defun open-todos() (interactive) (shell-command "the grep line above") (switch-to-buffer "result.org")) (global-define-key "your key binding" 'open-todos)