From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Guerry Subject: Re: Logging state change with timestamp, but without note Date: Thu, 14 Feb 2008 02:53:55 +0000 Message-ID: <87prv0ckos.fsf@bzg.ath.cx> References: <47B39DB7.2020706@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JPUEe-0007H2-7y for emacs-orgmode@gnu.org; Wed, 13 Feb 2008 21:54:04 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JPUEb-0007Gq-Tn for emacs-orgmode@gnu.org; Wed, 13 Feb 2008 21:54:02 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JPUEb-0007Gn-Je for emacs-orgmode@gnu.org; Wed, 13 Feb 2008 21:54:01 -0500 Received: from nf-out-0910.google.com ([64.233.182.191]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JPUEb-0001fT-1g for emacs-orgmode@gnu.org; Wed, 13 Feb 2008 21:54:01 -0500 Received: by nf-out-0910.google.com with SMTP id f5so149761nfh.26 for ; Wed, 13 Feb 2008 18:54:00 -0800 (PST) In-Reply-To: <47B39DB7.2020706@gmail.com> (Wanrong Lin's message of "Wed, 13 Feb 2008 20:47:35 -0500") 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 Cc: Wanrong Lin --=-=-= Wanrong Lin writes: > I would like to record down the time stamp when a TODO item changed its > state into some specific states (like "DELEGATED"), but I don't want to > be prompt with a window for notes. I like the idea. Here is a patch against latest org.el from git that implements something that might suits your needs. If you add "%!" to one of the heading in `org-log-note-headings' then Org doesn't pop up a new buffer, the log is filled automatically. (setq org-log-note-headings '((done . "CLOSING NOTE %t") (state . "State %-12s %t%!") (clock-out . "")))) Carsten, if you like it, I push it and update the manual accordingly. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=org.el.patch diff --git a/org.el b/org.el index d33d0ad..dd48e1d 100644 --- a/org.el +++ b/org.el @@ -14893,30 +14893,36 @@ The auto-repeater uses this.") (defun org-add-log-note (&optional purpose) "Pop up a window for taking a note, and add this note later at point." (remove-hook 'post-command-hook 'org-add-log-note) - (setq org-log-note-window-configuration (current-window-configuration)) - (delete-other-windows) - (move-marker org-log-note-return-to (point)) - (switch-to-buffer (marker-buffer org-log-note-marker)) - (goto-char org-log-note-marker) - (org-switch-to-buffer-other-window "*Org Note*") - (erase-buffer) - (let ((org-inhibit-startup t)) (org-mode)) - (insert (format "# Insert note for %s. + (catch 'exit + (when (string-match + "%!" (cdr (assq org-log-note-purpose org-log-note-headings))) + ;; The note should be construed and filled silently + (org-store-log-note t) + (throw 'exit t)) + (setq org-log-note-window-configuration (current-window-configuration)) + (delete-other-windows) + (move-marker org-log-note-return-to (point)) + (switch-to-buffer (marker-buffer org-log-note-marker)) + (goto-char org-log-note-marker) + (org-switch-to-buffer-other-window "*Org Note*") + (erase-buffer) + (let ((org-inhibit-startup t)) (org-mode)) + (insert (format "# Insert note for %s. # Finish with C-c C-c, or cancel with C-c C-k.\n\n" - (cond - ((eq org-log-note-purpose 'clock-out) "stopped clock") - ((eq org-log-note-purpose 'done) "closed todo item") - ((eq org-log-note-purpose 'state) - (format "state change to \"%s\"" org-log-note-state)) - (t (error "This should not happen"))))) - (org-set-local 'org-finish-function 'org-store-log-note)) - -(defun org-store-log-note () + (cond + ((eq org-log-note-purpose 'clock-out) "stopped clock") + ((eq org-log-note-purpose 'done) "closed todo item") + ((eq org-log-note-purpose 'state) + (format "state change to \"%s\"" org-log-note-state)) + (t (error "This should not happen"))))) + (org-set-local 'org-finish-function 'org-store-log-note))) + +(defun org-store-log-note (&optional auto-note) "Finish taking a log note, and insert it to where it belongs." - (let ((txt (buffer-string)) + (let ((txt (if auto-note "" (buffer-string))) (note (cdr (assq org-log-note-purpose org-log-note-headings))) lines ind) - (kill-buffer (current-buffer)) + (unless auto-note (kill-buffer (current-buffer))) (while (string-match "\\`#.*\n[ \t\n]*" txt) (setq txt (replace-match "" t t txt))) (if (string-match "\\s-+\\'" txt) @@ -14933,7 +14939,8 @@ The auto-repeater uses this.") (current-time))) (cons "%s" (if org-log-note-state (concat "\"" org-log-note-state "\"") - ""))))) + "")) + (cons "%!" "")))) (if lines (setq note (concat note " \\\\"))) (push note lines)) (when (or current-prefix-arg org-note-abort) (setq lines nil)) @@ -14953,10 +14960,11 @@ The auto-repeater uses this.") (setq ind (concat (match-string 0) " ")) (end-of-line 1) (while lines (insert "\n" ind (pop lines))))))) - (set-window-configuration org-log-note-window-configuration) - (with-current-buffer (marker-buffer org-log-note-return-to) - (goto-char org-log-note-return-to)) - (move-marker org-log-note-return-to nil) + (unless auto-note + (set-window-configuration org-log-note-window-configuration) + (with-current-buffer (marker-buffer org-log-note-return-to) + (goto-char org-log-note-return-to)) + (move-marker org-log-note-return-to nil)) (and org-log-post-message (message "%s" org-log-post-message))) ;; FIXME: what else would be useful? --=-=-= -- Bastien --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--