Browse Source

Clock/add_time Format

Replace all occurrences of the format string "%d:%02d" with
org-time-clocksum-format, which contains the same string by default.

This allows anyone to customize the appearance of clock summaries.

For example:

  (setq org-time-clocksum-format "%02d:%02d")
Carsten Dominik 17 years ago
parent
commit
56a96e0364
5 changed files with 23 additions and 6 deletions
  1. 11 0
      lisp/ChangeLog
  2. 3 3
      lisp/org-clock.el
  3. 1 1
      lisp/org-colview-xemacs.el
  4. 1 1
      lisp/org-colview.el
  5. 7 1
      lisp/org.el

+ 11 - 0
lisp/ChangeLog

@@ -1,6 +1,17 @@
 2008-05-16  Carsten Dominik  <dominik@science.uva.nl>
 
 	* org.el (org-olpath-completing-read): New function.
+	(org-time-clocksum-format): New option.
+	(org-minutes-to-hh:mm-string): Use `org-time-clocksum-format'.
+
+	* org-clock.el (org-clock-display, org-clock-out)
+	(org-update-mode-line): Use `org-time-clocksum-format'.
+
+	* org-colview-xemacs.el (org-columns-number-to-string): Use
+	`org-time-clocksum-format'.
+
+	* org-colview.el (org-columns-number-to-string): Use
+	`org-time-clocksum-format'.
 
 2008-05-15  Carsten Dominik  <dominik@science.uva.nl>
 

+ 3 - 3
lisp/org-clock.el

@@ -197,7 +197,7 @@ of a different task.")
 	 (h (floor delta 3600))
 	 (m (floor (- delta (* 3600 h)) 60)))
     (setq org-mode-line-string
-	  (propertize (format "-[%d:%02d (%s)]" h m org-clock-heading)
+	  (propertize (format (concat "-[" org-time-clocksum-format " (%s)]") h m org-clock-heading)
 		      'help-echo "Org-mode clock is running"))
     (force-mode-line-update)))
 
@@ -375,7 +375,7 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
 	(setq global-mode-string
 	      (delq 'org-mode-line-string global-mode-string))
 	(force-mode-line-update)
-	(message "Clock stopped at %s after HH:MM = %d:%02d%s" te h m
+	(message (concat "Clock stopped at %s after HH:MM = " org-time-clocksum-format "%s") te h m
 		 (if remove " => LINE REMOVED" "")))))))
 
 (defun org-clock-cancel ()
@@ -487,7 +487,7 @@ in the echo area."
 	(when org-remove-highlights-with-change
 	  (org-add-hook 'before-change-functions 'org-remove-clock-overlays
 			nil 'local))))
-    (message "Total file time: %d:%02d (%d hours and %d minutes)" h m h m)))
+    (message (concat "Total file time: " org-time-clocksum-format " (%d hours and %d minutes)") h m h m)))
 
 (defvar org-clock-overlays nil)
 (make-variable-buffer-local 'org-clock-overlays)

+ 1 - 1
lisp/org-colview-xemacs.el

@@ -1042,7 +1042,7 @@ Don't set this, this is meant for dynamic scoping.")
   (cond
    ((eq fmt 'add_times)
     (let* ((h (floor n)) (m (floor (+ 0.5 (* 60 (- n h))))))
-      (format "%d:%02d" h m)))
+      (format org-time-clocksum-format h m)))
    ((eq fmt 'checkbox)
     (cond ((= n (floor n)) "[X]")
 	  ((> n 1.) "[-]")

+ 1 - 1
lisp/org-colview.el

@@ -837,7 +837,7 @@ Don't set this, this is meant for dynamic scoping.")
   (cond
    ((eq fmt 'add_times)
     (let* ((h (floor n)) (m (floor (+ 0.5 (* 60 (- n h))))))
-      (format "%d:%02d" h m)))
+      (format org-time-clocksum-format h m)))
    ((eq fmt 'checkbox)
     (cond ((= n (floor n)) "[X]")
 	  ((> n 1.) "[-]")

+ 7 - 1
lisp/org.el

@@ -1598,6 +1598,12 @@ end of the second format."
 	(concat "[" (substring f 1 -1) "]")
       f)))
 
+(defcustom org-time-clocksum-format "%d:%02d"
+  "The format string used when creating CLOCKSUM lines, or when
+org-mode generates a time duration."
+  :group 'org-time
+  :type 'string)
+  
 (defcustom org-deadline-warning-days 14
   "No. of days before expiration during which a deadline becomes active.
 This variable governs the display in sparse trees and in the agenda.
@@ -11387,7 +11393,7 @@ If there is already a time stamp at the cursor position, update it."
   "Compute H:MM from a number of minutes."
   (let ((h (/ m 60)))
     (setq m (- m (* 60 h)))
-    (format "%d:%02d" h m)))
+    (format org-time-clocksum-format h m)))
 
 (defun org-hh:mm-string-to-minutes (s)
   "Convert a string H:MM to a number of minutes."