Mercurial > emacs
annotate lisp/org/org-timer.el @ 110682:ba6a1c230532
gnus-html.el (gnus-html-prefetch-images): Adjust regexp to avoid regexp backtrace overflows.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Fri, 01 Oct 2010 13:33:03 +0000 |
parents | a150e8a14679 |
children | 5cb272c831e8 |
rev | line source |
---|---|
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
1 ;;; org-timer.el --- The relative timer code for Org-mode |
100269
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
2 |
106815 | 3 ;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. |
100269
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
4 |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
5 ;; Author: Carsten Dominik <carsten at orgmode dot org> |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
6 ;; Keywords: outlines, hypermedia, calendar, wp |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
7 ;; Homepage: http://orgmode.org |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
8 ;; Version: 7.01 |
100269
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
9 ;; |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
11 ;; |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
15 ;; (at your option) any later version. |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
16 |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
20 ;; GNU General Public License for more details. |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
21 |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
24 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
25 ;; |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
26 ;;; Commentary: |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
27 |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
28 ;; This file contains the relative timer code for Org-mode |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
29 |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
30 ;;; Code: |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
31 |
100269
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
32 (require 'org) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
33 |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
34 (declare-function org-show-notification "org-clock" (parameters)) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
35 (declare-function org-agenda-error "org-agenda" ()) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
36 |
100269
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
37 (defvar org-timer-start-time nil |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
38 "t=0 for the running timer.") |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
39 |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
40 (defvar org-timer-pause-time nil |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
41 "Time when the timer was paused.") |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
42 |
100269
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
43 (defconst org-timer-re "\\([-+]?[0-9]+\\):\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)" |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
44 "Regular expression used to match timer stamps.") |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
45 |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
46 (defcustom org-timer-format "%s " |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
47 "The format to insert the time of the timer. |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
48 This format must contain one instance of \"%s\" which will be replaced by |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
49 the value of the relative timer." |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
50 :group 'org-time |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
51 :type 'string) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
52 |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
53 (defcustom org-timer-default-timer 0 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
54 "The default timer when a timer is set. |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
55 When 0, the user is prompted for a value." |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
56 :group 'org-time |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
57 :type 'number) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
58 |
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
59 (defvar org-timer-start-hook nil |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
60 "Hook run after relative timer is started.") |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
61 |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
62 (defvar org-timer-stop-hook nil |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
63 "Hook run before relative timer is stopped.") |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
64 |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
65 (defvar org-timer-pause-hook nil |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
66 "Hook run before relative timer is paused.") |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
67 |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
68 (defvar org-timer-set-hook nil |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
69 "Hook run after countdown timer is set.") |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
70 |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
71 (defvar org-timer-done-hook nil |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
72 "Hook run after countdown timer reaches zero.") |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
73 |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
74 (defvar org-timer-cancel-hook nil |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
75 "Hook run before countdown timer is canceled.") |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
76 |
100269
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
77 ;;;###autoload |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
78 (defun org-timer-start (&optional offset) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
79 "Set the starting time for the relative timer to now. |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
80 When called with prefix argument OFFSET, prompt the user for an offset time, |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
81 with the default taken from a timer stamp at point, if any. |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
82 If OFFSET is a string or an integer, it is directly taken to be the offset |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
83 without user interaction. |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
84 When called with a double prefix arg, all timer strings in the active |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
85 region will be shifted by a specific amount. You will be prompted for |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
86 the amount, with the default to make the first timer string in |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
87 the region 0:00:00." |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
88 (interactive "P") |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
89 (if (equal offset '(16)) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
90 (call-interactively 'org-timer-change-times-in-region) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
91 (let (delta def s) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
92 (if (not offset) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
93 (setq org-timer-start-time (current-time)) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
94 (cond |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
95 ((integerp offset) (setq delta offset)) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
96 ((stringp offset) (setq delta (org-timer-hms-to-secs offset))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
97 (t |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
98 (setq def (if (org-in-regexp org-timer-re) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
99 (match-string 0) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
100 "0:00:00") |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
101 s (read-string |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
102 (format "Restart timer with offset [%s]: " def))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
103 (unless (string-match "\\S-" s) (setq s def)) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
104 (setq delta (org-timer-hms-to-secs (org-timer-fix-incomplete s))))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
105 (setq org-timer-start-time |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
106 (seconds-to-time |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
107 (- (org-float-time) delta)))) |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
108 (org-timer-set-mode-line 'on) |
100269
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
109 (message "Timer start time set to %s, current value is %s" |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
110 (format-time-string "%T" org-timer-start-time) |
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
111 (org-timer-secs-to-hms (or delta 0))) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
112 (run-hooks 'org-timer-start-hook)))) |
100269
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
113 |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
114 (defun org-timer-pause-or-continue (&optional stop) |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
115 "Pause or continue the relative timer. |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
116 With prefix arg STOP, stop it entirely." |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
117 (interactive "P") |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
118 (cond |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
119 (stop (org-timer-stop)) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
120 ((not org-timer-start-time) (error "No timer is running")) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
121 (org-timer-pause-time |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
122 ;; timer is paused, continue |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
123 (setq org-timer-start-time |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
124 (seconds-to-time |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
125 (- |
104810
86b7fe7d1d8f
2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
104164
diff
changeset
|
126 (org-float-time) |
86b7fe7d1d8f
2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
104164
diff
changeset
|
127 (- (org-float-time org-timer-pause-time) |
86b7fe7d1d8f
2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
104164
diff
changeset
|
128 (org-float-time org-timer-start-time)))) |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
129 org-timer-pause-time nil) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
130 (org-timer-set-mode-line 'on) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
131 (message "Timer continues at %s" (org-timer-value-string))) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
132 (t |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
133 ;; pause timer |
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
134 (run-hooks 'org-timer-pause-hook) |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
135 (setq org-timer-pause-time (current-time)) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
136 (org-timer-set-mode-line 'pause) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
137 (message "Timer paused at %s" (org-timer-value-string))))) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
138 |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
139 (defun org-timer-stop () |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
140 "Stop the relative timer." |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
141 (interactive) |
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
142 (run-hooks 'org-timer-stop-hook) |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
143 (setq org-timer-start-time nil |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
144 org-timer-pause-time nil) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
145 (org-timer-set-mode-line 'off)) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
146 |
100269
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
147 ;;;###autoload |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
148 (defun org-timer (&optional restart) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
149 "Insert a H:MM:SS string from the timer into the buffer. |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
150 The first time this command is used, the timer is started. When used with |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
151 a \\[universal-argument] prefix, force restarting the timer. |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
152 When used with a double prefix argument \ |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
153 \\[universal-argument] \\universal-argument], change all the timer string |
100269
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
154 in the region by a fixed amount. This can be used to recalibrate a timer |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
155 that was not started at the correct moment." |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
156 (interactive "P") |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
157 (if (equal restart '(4)) (org-timer-start)) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
158 (or org-timer-start-time (org-timer-start)) |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
159 (insert (org-timer-value-string))) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
160 |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
161 (defun org-timer-value-string () |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
162 (format org-timer-format (org-timer-secs-to-hms (floor (org-timer-seconds))))) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
163 |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
164 (defun org-timer-seconds () |
104810
86b7fe7d1d8f
2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
104164
diff
changeset
|
165 (- (org-float-time (or org-timer-pause-time (current-time))) |
86b7fe7d1d8f
2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
104164
diff
changeset
|
166 (org-float-time org-timer-start-time))) |
100269
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
167 |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
168 ;;;###autoload |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
169 (defun org-timer-change-times-in-region (beg end delta) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
170 "Change all h:mm:ss time in region by a DELTA." |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
171 (interactive |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
172 "r\nsEnter time difference like \"-1:08:26\". Default is first time to zero: ") |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
173 (let ((re "[-+]?[0-9]+:[0-9]\\{2\\}:[0-9]\\{2\\}") p) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
174 (unless (string-match "\\S-" delta) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
175 (save-excursion |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
176 (goto-char beg) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
177 (when (re-search-forward re end t) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
178 (setq delta (match-string 0)) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
179 (if (equal (string-to-char delta) ?-) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
180 (setq delta (substring delta 1)) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
181 (setq delta (concat "-" delta)))))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
182 (setq delta (org-timer-hms-to-secs (org-timer-fix-incomplete delta))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
183 (when (= delta 0) (error "No change")) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
184 (save-excursion |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
185 (goto-char end) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
186 (while (re-search-backward re beg t) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
187 (setq p (point)) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
188 (replace-match |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
189 (save-match-data |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
190 (org-timer-secs-to-hms (+ (org-timer-hms-to-secs (match-string 0)) delta))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
191 t t) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
192 (goto-char p))))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
193 |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
194 ;;;###autoload |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
195 (defun org-timer-item (&optional arg) |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
196 "Insert a description-type item with the current timer value." |
100269
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
197 (interactive "P") |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
198 (let ((ind 0)) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
199 (save-excursion |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
200 (skip-chars-backward " \n\t") |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
201 (condition-case nil |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
202 (progn |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
203 (org-beginning-of-item) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
204 (setq ind (org-get-indentation))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
205 (error nil))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
206 (or (bolp) (newline)) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
207 (org-indent-line-to ind) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
208 (insert "- ") |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
209 (org-timer (if arg '(4))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
210 (insert ":: "))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
211 |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
212 (defun org-timer-fix-incomplete (hms) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
213 "If hms is a H:MM:SS string with missing hour or hour and minute, fix it." |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
214 (if (string-match "\\(?:\\([0-9]+:\\)?\\([0-9]+:\\)\\)?\\([0-9]+\\)" hms) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
215 (replace-match |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
216 (format "%d:%02d:%02d" |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
217 (if (match-end 1) (string-to-number (match-string 1 hms)) 0) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
218 (if (match-end 2) (string-to-number (match-string 2 hms)) 0) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
219 (string-to-number (match-string 3 hms))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
220 t t hms) |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
221 (error "Cannot parse HMS string \"%s\"" hms))) |
100269
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
222 |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
223 (defun org-timer-hms-to-secs (hms) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
224 "Convert h:mm:ss string to an integer time. |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
225 If the string starts with a minus sign, the integer will be negative." |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
226 (if (not (string-match |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
227 "\\([-+]?[0-9]+\\):\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)" |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
228 hms)) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
229 0 |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
230 (let* ((h (string-to-number (match-string 1 hms))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
231 (m (string-to-number (match-string 2 hms))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
232 (s (string-to-number (match-string 3 hms))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
233 (sign (equal (substring (match-string 1 hms) 0 1) "-"))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
234 (setq h (abs h)) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
235 (* (if sign -1 1) (+ s (* 60 (+ m (* 60 h)))))))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
236 |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
237 (defun org-timer-secs-to-hms (s) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
238 "Convert integer S into h:mm:ss. |
100458
ba23e35d3eaf
2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100448
diff
changeset
|
239 If the integer is negative, the string will start with \"-\"." |
100269
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
240 (let (sign m h) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
241 (setq sign (if (< s 0) "-" "") |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
242 s (abs s) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
243 m (/ s 60) s (- s (* 60 m)) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
244 h (/ m 60) m (- m (* 60 h))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
245 (format "%s%d:%02d:%02d" sign h m s))) |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
246 |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
247 (defvar org-timer-mode-line-timer nil) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
248 (defvar org-timer-mode-line-string nil) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
249 |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
250 (defun org-timer-set-mode-line (value) |
105973
b7d8222914b4
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
105341
diff
changeset
|
251 "Set the mode-line display of the relative timer. |
101458
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
252 VALUE can be `on', `off', or `pause'." |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
253 (or global-mode-string (setq global-mode-string '(""))) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
254 (or (memq 'org-timer-mode-line-string global-mode-string) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
255 (setq global-mode-string |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
256 (append global-mode-string '(org-timer-mode-line-string)))) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
257 (cond |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
258 ((equal value 'off) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
259 (when org-timer-mode-line-timer |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
260 (cancel-timer org-timer-mode-line-timer) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
261 (setq org-timer-mode-line-timer nil)) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
262 (setq global-mode-string |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
263 (delq 'org-timer-mode-line-string global-mode-string)) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
264 (force-mode-line-update)) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
265 ((equal value 'pause) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
266 (when org-timer-mode-line-timer |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
267 (cancel-timer org-timer-mode-line-timer) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
268 (setq org-timer-mode-line-timer nil))) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
269 ((equal value 'on) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
270 (or global-mode-string (setq global-mode-string '(""))) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
271 (or (memq 'org-timer-mode-line-string global-mode-string) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
272 (setq global-mode-string |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
273 (append global-mode-string '(org-timer-mode-line-string)))) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
274 (org-timer-update-mode-line) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
275 (when org-timer-mode-line-timer |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
276 (cancel-timer org-timer-mode-line-timer)) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
277 (setq org-timer-mode-line-timer |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
278 (run-with-timer 1 1 'org-timer-update-mode-line))))) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
279 |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
280 (defun org-timer-update-mode-line () |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
281 "Update the timer time in the mode line." |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
282 (if org-timer-pause-time |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
283 nil |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
284 (setq org-timer-mode-line-string |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
285 (concat " <" (substring (org-timer-value-string) 0 -1) ">")) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
286 (force-mode-line-update))) |
36abe982e7cd
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
100908
diff
changeset
|
287 |
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
288 (defvar org-timer-current-timer nil) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
289 (defun org-timer-cancel-timer () |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
290 "Cancel the current timer." |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
291 (interactive) |
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
292 (when (eval org-timer-current-timer) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
293 (run-hooks 'org-timer-cancel-hook) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
294 (cancel-timer org-timer-current-timer) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
295 (setq org-timer-current-timer nil)) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
296 (message "Last timer canceled")) |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
297 |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
298 (defun org-timer-show-remaining-time () |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
299 "Display the remaining time before the timer ends." |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
300 (interactive) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
301 (require 'time) |
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
302 (if (not org-timer-current-timer) |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
303 (message "No timer set") |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
304 (let* ((rtime (decode-time |
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
305 (time-subtract (timer--time org-timer-current-timer) |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
306 (current-time)))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
307 (rsecs (nth 0 rtime)) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
308 (rmins (nth 1 rtime))) |
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
106815
diff
changeset
|
309 (message "%d minute(s) %d seconds left before next time out" |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
310 rmins rsecs)))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
311 |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
312 (defun bzg-test (&optional test) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
313 (interactive "P") |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
314 test) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
315 |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
316 ;;;###autoload |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
317 (defun org-timer-set-timer (&optional opt) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
318 "Prompt for a duration and set a timer. |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
319 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
320 If `org-timer-default-timer' is not zero, suggest this value as |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
321 the default duration for the timer. If a timer is already set, |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
322 prompt the use if she wants to replace it. |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
323 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
324 Called with a numeric prefix argument, use this numeric value as |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
325 the duration of the timer. |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
326 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
327 Called with a `C-u' prefix arguments, use `org-timer-default-timer' |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
328 without prompting the user for a duration. |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
329 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
330 With two `C-u' prefix arguments, use `org-timer-default-timer' |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
331 without prompting the user for a duration and automatically |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
332 replace any running timer." |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
333 (interactive "P") |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
334 (let ((minutes (or (and (numberp opt) (number-to-string opt)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
335 (and (listp opt) (not (null opt)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
336 (number-to-string org-timer-default-timer)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
337 (read-from-minibuffer |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
338 "How many minutes left? " |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
339 (if (not (eq org-timer-default-timer 0)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
340 (number-to-string org-timer-default-timer)))))) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
341 (if (not (string-match "[0-9]+" minutes)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
342 (org-timer-show-remaining-time) |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
343 (let* ((mins (string-to-number (match-string 0 minutes))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
344 (secs (* mins 60)) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
345 (hl (cond |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
346 ((string-match "Org Agenda" (buffer-name)) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
347 (let* ((marker (or (get-text-property (point) 'org-marker) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
348 (org-agenda-error))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
349 (hdmarker (or (get-text-property (point) 'org-hd-marker) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
350 marker)) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
351 (pos (marker-position marker))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
352 (with-current-buffer (marker-buffer marker) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
353 (widen) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
354 (goto-char pos) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
355 (org-show-entry) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
356 (org-get-heading)))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
357 ((eq major-mode 'org-mode) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
358 (org-get-heading)) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
359 (t (error "Not in an Org buffer")))) |
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
360 timer-set) |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
361 (if (or (and org-timer-current-timer |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
362 (or (equal opt '(16)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
363 (y-or-n-p "Replace current timer? "))) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
364 (not org-timer-current-timer)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
365 (progn |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
366 (when org-timer-current-timer |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
367 (cancel-timer org-timer-current-timer)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
368 (setq org-timer-current-timer |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
369 (run-with-timer |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
370 secs nil `(lambda () |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
371 (setq org-timer-current-timer nil) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
372 (org-notify ,(format "%s: time out" hl) t) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
373 (run-hooks 'org-timer-done-hook)))) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
374 (run-hooks 'org-timer-set-hook)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
107863
diff
changeset
|
375 (message "No timer set")))))) |
104164
ac1a55cc2c38
2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101757
diff
changeset
|
376 |
101670
a15c11f894f1
2009-01-30 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101607
diff
changeset
|
377 (provide 'org-timer) |
a15c11f894f1
2009-01-30 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents:
101607
diff
changeset
|
378 |
100269
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
379 ;; arch-tag: 97538f8c-3871-4509-8f23-1e7b3ff3d107 |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
380 |
032aa24b2125
Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
381 ;;; org-timer.el ends here |