regexp

using regexp find and replace to reformat my todo list

Intro I had a series of todo entries like this *** TODO Rename legacy/authtoken.clj and sibling tests https://github.com/FOO/BAR/issues/158 and wanted them to have the issue number at the end of the todo title, which helps with our git branch naming praxis. Emacs regular expression (slightly improved) anzu-query-replace-regexp1 with the following: ^\(\*.*\) \(.*github.*\)\([0-9]+\)\s-+ → \1 #\3 \2\3 Where the linebreaks are entered literally via C-q C-j. The end result was what I wanted:

Emacs sorting with sort-regexp-fields

Emacs is really an endless world of commands, options, and use-cases, especially for dealing with text. Sorting text is a really common thing and often plain-old M-x sort-lines does the trick in one fell swoop. But what if you want something more sophisticated? It turns out my eyes have been opened and emacs has led me to think about sorting things in ways I never even thought about before.

Easy incrementing find and replace in emacs

I start with a list with a bunch of entries like this: newsletter W02 newsletter W02 newsletter W02 newsletter W02 EDIT: New Solutions It turns out that emacs automatically initializes a variable that tracks how many interations your replacement function has made, and in lisp mode you can get to it with \#. This way, the single line necessary to number all my newsletters becomes this: W\(02\) → W\,(format "%02d" (+ 4 \#))) and, of course, you can adjust that 4 to whatever you need it to be for your starting digit.