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

0

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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