How to captrue project note info in two step like this?
coppercu opened this issue · comments
Hi,
I'd like to add an org file to echo of projects, like "note.org"
Show projects in minibuffer when call a command like org-projectile-project-todo-completing-read
[org-projectile] Record TODO for project: {org-projectile | emacs | ...}
After select project, A new buffer to show and select template like org-capture
Select a capture template
=========================
[t] Task
[n] Note
[i] Idaa
Anyone have any idea on how to do this?
(defun org-projectile-select-capture-template ()
(interactive)
(occ-capture
(make-instance 'occ-context
:category (projectile-completing-read
"Record TODO for project: "
(occ-get-categories org-projectile-strategy))
:template (org-capture-select-template)
:strategy org-projectile-strategy
:options nil)))
This almost works, except that the return value for (org-capture-select-template) is not correct. This is because what is expected here is actually a string template rather than an actual capture template which is a lisp value. Capture template in all of their generality are not really supported by org-projectile, since org-projectile is doing a lot of the work (selecting where to put things) that the capture template would do.
Basically to fix this, just replace (org-capture-select-template)
with a function tha prompts for and actually returns string capture templates for whatever you want to do.
Thank you for your reply !
I am add this code to org-projectile.el and call this command in emacs, All is works well until enter keyword [n], and report error in minibuffer like this
org-capture-put: Wrong type argument: char-or-string-p, ("n" "Note" entry (file+olp+datetree "~/note/note.org") "* %?
%U
%i
%a")
Just like you reminded before.
I am try to write a funciton to do this, Because elisp is too hard for me, it will take a long time。
if you paste string versions of the capture templates you want here i can show you.
Thank you very much!
My org-capture-templates is set like this
(setq org-capture-templates
'(("t" "Task" entry (file+olp "~/note/note.org" "Task")
"* %?\n %U\n %i\n %a")
("n" "Note" entry (file+olp "~/note/note.org" "Note")
"* %?\n %U\n %i\n %a")
("g" "Gate" entry (file+olp "~/note/note.org" "Gate")
"* %?\n %U\n %i\n %a")
))
and "~/note/note.org" is record like this
* Note
** test note
[2020-04-16 Thursday 14:05]
* Gate
** test gate
[2020-04-16 Thursday 14:05]
* Task
** test task
[2020-04-16 Thursday 14:05]
And what i expect now is the note.org file is not only in one "~/note/note.org" but in every project's root note.org file
I found a way to implement config as mentioned before, which is ugry, but what just i need
(setq org-capture-templates
'(("t" "Task" entry (file+headline (lambda ()
(concat (org-projectile-location-for-project
(projectile-completing-read "Capture task for project:"
(occ-get-categories org-projectile-strategy))) "note/note.org")) "Tasks")
"* TODO %?\n %U\n %i\n %a")
("n" "Note" entry (file+headline (lambda ()
(concat (org-projectile-location-for-project
(projectile-completing-read "Capture note for project:"
(occ-get-categories org-projectile-strategy))) "note/note.org")) "Notes")
"* %?\n %U\n %i\n %a")
("g" "Gate" entry (file+headline (lambda ()
(concat (org-projectile-location-for-project
(projectile-completing-read "Capture gate for project:"
(occ-get-categories org-projectile-strategy))) "note/note.org")) "Gates")
"* %?\n %U\n %i\n %a")))