From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jambunathan K Subject: Re: Re: feature request: a basic conversation manager Date: Sun, 29 Aug 2010 00:46:35 +0530 Message-ID: <81lj7qh7jg.fsf@gmail.com> References: <20524da70811261844o3f47782ay3437fdfdc55bda95@mail.gmail.com> <81fwybeoem.fsf@gmail.com> <877hjn3fcp.wl%ucecesf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=37580 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OpQtU-0004h0-S1 for emacs-orgmode@gnu.org; Sat, 28 Aug 2010 15:16:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OpQtT-0007Ch-2I for emacs-orgmode@gnu.org; Sat, 28 Aug 2010 15:16:48 -0400 Received: from mail-pv0-f169.google.com ([74.125.83.169]:57420) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OpQtS-0007CZ-MN for emacs-orgmode@gnu.org; Sat, 28 Aug 2010 15:16:47 -0400 Received: by pvc30 with SMTP id 30so2924947pvc.0 for ; Sat, 28 Aug 2010 12:16:45 -0700 (PDT) In-Reply-To: <877hjn3fcp.wl%ucecesf@ucl.ac.uk> (Eric S. Fraga's message of "Wed, 18 Aug 2010 20:12:06 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Carsten & Others >> In the context of the original post, is there a possible way to do >> this. >> >> 1. I mark a TODO entry in todo.org as done. >> >> 2. An org-id (say ID-TODO) gets created for the TODO entry if >> there is none yet. >> >> 3. The state transition to DONE triggers a capture rule. The >> conversation is collected in a capture buffer and filed as a >> heading under conversation.org. An org-id (say ID-CONV) is >> generated for the captured entry. >> >> 4. ID-TODO is noted in the conversation.org 5. ID-CONV is noted >> down in todo.org >> >> Jambunathan K. Eric> I guess you could use the org-after-todo-state-change-hook Eric> together with the functionality of org-capture to implement Eric> this quite easily? Of course, this requires some emacs lisp Eric> knowledge. Thanks for accepting my earlier two patches on this thread. I have identified couple of more things that are needed in org core to support the above workflow. The changes required are minimal but enable complex workflows. [Context Switch] Before I proceed further let me add this - The intention of this mail is to share my notes and influence you to considering adding the needed support in the core. In effect the attached patch is demo-only and not to be construed as a formal commit request. [Back to Original Context] Needed features are: 1. Support for 'out-of-band' capture: Think of it as a org-add-log-setup for capture workflow. This is implemented as part of org-capture-setup in the enclosed patch. Note: Capture and Log Notes workflow are similar. + org-capture <=> org-add-log-note: Both of these routines pop-up notes buffers. + org-capture-finalize <=> org-store-log-note: Both dump the user notes to the user-specified position. + org-capture-setup <=> org-add-log-setup: Both make a note of the notes insertion position for later use. Note that they only setup the note taking process and don't by themselves collect or store notes. In some sense the addition of org-add-log-setup would make Log Notes and Org Capture closer together. ie., one can make org-capture supplant the simplistic Log Notes. 2. Support for chained captures: Think of it as per-capture-rule exit-hook. Unlike org-capture-before-finalize-hook (which gets invoked in the middle of the capture), this gets called right at the fag end of the capture after the capture buffer is saved or aborted and window configs are restored. This is implemented as part of a new :exit element in capture-plist in the attached patch. What you need to do: 1. Apply the attached patch to org-mode. 1. Load conversation.el. 2. Start with following todo.org entry. # Sample ~/todo.org * TODO Talk to someone SCHEDULED: <2010-09-08 Wed +1d> 3. Do a C-c C-t on the above entry 4. Do C-c C-t once more. See the following magic happen # TODO.org after 2 C-c C-t (s). * TODO Talk to someone SCHEDULED: <2010-09-08 Wed +1d> :PROPERTIES: :ID: 47df1dd3-3101-4dda-95df-cac71ae7dcab :END: [[id:a9664246-f396-4084-abb0-0c2274e409cd][Conversation-199003770]] [2010-08-28 Sat 23:25] [[id:ee280862-750e-49ee-b3a4-2cebe655dae8][Conversation-446218316]] [2010-08-28 Sat 23:25] # Conversation.org after 2 C-c C-t (s). * Conversations ** Conversation-446218316 :PROPERTIES: :ID: ee280862-750e-49ee-b3a4-2cebe655dae8 :END: TODO Context: [[id:47df1dd3-3101-4dda-95df-cac71ae7dcab][Talk to someone]] ** Conversation-199003770 :PROPERTIES: :ID: a9664246-f396-4084-abb0-0c2274e409cd :END: TODO Context: [[id:47df1dd3-3101-4dda-95df-cac71ae7dcab][Talk to someone]] I have few more things to share. This after sometime or once you revert with your comments. Jambunathan K. Attachments: --=-=-= Content-Disposition: attachment Content-Description: Unit Test Code ;; Use ID for storing links (setq org-link-to-org-use-id t) ;; trigger a capture on done (add-hook 'org-after-todo-state-change-hook 'my-todo-state-change-hook) ;; DONE on a todo item triggers a capture rule "x" (defun my-todo-state-change-hook () "" (when (member state org-done-keywords) (org-capture-setup "x"))) ;; org-capture-templates ;; Rule-x does this ;; - creates an entry in conversation.org ;; - saves a link to the parent TODO entry in the new conversation node ;; - exits with a call to my-update-todo-node defun (setq org-capture-templates '(("x" "Create conversation node" entry (file+headline "~/conversation.org" "Conversations") "** Conversation-%(int-to-string (random))\n TODO Context: %a\n %?" :prepend t :empty-lines 1 :exit (my-update-todo-node)))) ;; my-update-todo-node does this ;; - visits the last captured node (ie, the conversation node) ;; - installs a makeshift capture rule and invokes it ;; ;; makeshift capture rule installs a link to the newly created ;; conversation node in the todo node. (defun my-update-todo-node () (when (not org-note-abort) (let (org-capture-templates) (with-current-buffer (marker-buffer org-capture-last-stored-marker) (save-excursion (goto-char (marker-position org-capture-last-stored-marker)) (setq org-capture-templates `(("*" "Makeshift" plain (id ,(my-id-from-id-link (org-capture-get :annotation))) " %a %U\n %?"))) (org-capture nil "*")))))) ;; this is a library routine used by makeshift capture rule (defun my-id-from-id-link (id-link) "" (let (link type path) (when (string-match org-bracket-link-regexp id-link) (setq link (match-string-no-properties 1 id-link))) (when (and link (string-match org-link-re-with-space3 link)) (setq type (match-string 1 link) path (match-string 2 link))) path)) ;; (setq hyperlink "[[id:1766a3bb-d717-4779-ac33-98510ada95aa][Conversations]]") --=-=-= Content-Disposition: attachment Content-Description: patch to org-mode >From 01210b9ecf8e72db462639a9f317408f1390e964 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Sat, 28 Aug 2010 23:17:39 +0530 Subject: [PATCH] Support for chained captures and 'out of band' captures. * lisp/org-capture.el (org-capture-setup): Added. Use this to install a catpture rule that needs to be invoked as part of post-command-hook. Similar to org-add-log-setup. (org-capture-last-setup-marker): (org-capture-last-setup-keys): Added. Installed by org-capture-setup and used within org-capture. (org-capture): Modified. Check for a pending org-capture-setup and do the needful. (org-capture-finalize): Modified. Check for :exit properties and invoke the same. Think of it as a per-capture-rule exit hook. --- lisp/org-capture.el | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index e544964..def9975 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -76,6 +76,12 @@ :tag "Org Capture" :group 'org) +(defvar org-capture-last-setup-marker (make-marker) + "Marker position installed with `org-capture-setup'.") + +(defvar org-capture-last-setup-keys nil + "Capture keys installed with `org-capture-setup'.") + ;;;###autoload (defcustom org-capture-templates nil "Templates for the creation of new entries. @@ -370,6 +376,20 @@ Lisp programs can set KEYS to a string associated with a template in `org-capture-templates'. In this case, interactive selection will be bypassed." (interactive "P") + + (let ((setup-buf (marker-buffer org-capture-last-setup-marker)) + (setup-pos (marker-position org-capture-last-setup-marker))) + + (when setup-buf + (remove-hook 'post-command-hook 'org-capture) + + (with-current-buffer setup-buf + (goto-char setup-pos) + (setq keys org-capture-last-setup-keys)) + + (move-marker org-capture-last-setup-marker nil) + (setq org-capture-last-setup-keys nil))) + (cond ((equal goto '(4)) (org-capture-goto-target)) ((equal goto '(16)) (org-capture-goto-last-stored)) @@ -525,6 +545,9 @@ bypassed." (kill-buffer (current-buffer)) ;; Restore the window configuration before capture (set-window-configuration return-wconf)) + + (eval (or (org-capture-get :exit))) + (when abort-note (cond ((equal abort-note 'clean) @@ -901,6 +924,16 @@ already gone." (org-table-current-dline)))) (t (error "This should not happen")))) +(defun org-capture-setup (keys &optional buffer pos) + "Install position and keys for later capture. +The advised action is invoked as part of `post-command-hook'." + + (move-marker org-capture-last-setup-marker (or pos (point)) buffer) + (setq org-capture-last-setup-keys keys) + + (add-hook 'post-command-hook 'org-capture 'append) + ) + (defun org-capture-bookmark-last-stored-position () "Bookmark the last-captured position." (let* ((where (org-capture-get :position-for-last-stored 'local)) -- 1.7.0.4 --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--