From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Re: Relative clocking [Further discussion and ideas by OP] Date: Tue, 25 Nov 2008 12:29:15 +0100 Message-ID: References: <7bef1f890811232347s2b91a19ey985e967d501d7270@mail.gmail.com> <9EF47D2B-F1FF-4125-BA26-5C7F7FC42F1D@uva.nl> <7bef1f890811241231m52f9a2e1o8c320272d3a6e291@mail.gmail.com> <7bef1f890811250008l2c345ae6y3069fda96fe2cf20@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v929.2) Content-Type: multipart/mixed; boundary="===============1228334378==" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L4w7r-0003n9-Nv for emacs-orgmode@gnu.org; Tue, 25 Nov 2008 06:30:39 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L4w7p-0003m3-4e for emacs-orgmode@gnu.org; Tue, 25 Nov 2008 06:30:38 -0500 Received: from [199.232.76.173] (port=60024 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L4w7o-0003le-DM for emacs-orgmode@gnu.org; Tue, 25 Nov 2008 06:30:36 -0500 Received: from ug-out-1314.google.com ([66.249.92.168]:39897) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L4w7l-0007fO-1B for emacs-orgmode@gnu.org; Tue, 25 Nov 2008 06:30:33 -0500 Received: by ug-out-1314.google.com with SMTP id 36so1157905uga.17 for ; Tue, 25 Nov 2008 03:29:18 -0800 (PST) In-Reply-To: <7bef1f890811250008l2c345ae6y3069fda96fe2cf20@mail.gmail.com> 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: "Alan E. Davis" Cc: emacs-orgmode Mailinglist --===============1228334378== Content-Type: multipart/alternative; boundary=Apple-Mail-20-197252161 --Apple-Mail-20-197252161 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Hi Alan, I have added such a timer to Org-mode, if you get the latest git release, you can use it. Here is the documentation for it: New relative timer to support timed notes ========================================= Author: Carsten Dominik Date: 2008-11-25 12:28:50 CET Org now supports taking timed notes, useful for example while watching a video, or during a meeting which is also recorded. - `C-c C-x .' :: Insert a relative time into the buffer. The first time you use this, the timer will be started. When called with a prefix argument, the timer is reset to 0. - `C-c C-x -' :: Insert a description list item with the current relative time. With a prefix argument, first reset the timer to 0. - `C-c C-x 0' :: Reset the timer without inserting anything into the buffer. By default, the timer is reset to 0. When called with a `C-u' prefix, reset the timer to specific starting offset. The user is prompted for the offset, with a default taken from a timer string at point, if any, So this can be used to restart taking notes after a break in the process. When called with a double prefix argument `C-c C-u', change all timer strings in the active region by a certain amount. This can be used to fix timer strings if the timer was not started at exactly the right moment. Thanks to Alan Dove, Adam Spiers, and Alan Davis for contributions to this idea. On Nov 25, 2008, at 9:08 AM, Alan E. Davis wrote: > You may understand that I was already looking at the idea of > converting integer times back and forth to/from hh:mm:ss. Your > functions look extremely interesting. > > I am trying to write a function to start the clock at a specific > point in time. This could be useful when restarting or continuing a > video, and continuing notes. > > Thank you again, > > Alan > > On Tue, Nov 25, 2008 at 5:07 PM, Carsten Dominik > wrote: > > On Nov 24, 2008, at 9:31 PM, Alan E. Davis wrote: > >> Thank you for the reply. >> >> On Mon, Nov 24, 2008 at 8:30 PM, Carsten Dominik > > wrote: >> Why would you want to turn off the clock? It is actually >> not running, only a starting time is recorded. Just "start" >> it again when you need a new clock. >> >> Perfect! Thank you. >> >>> A further suggestion is born or my initial experiment with his >>> function: I started the clock a bit too late, so all the >>> timestamps are off by about 30-40 seconds. Is it (at least in >>> theory) possible to adjust all time stamps in a subtree by the >>> same amount? That would enable me to correct all of my notes in >>> one fell stroke. >> >> Of course this is possible, but code for that would need to be >> written. >> >> >> I have written some elisp, not alot. May I request a clue where to >> start? > > Well write a function searching for the strings and change them... :-) > > Something like this (untested) might do it. These functions > handle negative times, so you can also use this to change > the timings relative to the beginning of a scene, so that a prelude > to a scene might be at negative times.....: > > (defun my-change-times-in-region (beg end delta) > "Change all h:mm:ss time in region by a DELTA." > (interactive "r\nsEnter time difference like \"-1:08:26\" or > \"0:00:25\": ") > (let ((re "[-+]?[0-9]+:[0-9]\\{2\\}:[0-9]\\{2\\}") > (delta (my-hms-to-secs delta)) > old new p) > (when (= delta 0) (error "No change")) > (save-excursion > (goto-char end) > (while (re-search-backward re beg t) > (setq p (point)) > (replace-match > (save-match-data > (my-secs-to-hms (+ (my-hms-to-secs (match-string 0)) delta))) > t t) > (goto-char p))))) > > (defun my-hms-to-secs (hms) > "Convert h:mm:ss string to an integer time. > If the string starts with a minus sign, the integer will be negative." > (if (not (string-match > "\\([-+]?[0-9]+\\):\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)" > hms)) > 0 > (let* ((h (string-to-int (match-string 1 hms))) > (m (string-to-int (match-string 2 hms))) > (s (string-to-int (match-string 3 hms))) > (sign (equal (substring (match-string 1 hms) 0 1) "-"))) > (setq h (abs h)) > (* (if sign -1 1) (+ s (* 60 (+ m (* 60 h)))))))) > > (defun my-secs-to-hms (s) > "Convert integer S into h:mm:ss. > If the integer is negative, the strig will start with \"-\"." > (let (sign m h) > (setq sign (if (< s 0) "-" "") > s (abs s) > m (/ s 60) s (- s (* 60 m)) > h (/ m 60) m (- m (* 60 h))) > (format "%s%d:%02d:%02d" sign h m s))) > > HTH > > - Carsten > > > Hmmm, looks useful to me also for general note taking, maybe > I can add something linke this to Org.... > > > > > -- > Alan Davis > > "It's never a matter of liking or disliking ..." > ---Santa Ynez Chumash Medicine Man > --Apple-Mail-20-197252161 Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Alan,

I = have added such a timer to Org-mode, if you get the latest git release, = you can use it.

Here is the documentation for = it:


     =          New relative timer to support timed = notes
             =  =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Author: Carsten Dominik <carsten at orgmode dot = org>
Date: 2008-11-25 12:28:50 = CET


    Org now = supports taking timed notes, useful for example = while
    watching a video, or during a meeting = which is also recorded.

    - = `C-c C-x .' :: 
      Insert a = relative time into the buffer.  The first = time
      you use this, the timer will be = started.  When called
      with a = prefix argument, the timer is reset to = 0.

    - `C-c C-x -' = :: 
      Insert a description list = item with the current relative
      time. =  With a prefix argument, first reset the timer to = 0.

    - `C-c C-x 0' = :: 
      Reset the timer without = inserting anything into the buffer.
     =  By default, the timer is reset to 0.  When called with = a
      `C-u' prefix, reset the timer to = specific starting
      offset.  The = user is prompted for the offset, with a
     =  default taken from a timer string at point, if any, So = this
      can be used to restart taking = notes after a break in the
      process. =  When called with a double prefix argument
   =    `C-c C-u', change all timer strings in the = active
      region by a certain amount. =  This can be used to fix timer
     =  strings if the timer was not started at exactly the = right
     =  moment.

    Thanks to Alan = Dove, Adam Spiers, and Alan Davis for
   =  contributions to this = idea.



On Nov = 25, 2008, at 9:08 AM, Alan E. Davis wrote:

You may = understand that I was already looking at the idea of converting integer = times back and forth to/from  hh:mm:ss.  Your functions look = extremely interesting. 

I am trying to write a function to = start the clock at a specific point in time.  This could be useful = when restarting or continuing a video, and continuing notes. 
=
Thank you again,

Alan

On = Tue, Nov 25, 2008 at 5:07 PM, Carsten Dominik <dominik@science.uva.nl> = wrote:

On Nov 24, = 2008, at 9:31 PM, Alan E. Davis wrote:

Thank you for the reply.

On Mon, Nov 24, 2008 at 8:30 PM, Carsten Dominik = <dominik@science.uva.nl> wrote:
=
=
Why would you want to turn off the clock?  It is = actually
not running, only a starting time is recorded. =  Just "start"
it again when you need a new = clock.
=
 
Perfect!  Thank you. =
 
A further suggestion is born or my initial = experiment with his function: I started the clock a bit too late, so all = the timestamps are off by about 30-40 seconds.  Is it (at least in = theory) possible to adjust all time stamps in a subtree by the same = amount?  That would enable me to correct all of my notes in one = fell stroke.

Of = course this is possible, but code for that would need to be = written.
 

I have written = some elisp, not alot.  May I request a clue where to start?
=

Well write a function = searching for the strings and change them... = :-)

Something like this (untested) might do it. =  These functions
handle negative times, so you can = also use this to change
the timings relative to the beginning = of a scene, so that a prelude
to a scene might be at = negative times.....:

(defun = my-change-times-in-region (beg end delta)
  "Change = all h:mm:ss time in region by a DELTA."
=
  (interactive "r\nsEnter time difference like = \"-1:08:26\" or \"0:00:25\": ")
  (let ((re = "[-+]?[0-9]+:[0-9]\\{2\\}:[0-9]\\{2\\}")
(delta (my-hms-to-secs = delta))
old new = p)
    (when (=3D delta 0) (error "No = change"))
   =  (save-excursion
      (goto-char = end)
      (while (re-search-backward re = beg t)
(setq p = (point))
= (replace-match
= (save-match-data
=   (my-secs-to-hms (+ (my-hms-to-secs (match-string 0)) = delta)))
t = t)
(goto-char = p)))))

(defun my-hms-to-secs = (hms)
  "Convert h:mm:ss string to an integer = time.
If the string starts with a minus sign, the integer = will be negative."
  (if (not = (string-match
=   =  "\\([-+]?[0-9]+\\):\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)"
=
  =  hms))
      0
   =  (let* ((h (string-to-int (match-string 1 hms)))
  (m (string-to-int = (match-string 2 hms)))
=   (s (string-to-int (match-string 3 hms)))
  (sign (equal (substring = (match-string 1 hms) 0 1) "-")))
     =  (setq h (abs h))
      (* (if sign = -1 1) (+ s (* 60 (+ m (* 60 h))))))))

(defun = my-secs-to-hms (s)
  "Convert integer S into = h:mm:ss.
If the integer is negative, the strig will start with = \"-\"."
  (let (sign m h)
   =  (setq sign (if (< s 0) "-" "")
 s (abs s)
 m (/ s 60) s (- s (* 60 = m))
 h = (/ m 60) m (- m (* 60 h)))
    (format = "%s%d:%02d:%02d" sign h m = s)))

HTH

- = Carsten


Hmmm, looks useful to = me also for general note taking, maybe
I can add something = linke this to = Org....




--
Alan Davis

"It's never a matter of = liking or disliking ..."
      ---Santa Ynez Chumash = Medicine Man


= --Apple-Mail-20-197252161-- --===============1228334378== 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 --===============1228334378==--