Actually, there some bigger problems with the function as well... — It didn’t update the priority cookie properly when one had been set before * [#1] Exercise: update to [#2] — After fixing that, I noticed that the included save-excursion doesn’t work (https://emacs.stackexchange.com/questions/7574/why-save-excursion-doesnt-save-point-position) So, here’s a more comprehensive patch, including the previous changes (in order to support numeric priorities) and then adjusting the update/insert logic so that it makes more sense. I did not adjust the indentation, so that you can more clearly see which lines were changed. Inline comments in the patch explain what’s going on.