From 85a1395efadfd70e7eb90190985bd404b3bb35dc Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 19 Feb 2013 12:59:46 +0100 Subject: [PATCH] org-clock.el: Minor code clean-up * org-clock.el (org-clock-set-current) (org-clock-delete-current): Delete. (org-clock-in, org-clock-out): Set and delete `org-clock-current-task'. Minor code clean-up. --- lisp/org-clock.el | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 2c561472f..3ac345b7f 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -1093,16 +1093,7 @@ so long." 60.0)))) org-clock-user-idle-start))))) -(defvar org-clock-current-task nil - "Task currently clocked in.") -(defun org-clock-set-current () - "Set `org-clock-current-task' to the task currently clocked in." - (setq org-clock-current-task (nth 4 (org-heading-components)))) - -(defun org-clock-delete-current () - "Reset `org-clock-current-task' to nil." - (setq org-clock-current-task nil)) - +(defvar org-clock-current-task nil "Task currently clocked in.") (defvar org-clock-out-time nil) ; store the time of the last clock-out ;;;###autoload @@ -1200,7 +1191,7 @@ make this the default behavior.)" ;; manually (run-hooks 'org-clock-in-prepare-hook) (org-clock-history-push)) - (org-clock-set-current) + (setq org-clock-current-task (nth 4 (org-heading-components))) (cond ((functionp org-clock-in-switch-to-state) (looking-at org-complex-heading-regexp) (let ((newstate (funcall org-clock-in-switch-to-state @@ -1220,14 +1211,11 @@ make this the default behavior.)" (cond ((and org-clock-heading-function (functionp org-clock-heading-function)) (funcall org-clock-heading-function)) - ((and (looking-at org-complex-heading-regexp) - (match-string 4)) + ((nth 4 (org-heading-components)) (replace-regexp-in-string "\\[\\[.*?\\]\\[\\(.*?\\)\\]\\]" "\\1" - (match-string 4))) + (match-string-no-properties 4))) (t "???"))) - (setq org-clock-heading (org-propertize org-clock-heading - 'face nil)) (org-clock-find-position org-clock-in-resume) (cond ((and org-clock-in-resume @@ -1566,7 +1554,7 @@ to, overriding the existing value of `org-clock-out-switch-to-state'." te (if remove " => LINE REMOVED" "")) (run-hooks 'org-clock-out-hook) (unless (org-clocking-p) - (org-clock-delete-current))))))) + (setq org-clock-current-task nil))))))) (add-hook 'org-clock-out-hook 'org-clock-remove-empty-clock-drawer) @@ -2799,9 +2787,7 @@ The details of what will be saved are regulated by the variable (buffer-file-name b) (or (not org-clock-persist-query-save) (y-or-n-p (concat "Save current clock (" - (substring-no-properties - org-clock-heading) - ") ")))) + org-clock-heading ") ")))) (insert "(setq resume-clock '(\"" (buffer-file-name (org-clocking-buffer)) "\" . " (int-to-string (marker-position org-clock-marker)) -- 2.11.4.GIT