1

I have a todo list in a text file that I maintain with TaskAgent and emacs. TaskAgent adds trailing text to a line to indicate priority (#!!! represents highest, #! represents low, and no mark is lowest). I would like to sort the lines by priority in emacs from highest to lowest, for example:

groceries 
haircut #!!
water plants #!!!
clean gutters #!

would be sorted as

water plants #!!! 
haircut #!!
clean gutters #!
groceries

(sort-regexp-fields t "^.*$" "#!+" (point-min) (point-max))

almost works but ignores the lowest priority (non-marked) items

2
(sort-regexp-fields t "^.*?\\(#!+\\|\\)$" "\\1" (point-min) (point-max))
  • Please do not make this a code-only answer. – YoungFrog May 21 '17 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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