org-gtd.el icon indicating copy to clipboard operation
org-gtd.el copied to clipboard

Add the option in org-gtd-choose of "Refile to X project"

Open maikol-solis opened this issue 2 years ago • 8 comments

When we are in the process of capturing and clarifying items, sometimes a new item belongs to an already processed project.

Suppose you have in your project tree

* Projects
** [0/1] Learn how to bike
*** NEXT Practice 1 hour 

Later you recall you don't have a bike, then you capture in the inbox

* Buy a bike

In the clarify part, you get stuck because you need to cancel the whole process and refile manually the item to the correct project.

Please let me know if I was clear enough with the problem.

Best.

maikol-solis avatar Jan 08 '22 16:01 maikol-solis

It makes perfect sense. Your example is also a great example of a part of the problem: I don't know how to help you insert the new item in the correct order in the project. I could probably write some code to insert it as the ... first NEXT item in the project, so that it shows up in the agenda and you can adjust it yourself?

Trevoke avatar Jan 08 '22 20:01 Trevoke

Until we figure out a good desired behavior, you could also manually open the file with the project right now and add the task yourself - I realize that's a lot less helpful, but it's a fallback :)

Trevoke avatar Jan 08 '22 20:01 Trevoke

It makes perfect sense. Your example is also a great example of a part of the problem: I don't know how to help you insert the new item in the correct order in the project. I could probably write some code to insert it as the ... first NEXT item in the project, so that it shows up in the agenda and you can adjust it yourself?

I think it could be insert it after the last NEXT item in the project. If the user needs to put it above or below, it could be done manually.

WDYT?

maikol-solis avatar Jan 08 '22 23:01 maikol-solis

So at the end of the project, as the last item to be executed? I can do that. If you have:

* Learn how to bike
** NEXT practice 1 hour

Then you'd end up with

* Learn how to bike
** NEXT practice 1 hour
** NEXT buy a bike

So in the agenda you still see "practice 1 hour". My concern was that someone might forget to readjust the project if the item they just refiled didn't show up in the agenda, but on the other hand, since they just added the item to the project, they probably know it's there.

And I guess we can always start with this and refine it to a better feature later :)

Trevoke avatar Jan 10 '22 04:01 Trevoke

My concern was that someone might forget to readjust the project if the item they just refiled didn't show up in the agenda, but on the other hand, since they just added the item to the project, they probably know it's there.

Another option is to include a “second step” where the user organizes the new item using the natural planning model.

After refile, org-gtd could narrow the project subtree and let the users arrange the task as they want.

Just to be clear, my idea is

  • Step 1: Refile Put the item in whatever order refile does
* Learn how to bike
** NEXT practice 1 hour
** buy a bike
  • Step 2: Narrow to project subtree Go to the refiled target, narrow the project and arrange the tasks as we want. Possibly, we should change TODO states manually, but I don't see that as a problem.
* Learn how to bike
** NEXT buy a bike
** TODO practice 1 hour
  • Final Step: Remove the narrowed view of the project and continue with the next item in inbox

WDYT?

maikol-solis avatar Jan 10 '22 12:01 maikol-solis

That is a pretty good idea.

I think the behavior of the auto-NEXT todo code may be undefined if the user does this:

** NEXT new task
** DONE old first task
** NEXT old next task

but I think it's relatively simple logic to at least change it to NEXT / DONE / TODO ... And then I have to see if I can make it skip the DONE items and move to the next TODO (right now it's just gonna make whatever the next heading is become NEXT, so it'll reopen a DONE heading).

Trevoke avatar Jan 12 '22 04:01 Trevoke

I think the behavior of the auto-NEXT todo code may be undefined if the user does this:

** NEXT new task
** DONE old first task
** NEXT old next task

This why the refile mechanism should put at the end of the list. I think that the correct order should be like:

** DONE old first task
** NEXT old next task
** TODO new task

If the user need to reorder or clarify the project, it could be done manually,

** DONE old first task
** NEXT new task
** TODO old next task

And then I have to see if I can make it skip the DONE items and move to the next TODO (right now it's just gonna make whatever the next heading is become NEXT, so it'll reopen a DONE heading).

I don't think that at this stage, org-gtd should take care about how the user wants to organize their projects. Don't skip any DONE item, I don't think it's necessary. Because the TODO or NEXT items should be at the end of the list.

In any case, It's your call, of course.

maikol-solis avatar Jan 13 '22 20:01 maikol-solis

Something to that effect can be done with a bit of elisp. It doesn't take the user to that specific subtree and ask them to organise it, but for my purposes its good enough.

Adding to the end of the subtree or to the beginning is possible by changing the value of org-reverse-note-order

Here is how I've done it in Doom Emacs:

(defun my-org-gtd--refile ()
  (interactive)
  (org-gtd--decorate-item)
  (let* ((org-refile-history '())
         ; (org-reverse-note-order t) ; Uncomment this line if you want new tasks to go to the top
         (org-refile-targets `((,(concat org-gtd-directory "org-gtd-tasks.org") :maxlevel . 2))))
    (call-interactively #'org-refile))
  (org-gtd-process-inbox))

(add-hook! org-gtd-process-mode
  (transient-define-prefix org-gtd-choose ()
    "Choose how to categorize the current item.

Note that this function is intended to be used only during inbox processing.
Each action continues inbox processing, so you may put your emacs in an
undefined state."
    ["Actionable"
     [("q" "Quick action" org-gtd--quick-action)
      ("s" "Single action" org-gtd--single-action)]
     [("d" "Delegate" org-gtd--delegate)
      ("c" "Calendar" org-gtd--calendar)]
     [("p" "Make new project" org-gtd--project)
      ("P" "Refile to existing project" my-org-gtd--refile)]
     ]
    ["Non-actionable"
     [("i" "Incubate" org-gtd--incubate)
      ("a" "Archive this knowledge" org-gtd--archive)]
     [("t" "Trash" org-gtd--trash)]]
    ["Org GTD"
     ("x"
      "Exit. Stop processing the inbox for now."
      org-gtd--stop-processing)]))

There is probably a more clean way of limiting the refile target to just those under the heading "Projects" but I have not tried since this works well enough for my purposes.

Sabicool avatar Apr 22 '22 10:04 Sabicool

I've just merged in code that allows one to move a task to an existing project! Try it when MELPA updates and let me know how it goes :D

I decided to move the new item to the top of the project tasks, so that it shows up in the agenda and you don't forget it happened, if you need to reorder it further, and there's also a convenience function (org-gtd-projects-fix-todo-keywords-for-project-at-point) to help fix the TODO keywords after the fact so that everything remains consistent.

Try it out and let me know how you like it!

Closing this issue, but we can reopen it if something's wrong :)

Trevoke avatar Jan 06 '23 02:01 Trevoke

Awesome! Thanks!

maikol-solis avatar Jan 06 '23 18:01 maikol-solis

To note - I had forgotten this issue existed so I did it as it was in my head, refiling as the first item. I've already gotten the feedback that it should at least be a choice, so I'm going to update the feature so the task can go to the top or the bottom of the project, since you both here preferred it that way. Stay tuned. :D

Trevoke avatar Jan 06 '23 18:01 Trevoke

Okay, done! Now you can use org-reverse-note-order to configure whether the task should be at top or bottom of the project task list.

Trevoke avatar Jan 09 '23 05:01 Trevoke

I hate to do this to you. Should it be 'org-gtd-reverse-note-order' to avoid confusion with the variable by the same name in org remember?

Sabicool avatar Jan 10 '23 00:01 Sabicool

It is actually the org mode variable, I didn't create a new one :)

--

Aldric. Sent from a mobile device.

On Mon, Jan 9, 2023, 19:02 Sabicool @.***> wrote:

I hate to do this to you. Should it be 'org-gtd-reverse-note-order' to avoid confusion with the variable by the same name in org remember?

— Reply to this email directly, view it on GitHub https://github.com/Trevoke/org-gtd.el/issues/83#issuecomment-1376514371, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAQSSMIW5LPL54AVZKHYKDWRSRH3ANCNFSM5LQZK4LA . You are receiving this because you modified the open/close state.Message ID: @.***>

Trevoke avatar Jan 10 '23 00:01 Trevoke