rpdillon / todotxt.el

A todo.txt client for Emacs
55 stars 18 forks source link

After changing priority, return to same place in list #32

Open TRSx80 opened 4 years ago

TRSx80 commented 4 years ago

Currently, after you change the priority (r key by default) the list seems to refresh and put the cursor all the way back at the top. This is very disorienting, and makes it a hassle to get back down to wherever you came from, especially if you were far down the list. Which makes the use-case of "periodic review" (ala GTD) of the todo.txt file much more difficult than it needs to be.

I suspect it could be fixed with something like (save-excursion) but I have not spent any time working on it yet. Even if I do get something working, I hesitate to submit a PR as it seems (as of today) there are already (4) languishing, (3) from 2019 and (1) from 2016(!).

Anyway, if I do get it working, maybe I post the code back here in this issue in case it helps anyone else.

In the meantime, thanks for sharing this handy little tool, I use it daily and it is an important part of my workflow, even just as it sits today! So thanks for your work, and for sharing it! :beers:

TRSx80 commented 4 years ago

I fixed it by commenting out the following line, which can be found near the end of the todotxt-add-priority function in todotxt.el:

;(todotxt-prioritize 'todotxt-get-due-priority-sort-key)

Then, there appears to be no way to manually initiate the todotxt-prioritize function. So I added the following to my init file to re-map the s key to re-Sort the list[1]. Since the function needs to supply an argument, we wrap it in a lambda:

  (define-key todotxt-mode-map (kbd "s")
    (lambda() (interactive) (todotxt-prioritize
                 'todotxt-get-due-priority-sort-key)))

This seems to work for me. As an added bonus, somehow I seem to now keep my position in the list, even after pressing "s" to re-sort. I don't understand this because there is no (save-excursion) in the todotxt-prioritize function. But I don't have any more time right now to play with this at the moment.

Even though I left this workaround, I will leave it up to you to decide whether to close this or keep it open as a feature request or for whatever tracking purposes.

Cheers! :beers:

[1] By default "s" is mapped to save-buffer which I don't need because I have auto save set up already.