emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien Guerry <bzg@altern.org>
To: emacs-orgmode@gnu.org
Cc: Wanrong Lin <wrglin@gmail.com>
Subject: Re: Logging state change with timestamp, but without note
Date: Thu, 14 Feb 2008 02:53:55 +0000	[thread overview]
Message-ID: <87prv0ckos.fsf@bzg.ath.cx> (raw)
In-Reply-To: <47B39DB7.2020706@gmail.com> (Wanrong Lin's message of "Wed, 13 Feb 2008 20:47:35 -0500")

[-- Attachment #1: Type: text/plain, Size: 693 bytes --]

Wanrong Lin <wanrong.lin@gmail.com> 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org.el.patch --]
[-- Type: text/x-diff, Size: 3734 bytes --]

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?

[-- Attachment #3: Type: text/plain, Size: 13 bytes --]


-- 
Bastien

[-- Attachment #4: Type: text/plain, Size: 204 bytes --]

_______________________________________________
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

  reply	other threads:[~2008-02-14  2:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-14  1:47 Logging state change with timestamp, but without note Wanrong Lin
2008-02-14  2:53 ` Bastien Guerry [this message]
2008-02-14 12:50   ` Carsten Dominik
2008-02-14 13:43     ` Bastien
2008-02-14 13:46       ` Carsten Dominik
2008-02-14 13:49       ` Carsten Dominik
2008-02-14 15:09     ` Wanrong Lin
2008-02-14 16:19       ` Carsten Dominik
2008-02-15 10:14     ` Carsten Dominik
2008-02-15 16:17       ` Wanrong Lin
2008-02-15 16:34         ` Bernt Hansen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87prv0ckos.fsf@bzg.ath.cx \
    --to=bzg@altern.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=wrglin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).