summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2012-07-14 08:33:48 +0200
committerBastien Guerry <bzg@altern.org>2012-07-14 08:33:48 +0200
commitfea1b82befb73027b0a4ad00527dccd6a90e5479 (patch)
tree29e0d54e786ece9b98b60c456321a6ec0fe6335b
parentef3d4b5965b828e85a535ef3f32999473c6a2a7a (diff)
downloadorg-mode-fea1b82befb73027b0a4ad00527dccd6a90e5479.tar.gz
Bind `org-clock-in-last' to C-c C-x C-x and ̀org-clock-cancel' to C-c C-x C-q.
* org.el (org-flag-drawer): Add a docstring. (org-mode-map): Bind ̀org-clock-cancel' to "C-cC-xC-q" and `org-clock-in-last' to "C-cC-xC-x". This fixes a bug in the previous keybinding for `org-clock-in-last', which would override the one for `org-clock-in'. * org-clock.el (org-clock-in-last): Prevent errors when there is no clocking history. (org-clock-cancel): Fix bug when checking against a clock log in a folded drawer. Thanks to Bernt Hansen who reported the problem.
-rw-r--r--lisp/org-clock.el13
-rw-r--r--lisp/org.el6
2 files changed, 11 insertions, 8 deletions
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index e99eb52..162ee07 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1264,10 +1264,12 @@ last clock-out time, if any."
(let ((start-time (if (or org-clock-continuously (equal arg '(16)))
(or org-clock-out-time (current-time))
(current-time))))
- (org-clock-clock-in (list (car org-clock-history)) nil start-time)
- (message "Now clocking in: %s (in %s)"
- org-clock-current-task
- (buffer-name (marker-buffer org-clock-marker))))))
+ (if (null org-clock-history)
+ (message "No last clock")
+ (org-clock-clock-in (list (car org-clock-history)) nil start-time)
+ (message "Clocking back: %s (in %s)"
+ org-clock-current-task
+ (buffer-name (marker-buffer org-clock-marker)))))))
(defun org-clock-mark-default-task ()
"Mark current task as default task."
@@ -1560,8 +1562,7 @@ UPDOWN tells whether to change 'up or 'down."
(save-excursion ; Do not replace this with `with-current-buffer'.
(org-no-warnings (set-buffer (org-clocking-buffer)))
(goto-char org-clock-marker)
- (if (save-excursion (move-beginning-of-line 1)
- (looking-at (concat "^[ \t]*" org-clock-string)))
+ (if (looking-back (concat "^[ \t]*" org-clock-string ".*"))
(progn (delete-region (1- (point-at-bol)) (point-at-eol))
(org-remove-empty-drawer-at "LOGBOOK" (point)))
(message "Clock gone, cancel the timer anyway")
diff --git a/lisp/org.el b/lisp/org.el
index e728303..ddc6285 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6703,6 +6703,8 @@ open and agenda-wise Org files."
(org-flag-drawer t))))))
(defun org-flag-drawer (flag)
+ "When FLAG is non-nil, hide the drawer we are within.
+Otherwise make it visible."
(save-excursion
(beginning-of-line 1)
(when (looking-at "^[ \t]*:[a-zA-Z][a-zA-Z0-9]*:")
@@ -17800,10 +17802,10 @@ BEG and END default to the buffer boundaries."
(org-defkey org-mode-map "\C-c\C-x\C-t" 'org-toggle-time-stamp-overlays)
(org-defkey org-mode-map "\C-c\C-x\C-i" 'org-clock-in)
-(org-defkey org-mode-map "\C-c\C-x\C-I" 'org-clock-in-last)
+(org-defkey org-mode-map "\C-c\C-x\C-x" 'org-clock-in-last)
(org-defkey org-mode-map "\C-c\C-x\C-o" 'org-clock-out)
(org-defkey org-mode-map "\C-c\C-x\C-j" 'org-clock-goto)
-(org-defkey org-mode-map "\C-c\C-x\C-x" 'org-clock-cancel)
+(org-defkey org-mode-map "\C-c\C-x\C-q" 'org-clock-cancel)
(org-defkey org-mode-map "\C-c\C-x\C-d" 'org-clock-display)
(org-defkey org-mode-map "\C-c\C-x\C-r" 'org-clock-report)
(org-defkey org-mode-map "\C-c\C-x\C-u" 'org-dblock-update)