comparison lisp/org/org-clock.el @ 96975:60149c696033

2008-07-24 Carsten Dominik <dominik@science.uva.nl> * org-exp.el (org-export-region-as-html, org-export-as-html): Make sure that calls from `org-export-region-as-html' do not do the special check for a subtree. * org-agenda.el (org-batch-store-agenda-views): Fix parsing bug. * org.el (org-open-file): Use `org-open-directory-means-index-dot-org'. (org-open-directory-means-index-dot-org): New option. * org.el (org-make-link-string): Remove link attributes from description. (org-open-at-point): Remove link attributes bevore using the path. * org-exp.el (org-export-as-html): Handle link attributes. * org.el (org-extract-attributes, org-attributes-to-string): New functions. * org-table.el (org-table-to-lisp): New function. * org.el (org-narrow-to-subtree): Do not include the final newline into the narrowed region. * org-agenda.el (org-agenda-custom-commands-local-options): Fixed bug with user-define skipping condition. * org-agenda.el (org-agenda-get-restriction-and-command): Fixed typo. * org-exp.el (org-export-html-style-default): Automatic overflow handling for pre fields. (org-export-as-ascii, org-export-as-html): Change default format for time stamp. * org-table.el (org-table-export): Offer completion for translator functions, and do not require a heading above the table. * org.el (org-renumber-ordered-list, org-beginning-of-item-list): Cater for the case of a list starting in the first line of the buffer. * org-publish.el (org-publish-find-title): Bug fix. (org-publish-org-index): Implement new :index-style option. * org-publish.el (org-publish-timestamp-filename): Use SHA1-encoded file names in the timestamp directory. * org-publish.el (org-publish-needed-p): Be verbose about files published and files skipped. * org-exp.el (org-export-preprocess-string): Swap link normalization and inernal link targeting. * org-publish.el (org-publish-needed-p): Create timestamp directory when it does not exist. * org-clock.el (org-clock-out-when-done): Doc fix. * org.el (org-agenda-skip-unavailable-files): Doc fix. * org-exp.el (org-export-remove-comment-blocks-and-subtrees): Ignore case when searching for the COMMENT cookie at export time. * org-exp.el (org-get-file-contents) (org-get-and-remove-property): New functions. (org-export-handle-include-files): Handle the new prefix options. (org-export-as-html): Fix the verse environment. * org.el (org-time=, org-time<, org-time<=, org-time>) (org-time>=, org-time<>, org-2ft): New functions. (org-op-to-function): Also provide for the time testing fucntions. * org-exp.el (org-export-html-style-default): New constant. * org-exp.el (org-export-html-style-extra): New variable. (org-export-splice-style): New function. * org-exp.el (org-export-plist-vars, org-export-as-html): Implement `org-export-creator-info'. (org-export-creator-info): New option. * org.el (org-clock-drawer-start-re, org-clock-drawer-end-re) (org-property-drawer-re, org-clock-drawer-re): New constants. * org-exp.el (org-icalendar-use-deadline) (org-icalendar-use-scheduled): New options. (org-icalendar-include-todo): Default changed to t. (org-print-icalendar-entries): Implement better utilization of scheduling and deadline time stamps. (org-export-target-internal-links, org-export-as-html): Allow file lines without the "file:" prefix if the file path is an absolute path or starts with ".". * org-clock.el (org-clocktable-shift): Also undertand yesterday, lastweek etc. (org-clock-special-range): Also undertand yesterday, lastweek etc. * org.el (org-agenda-skip-archived-trees): Docstring now discourages using this. (org-scan-tags): Check for org-agenda-archives-mode. (org-map-entries): Make sure org-agenda-archives-mode is nil. (org-agenda-files): Functionality of second arg changed. * org-agenda.el (org-agenda-archives-mode): New variable (org-write-agenda, org-prepare-agenda, org-agenda-list) (org-search-view, org-todo-list, org-tags-view) (org-agenda-list-stuck-projects): Call `org-agenda-files' with `ifmode' argument. (org-agenda-quit): Reset the archives mode. (org-agenda-archives-mode): New command. (org-agenda-set-mode-name): Include archives info. * org.el (org-paste-subtree): Make sure the yanked headline is visible if it was yanked at a visible point. (org-move-item-up): Fix the bug with moving white space at the end of the item. (org-show-empty-lines-in-parent): New function.
author Carsten Dominik <dominik@science.uva.nl>
date Thu, 24 Jul 2008 13:59:56 +0000
parents 2bab01f9c7bb
children adc2dffbdfc3
comparison
equal deleted inserted replaced
96974:fa6516860909 96975:60149c696033
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. 3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4 4
5 ;; Author: Carsten Dominik <carsten at orgmode dot org> 5 ;; Author: Carsten Dominik <carsten at orgmode dot org>
6 ;; Keywords: outlines, hypermedia, calendar, wp 6 ;; Keywords: outlines, hypermedia, calendar, wp
7 ;; Homepage: http://orgmode.org 7 ;; Homepage: http://orgmode.org
8 ;; Version: 6.05a 8 ;; Version: 6.06a
9 ;; 9 ;;
10 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
11 ;; 11 ;;
12 ;; GNU Emacs is free software: you can redistribute it and/or modify 12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by 13 ;; it under the terms of the GNU General Public License as published by
52 (const :tag "Always" t) 52 (const :tag "Always" t)
53 (const :tag "Only when drawer exists" nil) 53 (const :tag "Only when drawer exists" nil)
54 (integer :tag "When at least N clock entries"))) 54 (integer :tag "When at least N clock entries")))
55 55
56 (defcustom org-clock-out-when-done t 56 (defcustom org-clock-out-when-done t
57 "When t, the clock will be stopped when the relevant entry is marked DONE. 57 "When non-nil, the clock will be stopped when the relevant entry is marked DONE.
58 When nil, clock will keep running until stopped explicitly with 58 A nil value means, clock will keep running until stopped explicitly with
59 `C-c C-x C-o', or until the clock is started in a different item." 59 `C-c C-x C-o', or until the clock is started in a different item."
60 :group 'org-clock 60 :group 'org-clock
61 :type 'boolean) 61 :type 'boolean)
62 62
63 (defcustom org-clock-out-remove-zero-time-clocks nil 63 (defcustom org-clock-out-remove-zero-time-clocks nil
134 134
135 (defun org-clock-select-task (&optional prompt) 135 (defun org-clock-select-task (&optional prompt)
136 "Select a task that recently was associated with clocking." 136 "Select a task that recently was associated with clocking."
137 (interactive) 137 (interactive)
138 (let (sel-list rpl file task (i 0) s) 138 (let (sel-list rpl file task (i 0) s)
139 (save-window-excursion 139 (save-window-excursion
140 (org-switch-to-buffer-other-window 140 (org-switch-to-buffer-other-window
141 (get-buffer-create "*Clock Task Select*")) 141 (get-buffer-create "*Clock Task Select*"))
142 (erase-buffer) 142 (erase-buffer)
143 (when (marker-buffer org-clock-default-task) 143 (when (marker-buffer org-clock-default-task)
144 (insert (org-add-props "Default Task\n" nil 'face 'bold)) 144 (insert (org-add-props "Default Task\n" nil 'face 'bold))
188 (org-get-category))) 188 (org-get-category)))
189 task (org-get-heading 'notags))))) 189 task (org-get-heading 'notags)))))
190 (when (and cat task) 190 (when (and cat task)
191 (insert (format "[%c] %-15s %s\n" i cat task)) 191 (insert (format "[%c] %-15s %s\n" i cat task))
192 (cons i marker))))) 192 (cons i marker)))))
193 193
194 (defun org-update-mode-line () 194 (defun org-update-mode-line ()
195 (let* ((delta (- (time-to-seconds (current-time)) 195 (let* ((delta (- (time-to-seconds (current-time))
196 (time-to-seconds org-clock-start-time))) 196 (time-to-seconds org-clock-start-time)))
197 (h (floor delta 3600)) 197 (h (floor delta 3600))
198 (m (floor (- delta (* 3600 h)) 60))) 198 (m (floor (- delta (* 3600 h)) 60)))
205 "Information for the modeline about the running clock.") 205 "Information for the modeline about the running clock.")
206 206
207 (defun org-clock-in (&optional select) 207 (defun org-clock-in (&optional select)
208 "Start the clock on the current item. 208 "Start the clock on the current item.
209 If necessary, clock-out of the currently active clock. 209 If necessary, clock-out of the currently active clock.
210 With prefix arg SELECT, offer a list of recently clocked ta sks to 210 With prefix arg SELECT, offer a list of recently clocked tasks to
211 clock into. When SELECT is `C-u C-u', clock into the current task and mark 211 clock into. When SELECT is `C-u C-u', clock into the current task and mark
212 is as the default task, a special task that will always be offered in 212 is as the default task, a special task that will always be offered in
213 the clocking selection, associated with the letter `d'." 213 the clocking selection, associated with the letter `d'."
214 (interactive "P") 214 (interactive "P")
215 (let ((interrupting (marker-buffer org-clock-marker)) 215 (let ((interrupting (marker-buffer org-clock-marker))
224 ;; Save a marker to this task, so that we can go back. 224 ;; Save a marker to this task, so that we can go back.
225 (move-marker org-clock-interrupted-task 225 (move-marker org-clock-interrupted-task
226 (marker-position org-clock-marker) 226 (marker-position org-clock-marker)
227 (marker-buffer org-clock-marker)) 227 (marker-buffer org-clock-marker))
228 (org-clock-out t)) 228 (org-clock-out t))
229 229
230 (when (equal select '(16)) 230 (when (equal select '(16))
231 ;; Mark as default clocking task 231 ;; Mark as default clocking task
232 (save-excursion 232 (save-excursion
233 (org-back-to-heading t) 233 (org-back-to-heading t)
234 (move-marker org-clock-default-task (point)))) 234 (move-marker org-clock-default-task (point))))
235 235
236 (setq target-pos (point)) ;; we want to clock in at this location 236 (setq target-pos (point)) ;; we want to clock in at this location
237 (save-excursion 237 (save-excursion
238 (when (and selected-task (marker-buffer selected-task)) 238 (when (and selected-task (marker-buffer selected-task))
239 ;; There is a selected task, move to the correct buffer 239 ;; There is a selected task, move to the correct buffer
240 ;; and set the new target position. 240 ;; and set the new target position.
259 (if (looking-at org-complex-heading-regexp) 259 (if (looking-at org-complex-heading-regexp)
260 (setq org-clock-heading (match-string 4)) 260 (setq org-clock-heading (match-string 4))
261 (setq org-clock-heading "???"))) 261 (setq org-clock-heading "???")))
262 (setq org-clock-heading (propertize org-clock-heading 'face nil)) 262 (setq org-clock-heading (propertize org-clock-heading 'face nil))
263 (org-clock-find-position) 263 (org-clock-find-position)
264 264
265 (insert "\n") (backward-char 1) 265 (insert "\n") (backward-char 1)
266 (indent-relative) 266 (indent-relative)
267 (insert org-clock-string " ") 267 (insert org-clock-string " ")
268 (setq org-clock-start-time (current-time)) 268 (setq org-clock-start-time (current-time))
269 (setq ts (org-insert-time-stamp (current-time) 'with-hm 'inactive)) 269 (setq ts (org-insert-time-stamp (current-time) 'with-hm 'inactive))
636 d (string-to-number (match-string 3 skey)) 636 d (string-to-number (match-string 3 skey))
637 key 'day)) 637 key 'day))
638 ((string-match "\\([-+][0-9]+\\)$" skey) 638 ((string-match "\\([-+][0-9]+\\)$" skey)
639 (setq shift (string-to-number (match-string 1 skey)) 639 (setq shift (string-to-number (match-string 1 skey))
640 key (intern (substring skey 0 (match-beginning 1)))))) 640 key (intern (substring skey 0 (match-beginning 1))))))
641 (unless shift 641 (when (= shift 0)
642 (cond ((eq key 'yesterday) (setq key 'today shift -1)) 642 (cond ((eq key 'yesterday) (setq key 'today shift -1))
643 ((eq key 'lastweek) (setq key 'week shift -1)) 643 ((eq key 'lastweek) (setq key 'week shift -1))
644 ((eq key 'lastmonth) (setq key 'month shift -1)) 644 ((eq key 'lastmonth) (setq key 'month shift -1))
645 ((eq key 'lastyear) (setq key 'year shift -1)))) 645 ((eq key 'lastyear) (setq key 'year shift -1))))
646 (cond 646 (cond
687 (if (not (looking-at "#\\+BEGIN: clocktable\\>.*?:block[ \t]+\\(\\S-+\\)")) 687 (if (not (looking-at "#\\+BEGIN: clocktable\\>.*?:block[ \t]+\\(\\S-+\\)"))
688 (error "Line needs a :block definition before this command works") 688 (error "Line needs a :block definition before this command works")
689 (let* ((b (match-beginning 1)) (e (match-end 1)) 689 (let* ((b (match-beginning 1)) (e (match-end 1))
690 (s (match-string 1)) 690 (s (match-string 1))
691 block shift ins y mw d date wp m) 691 block shift ins y mw d date wp m)
692 (cond
693 ((equal s "yesterday") (setq s "today-1"))
694 ((equal s "lastweek") (setq s "thisweek-1"))
695 ((equal s "lastmonth") (setq s "thismonth-1"))
696 ((equal s "lastyear") (setq s "thisyear-1")))
692 (cond 697 (cond
693 ((string-match "^\\(today\\|thisweek\\|thismonth\\|thisyear\\)\\([-+][0-9]+\\)?$" s) 698 ((string-match "^\\(today\\|thisweek\\|thismonth\\|thisyear\\)\\([-+][0-9]+\\)?$" s)
694 (setq block (match-string 1 s) 699 (setq block (match-string 1 s)
695 shift (if (match-end 2) 700 shift (if (match-end 2)
696 (string-to-number (match-string 2 s)) 701 (string-to-number (match-string 2 s))
733 (catch 'exit 738 (catch 'exit
734 (let* ((hlchars '((1 . "*") (2 . "/"))) 739 (let* ((hlchars '((1 . "*") (2 . "/")))
735 (ins (make-marker)) 740 (ins (make-marker))
736 (total-time nil) 741 (total-time nil)
737 (scope (plist-get params :scope)) 742 (scope (plist-get params :scope))
738 (tostring (plist-get params :tostring)) 743 (tostring (plist-get params :tostring))
739 (multifile (plist-get params :multifile)) 744 (multifile (plist-get params :multifile))
740 (header (plist-get params :header)) 745 (header (plist-get params :header))
741 (maxlevel (or (plist-get params :maxlevel) 3)) 746 (maxlevel (or (plist-get params :maxlevel) 3))
742 (step (plist-get params :step)) 747 (step (plist-get params :step))
743 (emph (plist-get params :emphasize)) 748 (emph (plist-get params :emphasize))
744 (ts (plist-get params :tstart)) 749 (ts (plist-get params :tstart))
745 (te (plist-get params :tend)) 750 (te (plist-get params :tend))