Trevoke / org-gtd.el

A package for using GTD with org-mode
GNU General Public License v3.0
367 stars 45 forks source link

Turn a file into a refile target rather than just headings #203

Closed graven04 closed 2 months ago

graven04 commented 4 months ago

My current org gtd configuration has many files each of which is a project or contain many projects, almost like instead of tags i have files though i do use tags as well. This is because it is often easier to handle and the projects often get large or very similar projects can be bunched together in a file.

This package is a game changer for my configuration but having files as projects and not having a top level headings just for description purposes (e.g to make into a refile target) is also crucial to my configuration. This has caused a few problems when i try to refile to these files. I have tried making the file properties the same as the document states for the refile heading but this has not worked. I would love to see this feature added to the package if possible.

The problem/feature:

I cannot refile to a file whose top level heading is a project or next action itself, since there is no option that i can find in the documentation for this. I would like to refile under a whole file rather than just a heading, if this is possible.

some similar issues: ( i made this issue because i am not sure if these issues are talking about exactly this problem/feature) https://github.com/Trevoke/org-gtd.el/issues/4

This above issue allows for projects per files but i am not sure if it means that no top level descriptive refile heading is needed or not.

p.s a truly amazing emacs package @Trevoke

Trevoke commented 4 months ago

Thank you!

Ah, the refiling! Yes, this is a big one.

One of the core "design concept because org-mode is too complicated for me" was to decide to pin most of the logic to level 1 headings, so-called top-level headings (i.e. not subheadings, but also not file-level). This allowed me to implement org-gtd with relatively simple logic.

If you look at the code below, I think that this would "fix" your current problem by allowing refiles "up to level 1", but the real problem is that org-gtd would then no longer find these projects when searching for them (or worse, might think that all project tasks are project headings).

The main problem with "projects" is that they have, in their current implementation, headings and subheadings (project name and project tasks), and that I have implemented them in a simple "level 1 heading" vs "level 2 heading under a project level 1 heading" setup so they're easy to find/query for/etc.

I have been, believe it or not, poking at many different ways to handle projects ( see https://github.com/Trevoke/org-gtd.el/issues/71 ) -- I see now that issue has been left very empty, I need to fill it up with my current plan, beyond just a few links to keep track of how other people solved the problem :D

(defmacro with-org-gtd-refile (type &rest body)
  "Macro to refile specifically within org-gtd context.

TYPE is the org-gtd action type.  BODY... is the rest of the code."
  (declare (debug t) (indent 1))
  `(let ((org-refile-target-verify-function (lambda () (org-gtd-refile--group-p ,type)))
         (org-refile-targets '((org-agenda-files :maxlevel . 1)))
         (org-refile-use-outline-path nil)
         (org-outline-path-complete-in-steps nil))
     (unwind-protect
         (with-org-gtd-context (progn ,@body)))))
graven04 commented 3 months ago

Hi Tervoke,

I replaced the code in refile file with this code but i am a bit confused as how to use it. Could you tell me how i would refile to the top level with this code. Unfortunately I am not very good at elisp (yet!).

Edit: For now I have just decided to rework my system to use level one headings