annotate lisp/org/org-timer.el @ 104810:86b7fe7d1d8f

2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-protocol.el (org-protocol-store-link) (org-protocol-remember, org-protocol-open-source): Add autoloads. * org-compat.el (org-float-time): New function. * org.el (org-clock-update-time-maybe) (org-sort-entries-or-items, org-do-sort) (org-evaluate-time-range, org-time-string-to-seconds) (org-closed-in-range): Use `org-float-time'. * org-timer.el (org-timer-start, org-timer-pause-or-continue) (org-timer-seconds): Use `org-float-time'. * org-clock.el (org-clock-get-clocked-time, org-clock-out) (org-clock-sum, org-dblock-write:clocktable) (org-clocktable-steps): Use `org-float-time'. * org-agenda.el (org-agenda-last-marker-time) (org-agenda-new-marker, org-diary): Use `org-float-time'. * org-compat.el (w32-focus-frame): Declare the w32-focus-frame function. * org-exp.el (org-get-file-contents): Only protect lines that really need it. * org-html.el (require): Require cl for compilation. * org.el: Avoid using `default-major-mode'. * org-plot.el (require): Require CL only at compile time. * org-exp.el (require): Require CL only at compile time. * org-agenda.el (org-agenda-quit): When the agenda window is dedicated, remove other windows before exiting, so that the frame really will be killed. * org-exp.el (org-export-handle-include-files): Reset START and END for each loop cycle. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-eval-in-calendar): Use `org-select-frame-set-input-focus'. * org-compat.el (org-select-frame-set-input-focus): New function. * org.el (org-update-statistics-cookies): New function. (org-mode-map): Bind `C-c #' to `org-update-statistics-cookies'. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-src.el (org-edit-fixed-width-region): Set org-src-mode only after the local variables are set. * org-latex.el (org-export-latex-protect-amp): New function. (org-export-latex-links): Protect link ampersands in tables. * org-exp.el (org-export-select-backend-specific-text): Match in two steps, to avoid regexp problems. * org.el (org-offer-links-in-entry): Improve working with many and duplicate links. * org-agenda.el (org-agenda-show-1): Make more consistent with normal cycling. (org-agenda-cycle-show): Make more consistent with normal cycling. * org-gnus.el (org-gnus-store-link): Restore the linking to a website. 2009-09-02 Bastien Guerry <bzg@altern.org> * org-latex.el (org-export-latex-first-lines): Bugfix. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-clock.el (org-clock-modify-effort-estimate): Emit message about new effort. * org.el (org-set-effort): New function. (org-mode-map): New key for effort setting command. * org-agenda.el (org-agenda): Keep window setup when calling agenda from within agenda window. (org-agenda-mode-map): New keys for effort setting commands. (org-agenda-menu): Add effort setting commands to menu. (org-agenda-set-property, org-agenda-set-effort): New functions. * org-latex.el (org-export-latex-tables): Fix `org-table-last-alignment' and `org-table-last-column-widths' if the first column has been removed. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-remove-timestamp-with-keyword): Only remove in entry, not in subtree. * org-src.el (org-src-lang-modes): Add abbreviation elisp for emacs lisp. * org.el (org-open-at-point): When on headline, offer all strings in entry. * org-remember.el (org-remember-templates): Documentation fix. * org.el (org-move-subtree-down): Use `org-get-next-sibling' and `org-get-last-sibling' instead of the outline versions of these functions. (org-get-last-sibling): New function. (org-refile): Use `org-get-next-sibling' instead of the outline version of this function. (org-clean-visibility-after-subtree-move): Use `org-get-next-sibling' and `org-get-last-sibling' instead of the outline versions of these functions. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-prepare-agenda): When creating a new frame for the agenda, make the window dedicated. * org-agenda.el (org-agenda-mode-map): New keys for time motion. * org-table.el (org-table-align): Change the order of reinsertion and deletion, to avoid problems with overlays following the table. * org.el (org-parse-time-string): Better error message. (org-show-subtree): Use org-end-of-subtree. * org-macs.el (org-goto-line): New defsubst. * org.el (org-open-file, org-change-tag-in-region) (org-fast-tag-show-exit): Don't use `goto-line'. * org-table.el (org-table-align, org-table-insert-column) (org-table-delete-column, org-table-move-column) (org-table-sort-lines, org-table-copy-region) (org-table-paste-rectangle, org-table-wrap-region) (org-table-get-specials, org-table-rotate-recalc-marks) (org-table-get-range, org-table-recalculate) (org-table-edit-formulas, org-table-fedit-convert-buffer) (org-table-show-reference, org-table-highlight-rectangle): Don't use `goto-line'. * org-src.el (org-edit-src-code, org-edit-fixed-width-region) (org-edit-src-exit): Don't use `goto-line'. * org-macs.el (org-preserve-lc): Don't use `goto-line'. * org-list.el (org-renumber-ordered-list, org-fix-bullet-type): Don't use `goto-line'. * org-exp.el (org-export-number-lines): Don't use `goto-line'. * org-colview.el (org-columns, org-columns-redo) (org-agenda-columns): Don't use `goto-line'. * org-colview-xemacs.el (org-columns, org-agenda-columns): Don't use `goto-line'. * org-agenda.el (org-agenda-mode): Force visual line motion off. (org-agenda-add-entry-text-maxlines): Improve docstring. (org-agenda-start-with-entry-text-mode): New option. (org-agenda-entry-text-maxlines): New option. (org-agenda-entry-text-mode): New variable. (org-agenda-mode): Set initial value of `org-agenda-entry-text-mode'. (org-agenda-mode-map): Add the `E' key. (org-agenda-menu): Add entry text mode to the menu. (org-agenda-get-some-entry-text): Fix line count bug. (org-finalize-agenda): Apply entry text mode if appropriate. (org-agenda-entry-text-show-here): New function. (org-agenda-entry-text-show): New function. (org-agenda-entry-text-hide): New function. (org-agenda-view-mode-dispatch): Add entry text mode to the view key menu. (org-agenda-entry-text-mode): New command. (org-agenda-set-mode-name): Add entry text mode to the mode line string. (org-agenda-undo, org-agenda-get-restriction-and-command) (org-agenda-get-some-entry-text, org-agenda-redo): Don't use `goto-line'. 2009-09-02 Bernt Hansen <bernt@norang.ca> * org-clock.el (org-notify): Bugfix. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-open-link): Handle multiple links and check for after-string. * org-gnus.el (org-gnus-store-link): Simplify. * org.el (org-latex-regexps): Don't add extra empty lines for display formulas. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-get-some-entry-text): New function. (org-agenda-add-entry-text): Use `org-agenda-get-some-entry-text'. * org.el (org-cycle-separator-lines): Update docstring. (org-cycle-show-empty-lines): Handle negative values for `org-cycle-show-empty-lines'. * org-exp.el (org-export-protect-sub-super): New function. (org-export-normalize-links): Protect the url of plain links from supscript and superscript processing. * org-remember.el (org-remember-escaped-%): New function. (org-remember-apply-template): Use `org-remember-escaped-%' to detect escaped % signs. 2009-09-02 Bastien Guerry <bzg@altern.org> * org-timer.el (org-timer-set-timer): Use `org-notify' and play a sound when showing the notification. * org-clock.el (org-notify): New function. (org-clock-notify-once-if-expired): Use `org-notify'. * org-gnus.el (org-gnus-store-link): Handle `gnus-summary-mode' and `gnus-article-mode' separately. (gnus-summary-article-header): Fix the declare-function. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-format-source-code-or-example): Translate language. * org-src.el (org-src-lang-modes): New variable (org-edit-src-code): Translate language. * org-exp.el (org-export-format-source-code-or-example): Deal wit the new structure of the `org-export-latex-listings-langs' variable. * org-latex.el (org-export-latex-listings-langs): Change structure of the variable from plist to alist. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-in-commented-line): New function. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-hide-block-toggle): Make folded blocks searchable. 2009-09-02 Friedrich Delgado Friedrichs <friedel@nomaden.org> (tiny change) * org.el (org-flag-drawer): More useful error. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-remember.el (org-remember-apply-template): Use org-icompleting-read. * org-publish.el (org-publish): Use org-icompleting-read. * org-colview.el (org-columns-edit-value, org-columns-new) (org-insert-columns-dblock): Use org-icompleting-read. * org-colview-xemacs.el (org-columns-edit-value) (org-columns-new, org-insert-columns-dblock): Use org-icompleting-read. * org-attach.el (org-attach-delete-one, org-attach-open): Use org-icompleting-read. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-hierarchical-todo-statistics): Improve docstring. (org-version): Return the version text. (org-org-menu): Add a menu entry for the new bug reporter. (org-submit-bug-report): New command. * org-list.el (org-hierarchical-checkbox-statistics): Improve docstring. * org.el (org-emphasis-regexp-components): Add "`" to set of pre-emphasis characters. * org-latex.el (org-export-latex-classes): Always include the soul package. (org-export-latex-emphasis-alist): Use \st for strikethough. * org-exp-blocks.el (org-export-blocks-preprocess): Use `indent-code-rigidly' to indent. * org-agenda.el (org-agenda-get-restriction-and-command): Remove properties only if MATCH really is a string. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-packages-alist): Fix customization type. * org.el (org-create-formula-image): Also use `org-export-latex-packages-alist'. * org-html.el (org-export-as-html): Fix bug in footnote regexp. (org-export-as-html): Format footnotes correctly. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-fast-tag-selection): Avoid text properties on tags in the alist. * org-agenda.el (org-agenda-get-restriction-and-command): Avoid text properties on the match element. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-set-regexps-and-options): Make sure the list of done keywords is not invalid. * org-exp.el (org-export-interpolate-newlines): New function. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-format-latex): Avoid nested overlays. * org-latex.el (org-export-latex-listings-langs): Add a few more languages. * org-exp.el (org-export-preprocess-apply-macros): Make sure to ignore newlines and space before the first macro argument. * org-latex.el (org-export-latex-tables): Remove save-excursion around `org-table-align'. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-export-html-special-string-regexps): Definition moved into org.el * org-exp.el (org-export-preprocess-apply-macros): Allow newlines in macro calls. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-listings) (org-export-latex-listings-langs): New options. * org-exp.el (org-export-format-source-code-or-example): Use listing package if requested by the user. 2009-09-02 Bastien Guerry <bzg@altern.org> * org.el (org-iswitchb): Fix bug when aborting the `org-iswitchb' command before actually switching to a buffer. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-get-file-contents): Only quote org lines when the markup is src or example. * org-agenda.el (org-agenda-skip-scheduled-if-deadline-is-shown): New option (org-agenda-get-day-entries): Remember deadline results and pass them on into the function getting the scheduling information. (org-agenda-get-scheduled): Accept deadline results as parameters and maybe skip some entries. (org-agenda-skip-scheduled-if-deadline-is-shown): New option. * org.el (org-insert-heading): When respecting content, do not convert current line to headline. * org-clock.el (org-clock-save-markers-for-cut-and-paste): Also cheeeeeck the hd marker (org-clock-in): Also set the hd marker. (org-clock-out): Also set the hd marker. (org-clock-cancel): Reset markers. * org.el (org-clock-hd-marker): New marker. * org-faces.el (org-agenda-clocking): New face. * org-agenda.el (org-agenda-mark-clocking-task): New function. (org-finalize-agenda): call `org-agenda-mark-clocking-task'. * org.el (org-modules): Add org-track.el. * org-agenda.el (org-agenda-bulk-marked-p): New function. (org-agenda-bulk-mark, org-agenda-bulk-unmark): Use `org-agenda-bulk-marked-p'. (org-agenda-bulk-toggle): New command. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-move-subtree-down): Hide subtree if it was folded, not just the body. * org-remember.el (org-remember-finalize): Avoid buffer-modified messages.
author Carsten Dominik <dominik@science.uva.nl>
date Wed, 02 Sep 2009 12:59:52 +0000
parents ac1a55cc2c38
children 2a8a3a69c1c7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
100908
a9dc0e7c3f2b Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 100605
diff changeset
3 ;; Copyright (C) 2008, 2009 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
104810
86b7fe7d1d8f 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 104164
diff changeset
8 ;; Version: 6.30c
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
032aa24b2125 Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
30 (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
31
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
32 (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
33 (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
34
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
35 (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
36 "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
37
101458
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
38 (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
39 "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
40
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
41 (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
42 "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
43
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 (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
45 "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
46 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
47 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
48 :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
49 :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
50
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 ;;;###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
52 (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
53 "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
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62 (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
63 (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
64 (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
65 (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
66 (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
67 (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
68 (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
69 ((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
70 ((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
71 (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
72 (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
73 (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
74 "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
75 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
76 (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
77 (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
78 (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
79 (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
80 (seconds-to-time
104810
86b7fe7d1d8f 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 104164
diff changeset
81 (- (org-float-time) (org-timer-hms-to-secs s)))))
101458
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
82 (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
83 (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
84 (format-time-string "%T" 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
85 (org-timer-secs-to-hms (or delta 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
86
101458
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
87 (defun org-timer-pause-or-continue (&optional stop)
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
88 "Pause or continue the relative timer. With prefix arg, stop it entirely."
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
89 (interactive "P")
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
90 (cond
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
91 (stop (org-timer-stop))
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
92 ((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
93 (org-timer-pause-time
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
94 ;; timer is paused, continue
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
95 (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
96 (seconds-to-time
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
97 (-
104810
86b7fe7d1d8f 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 104164
diff changeset
98 (org-float-time)
86b7fe7d1d8f 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 104164
diff changeset
99 (- (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
100 (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
101 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
102 (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
103 (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
104 (t
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
105 ;; pause timer
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
106 (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
107 (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
108 (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
109
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
110 (defun org-timer-stop ()
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
111 "Stop the relative timer."
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
112 (interactive)
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
113 (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
114 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
115 (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
116
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
117 ;;;###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
118 (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
119 "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
120 The first time this command is used, the timer is started. When used with
032aa24b2125 Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
121 a `C-u' prefix, force restarting 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
122 When used with a double prefix arg `C-u C-u', change all the timer 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
123 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
124 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
125 (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
126 (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
127 (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
128 (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
129
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
130 (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
131 (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
132
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
133 (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
134 (- (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
135 (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
136
032aa24b2125 Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
137 ;;;###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
138 (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
139 "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
140 (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
141 "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
142 (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
143 (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
144 (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
145 (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
146 (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
147 (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
148 (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
149 (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
150 (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
151 (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
152 (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
153 (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
154 (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
155 (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
156 (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
157 (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
158 (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
159 (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
160 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
161 (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
162
032aa24b2125 Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
163 ;;;###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
164 (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
165 "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
166 (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
167 (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
168 (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
169 (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
170 (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
171 (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
172 (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
173 (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
174 (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
175 (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
176 (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
177 (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
178 (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
179 (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
180
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 (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
182 "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
183 (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
184 (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
185 (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
186 (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
187 (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
188 (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
189 t t hms)
100458
ba23e35d3eaf 2008-12-17 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100448
diff changeset
190 (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
191
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 (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
193 "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
194 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
195 (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
196 "\\([-+]?[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
197 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
198 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 (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
200 (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
201 (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
202 (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
203 (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
204 (* (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
205
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 (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
207 "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
208 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
209 (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
210 (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
211 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
212 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
213 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
214 (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
215
101458
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
216 (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
217 (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
218
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
219 (defun org-timer-set-mode-line (value)
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
220 "Set the mode-line dispay of the relative timer.
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
221 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
222 (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
223 (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
224 (setq global-mode-string
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
225 (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
226 (cond
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
227 ((equal value 'off)
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
228 (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
229 (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
230 (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
231 (setq global-mode-string
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
232 (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
233 (force-mode-line-update))
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
234 ((equal value 'pause)
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
235 (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
236 (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
237 (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
238 ((equal value 'on)
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
239 (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
240 (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
241 (setq global-mode-string
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
242 (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
243 (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
244 (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
245 (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
246 (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
247 (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
248
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
249 (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
250 "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
251 (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
252 nil
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
253 (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
254 (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
255 (force-mode-line-update)))
36abe982e7cd 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 100908
diff changeset
256
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
257 (defvar org-timer-timer1 nil)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
258 (defvar org-timer-timer2 nil)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
259 (defvar org-timer-timer3 nil)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
260 (defvar org-timer-last-timer nil)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
261
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
262 (defun org-timer-cancel-timers ()
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
263 "Reset all timers."
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
264 (interactive)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
265 (mapc (lambda(timer)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
266 (when (eval timer)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
267 (cancel-timer timer)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
268 (setq timer nil)))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
269 '(org-timer-timer1
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
270 org-timer-timer2
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
271 org-timer-timer3))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
272 (message "All timers reset"))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
273
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
274 (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
275 "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
276 (interactive)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
277 (require 'time)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
278 (if (and (not org-timer-timer1)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
279 (not org-timer-timer2)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
280 (not org-timer-timer3))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
281 (message "No timer set")
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
282 (let* ((rtime (decode-time
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
283 (time-subtract (timer--time org-timer-last-timer)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
284 (current-time))))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
285 (rsecs (nth 0 rtime))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
286 (rmins (nth 1 rtime)))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
287 (message "%d minutes %d secondes left before next time out"
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
288 rmins rsecs))))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
289
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
290 ;;;###autoload
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
291 (defun org-timer-set-timer (minutes)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
292 "Set a timer."
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
293 (interactive "sTime out in (min)? ")
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
294 (if (not (string-match "[0-9]+" minutes))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
295 (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
296 (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
297 (secs (* mins 60))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
298 (hl (cond
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
299 ((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
300 (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
301 (org-agenda-error)))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
302 (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
303 marker))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
304 (pos (marker-position marker)))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
305 (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
306 (widen)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
307 (goto-char pos)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
308 (org-show-entry)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
309 (org-get-heading))))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
310 ((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
311 (org-get-heading))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
312 (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
313 timer-set)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
314 (mapcar (lambda(timer)
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
315 (if (not (or (eval timer) timer-set))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
316 (setq timer-set t
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
317 timer
104810
86b7fe7d1d8f 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 104164
diff changeset
318 (run-with-timer
86b7fe7d1d8f 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 104164
diff changeset
319 secs nil 'org-notify (format "%s: time out" hl) t)
104164
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
320 org-timer-last-timer timer)))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
321 '(org-timer-timer1
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
322 org-timer-timer2
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
323 org-timer-timer3)))))
ac1a55cc2c38 2009-08-06 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101757
diff changeset
324
101670
a15c11f894f1 2009-01-30 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101607
diff changeset
325 (provide 'org-timer)
a15c11f894f1 2009-01-30 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <dominik@science.uva.nl>
parents: 101607
diff changeset
326
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
327 ;; 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
328
032aa24b2125 Checking in the correct versions of the files, sorry, I hade used the files
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
329 ;;; org-timer.el ends here