summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2011-07-09 23:54:49 +0200
committerBastien Guerry <bzg@altern.org>2011-07-09 23:54:49 +0200
commitd406defd616d55ee733c315714778a56b5ca9cb6 (patch)
tree71724fc35a253ed63383bdb6d7911c3e971a1274
parentfd12e700b0bab747fd312e2384cd69444b6f35d8 (diff)
downloadorg-mode-d406defd616d55ee733c315714778a56b5ca9cb6.tar.gz
org-clock.el: Fix bug in `org-clock-timestamps-change'.
-rw-r--r--lisp/org-clock.el63
1 files changed, 32 insertions, 31 deletions
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 0c3deeb..a9c2cf6 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1426,38 +1426,39 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
"Change CLOCK timestamps synchronously at cursor.
UPDOWN tells whether to change 'up or 'down."
(setq org-ts-what nil)
- (let ((tschange (if (eq updown 'up) 'org-timestamp-up
- 'org-timestamp-down))
- ts1 begts1 ts2 begts2 updatets1 tdiff)
- (save-excursion
- (move-beginning-of-line 1)
- (re-search-forward org-ts-regexp3 nil t)
- (setq ts1 (match-string 0) begts1 (match-beginning 0))
- (when (re-search-forward org-ts-regexp3 nil t)
- (setq ts2 (match-string 0) begts2 (match-beginning 0))))
- ;; Are we on the second timestamp?
- (if (<= begts2 (point)) (setq updatets1 t))
- (if (not ts2)
- ;; fall back on org-timestamp-up if there is only one
+ (when (org-at-timestamp-p t)
+ (let ((tschange (if (eq updown 'up) 'org-timestamp-up
+ 'org-timestamp-down))
+ ts1 begts1 ts2 begts2 updatets1 tdiff)
+ (save-excursion
+ (move-beginning-of-line 1)
+ (re-search-forward org-ts-regexp3 nil t)
+ (setq ts1 (match-string 0) begts1 (match-beginning 0))
+ (when (re-search-forward org-ts-regexp3 nil t)
+ (setq ts2 (match-string 0) begts2 (match-beginning 0))))
+ ;; Are we on the second timestamp?
+ (if (<= begts2 (point)) (setq updatets1 t))
+ (if (not ts2)
+ ;; fall back on org-timestamp-up if there is only one
+ (funcall tschange)
+ ;; setq this so that (boundp 'org-ts-what is non-nil)
(funcall tschange)
- ;; setq this so that (boundp 'org-ts-what is non-nil)
- (funcall tschange)
- (let ((ts (if updatets1 ts2 ts1))
- (begts (if updatets1 begts1 begts2)))
- (setq tdiff
- (subtract-time
- (org-time-string-to-time org-last-changed-timestamp)
- (org-time-string-to-time ts)))
- (save-excursion
- (goto-char begts)
- (org-timestamp-change
- (round (/ (org-float-time tdiff)
- (cond ((eq org-ts-what 'minute) 60)
- ((eq org-ts-what 'hour) 3600)
- ((eq org-ts-what 'day) (* 24 3600))
- ((eq org-ts-what 'month) (* 24 3600 31))
- ((eq org-ts-what 'year) (* 24 3600 365.2)))))
- org-ts-what 'updown))))))
+ (let ((ts (if updatets1 ts2 ts1))
+ (begts (if updatets1 begts1 begts2)))
+ (setq tdiff
+ (subtract-time
+ (org-time-string-to-time org-last-changed-timestamp)
+ (org-time-string-to-time ts)))
+ (save-excursion
+ (goto-char begts)
+ (org-timestamp-change
+ (round (/ (org-float-time tdiff)
+ (cond ((eq org-ts-what 'minute) 60)
+ ((eq org-ts-what 'hour) 3600)
+ ((eq org-ts-what 'day) (* 24 3600))
+ ((eq org-ts-what 'month) (* 24 3600 31))
+ ((eq org-ts-what 'year) (* 24 3600 365.2)))))
+ org-ts-what 'updown)))))))
(defun org-clock-cancel ()
"Cancel the running clock by removing the start timestamp."