`org-project-capture` integrates `org-mode` TODOs with both `projectile` and `project.el`. This permits the maintenance of TODO lists for specific projects.
- Install using the package instructions for your Emacs setup. If you’re using MELPA:
M-x package-install org-project-capture
- For those intending to use the `projectile` backend, also install `org-projectile`:
M-x package-install org-projectile
You need to set the backend for `org-project-capture` using its class-based structure.
- For `project.el`:
(setq org-project-capture-default-backend (make-instance 'org-project-capture-project-backend))
- If using `projectile`:
(require 'org-projectile) (setq org-project-capture-default-backend (make-instance 'org-project-capture-projectile-backend))
`org-projectile` remains available as a compatibility layer, but the preferred setup is to configure `org-project-capture` directly and use the projectile backend.
Specify the location for storing project-specific TODOs:
(setq org-project-capture-projects-file "~/org/projects.org")Establish a keybinding for easy capturing:
(global-set-key (kbd "C-c n p") 'org-project-capture-project-todo-completing-read) (global-set-key (kbd "C-c n t") 'org-project-capture-capture-for-current-project) (global-set-key (kbd "C-c n a") 'org-project-capture-agenda-for-current-project)`org-project-capture-project-todo-completing-read` prompts for a project. `org-project-capture-capture-for-current-project` uses the current buffer’s project automatically.
Determine if TODOs should be in a single file or across individual projects:
(org-project-capture-single-file) ;; OR (org-project-capture-per-project)Combine both strategies, but prefer single file (projects will only use their own file if they already have one)
(setq org-project-capture-strategy (make-instance 'org-project-capture-combine-strategies :strategies (list (make-instance 'org-project-capture-single-file-strategy) (make-instance 'org-project-capture-per-project-strategy))))For those utilizing `use-package`, here’s a streamlined setup:
(use-package org-project-capture :bind (("C-c n p" . org-project-capture-project-todo-completing-read)) :ensure t :config (progn (setq org-project-capture-backend (make-instance 'YOUR-CHOSEN-BACKEND)) ; Replace with your backend of choice (setq org-project-capture-projects-file "~/org/projects.org") (org-project-capture-single-file))If you prefer to drive everything through `org-capture`, add a project-aware template entry:
(setq org-capture-templates (append org-capture-templates (list (org-project-capture-project-todo-entry :capture-character "p" :capture-heading "Project TODO"))))That template uses the current buffer’s project automatically. If you want a custom template body, pass `:capture-template`:
(org-project-capture-project-todo-entry :capture-character "p" :capture-heading "Project TODO" :capture-template "* NEXT %?\n%U\n")The command-style entry points also accept `:capture-template` directly:
(global-set-key (kbd "C-c n T") (lambda () (interactive) (org-project-capture-capture-for-current-project :capture-template "* TODO %?\nDEADLINE: %^T\n")))There are numerous customization options for `org-project-capture`:
M-x customize-group RET org-project-capture RETProject categories come from the active backend’s project names. For `projectile`, that means `projectile-project-name-function` and related projectile naming overrides are respected. This is the recommended way to avoid collisions when two different projects would otherwise share the same basename.