diff options
author | Bastien Guerry <bastien1@free.fr> | 2011-07-28 17:13:49 +0200 |
---|---|---|
committer | Bastien Guerry <bastien1@free.fr> | 2011-07-28 17:13:49 +0200 |
commit | 3ab2c837b302b01fff610f7b83050ab7e703477c (patch) | |
tree | efa67ed523bbda4d41488ae6b9ad2782941ddcf2 /lisp/org/org-timer.el | |
parent | 44a8054f971837447e80d618b6e0c2a77778a2ee (diff) | |
download | emacs-3ab2c837b302b01fff610f7b83050ab7e703477c.tar.gz |
Merge changes from Org 7.4 to current Org 7.7.
Diffstat (limited to 'lisp/org/org-timer.el')
-rw-r--r-- | lisp/org/org-timer.el | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/lisp/org/org-timer.el b/lisp/org/org-timer.el index f920062362b..e612d45b145 100644 --- a/lisp/org/org-timer.el +++ b/lisp/org/org-timer.el @@ -1,11 +1,11 @@ ;;; org-timer.el --- The relative timer code for Org-mode -;; Copyright (C) 2008-2011 Free Software Foundation, Inc. +;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: Carsten Dominik <carsten at orgmode dot org> ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 7.4 +;; Version: 7.7 ;; ;; This file is part of GNU Emacs. ;; @@ -65,6 +65,9 @@ When 0, the user is prompted for a value." (defvar org-timer-pause-hook nil "Hook run before relative timer is paused.") +(defvar org-timer-continue-hook nil + "Hook run after relative timer is continued.") + (defvar org-timer-set-hook nil "Hook run after countdown timer is set.") @@ -128,6 +131,7 @@ With prefix arg STOP, stop it entirely." (org-float-time org-timer-start-time)))) org-timer-pause-time nil) (org-timer-set-mode-line 'on) + (run-hooks 'org-timer-continue-hook) (message "Timer continues at %s" (org-timer-value-string))) (t ;; pause timer @@ -203,22 +207,27 @@ it in the buffer." (defun org-timer-item (&optional arg) "Insert a description-type item with the current timer value." (interactive "P") - (cond - ;; In a timer list, insert with `org-list-insert-item-generic'. - ((and (org-in-item-p) - (save-excursion (org-beginning-of-item) (org-at-item-timer-p))) - (org-list-insert-item-generic - (point) nil (concat (org-timer (when arg '(4)) t) ":: "))) - ;; In a list of another type, don't break anything: throw an error. - ((org-in-item-p) - (error "This is not a timer list")) - ;; Else, insert the timer correctly indented at bol. - (t - (beginning-of-line) - (org-indent-line-function) - (insert "- ") - (org-timer (when arg '(4))) - (insert ":: ")))) + (let ((itemp (org-in-item-p)) (pos (point))) + (cond + ;; In a timer list, insert with `org-list-insert-item', + ;; then fix the list. + ((and itemp (goto-char itemp) (org-at-item-timer-p)) + (let* ((struct (org-list-struct)) + (prevs (org-list-prevs-alist struct)) + (s (concat (org-timer (when arg '(4)) t) ":: "))) + (setq struct (org-list-insert-item pos struct prevs nil s)) + (org-list-write-struct struct (org-list-parents-alist struct)) + (looking-at org-list-full-item-re) + (goto-char (match-end 0)))) + ;; In a list of another type, don't break anything: throw an error. + (itemp (goto-char pos) (error "This is not a timer list")) + ;; Else, start a new list. + (t + (beginning-of-line) + (org-indent-line-function) + (insert "- ") + (org-timer (when arg '(4))) + (insert ":: "))))) (defun org-timer-fix-incomplete (hms) "If hms is a H:MM:SS string with missing hour or hour and minute, fix it." @@ -364,7 +373,7 @@ replace any running timer." (org-show-entry) (or (ignore-errors (org-get-heading)) (concat "File:" (file-name-nondirectory (buffer-file-name))))))) - ((eq major-mode 'org-mode) + ((org-mode-p) (or (ignore-errors (org-get-heading)) (concat "File:" (file-name-nondirectory (buffer-file-name))))) (t (error "Not in an Org buffer")))) @@ -394,5 +403,6 @@ replace any running timer." (provide 'org-timer) +;; arch-tag: 97538f8c-3871-4509-8f23-1e7b3ff3d107 ;;; org-timer.el ends here |