summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2011-07-09 18:12:18 +0200
committerBastien Guerry <bzg@altern.org>2011-07-09 18:12:18 +0200
commitfd12e700b0bab747fd312e2384cd69444b6f35d8 (patch)
treee78e0981618d0f36ce6a7ebfbdff45160ae2fa93
parenta493b4d489e8f6141a855e3db8ecc13bb63d39ac (diff)
downloadorg-mode-fd12e700b0bab747fd312e2384cd69444b6f35d8.tar.gz
Minor code cleanup.
-rw-r--r--lisp/org-clock.el76
-rw-r--r--lisp/org.el6
2 files changed, 42 insertions, 40 deletions
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 9043749..0c3deeb 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -38,6 +38,7 @@
(declare-function calendar-absolute-from-iso "cal-iso" (&optional date))
(declare-function notifications-notify "notifications" (&rest params))
(defvar org-time-stamp-formats)
+(defvar org-ts-what)
(defgroup org-clock nil
"Options concerning clocking working time in Org-mode."
@@ -1425,39 +1426,38 @@ 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)
- (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)
+ (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)
- (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)))))))
+ ;; 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))))))
(defun org-clock-cancel ()
"Cancel the running clock by removing the start timestamp."
@@ -1741,7 +1741,7 @@ fontified, and then returned."
"Create a table containing a report about clocked time.
If the cursor is inside an existing clocktable block, then the table
will be updated. If not, a new clocktable will be inserted. The scope
-of the new clock will be subtree when called from within a subtree, and
+of the new clock will be subtree when called from within a subtree, and
file elsewhere.
When called with a prefix argument, move to the first clock table in the
@@ -1753,11 +1753,11 @@ buffer and update it."
(org-show-entry))
(if (org-in-clocktable-p)
(goto-char (org-in-clocktable-p))
- (let ((props (if (ignore-errors
+ (let ((props (if (ignore-errors
(save-excursion (org-back-to-heading)))
(list :name "clocktable" :scope 'subtree)
(list :name "clocktable"))))
- (org-create-dblock
+ (org-create-dblock
(org-combine-plists org-clock-clocktable-default-properties props))))
(org-update-dblock))
@@ -2133,7 +2133,7 @@ from the dynamic block defintion."
;; much easier because there can be a fixed format with a
;; well-defined number of columns...
(let* ((hlchars '((1 . "*") (2 . "/")))
- (lwords (assoc (or (plist-get params :lang)
+ (lwords (assoc (or (plist-get params :lang)
org-export-default-language)
org-clock-clocktable-language-setup))
(multifile (plist-get params :multifile))
@@ -2221,14 +2221,14 @@ from the dynamic block defintion."
(if level-p (concat (nth 2 lwords) "|") "") ; level column, maybe
(if timestamp (concat (nth 3 lwords) "|") "") ; timestamp column, maybe
(if properties (concat (mapconcat 'identity properties "|") "|") "") ;properties columns, maybe
- (concat (nth 4 lwords) "|"
+ (concat (nth 4 lwords) "|"
(nth 5 lwords) "|\n")) ; headline and time columns
;; Insert the total time in the table
(insert-before-markers
"|-\n" ; a hline
"|" ; table line starter
- (if multifile (concat "| " (nth 6 lwords) " ") "")
+ (if multifile (concat "| " (nth 6 lwords) " ") "")
; file column, maybe
(if level-p "|" "") ; level column, maybe
(if timestamp "|" "") ; timestamp column, maybe
diff --git a/lisp/org.el b/lisp/org.el
index 9e9d85d..9cf48f0 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17547,7 +17547,8 @@ Depending on context, this does one of the following:
"Change timestamps synchronously up in CLOCK log lines."
(interactive)
(cond ((and (not org-support-shift-select)
- (org-at-clock-log-p))
+ (org-at-clock-log-p)
+ (org-at-timestamp-p t))
(org-clock-timestamps-up))
(t (org-shiftselect-error))))
@@ -17555,7 +17556,8 @@ Depending on context, this does one of the following:
"Change timestamps synchronously down in CLOCK log lines."
(interactive)
(cond ((and (not org-support-shift-select)
- (org-at-clock-log-p))
+ (org-at-clock-log-p)
+ (org-at-timestamp-p t))
(org-clock-timestamps-down))
(t (org-shiftselect-error))))