Function: org-clock-cancel

org-clock-cancel is an autoloaded, interactive and byte-compiled function defined in org-clock.el.gz.

Signature

(org-clock-cancel)

Documentation

Cancel the running clock by removing the start timestamp.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-clock.el.gz
;;;###autoload
(defun org-clock-cancel ()
  "Cancel the running clock by removing the start timestamp."
  (interactive)
  (when (not (org-clocking-p))
    (setq global-mode-string
	  (delq 'org-mode-line-string global-mode-string))
    (org-clock-restore-frame-title-format)
    (force-mode-line-update)
    (user-error "No active clock"))
  (save-excursion    ; Do not replace this with `with-current-buffer'.
    (with-no-warnings (set-buffer (org-clocking-buffer)))
    (goto-char org-clock-marker)
    (if (looking-back (concat "^[ \t]*" org-clock-string ".*")
		      (line-beginning-position))
        (progn (delete-region (1- (line-beginning-position)) (line-end-position))
	       (org-remove-empty-drawer-at (point)))
      (message "Clock gone, cancel the timer anyway")
      (sit-for 2)))
  (move-marker org-clock-marker nil)
  (move-marker org-clock-hd-marker nil)
  (setq org-clock-current-task nil)
  (setq global-mode-string
	(delq 'org-mode-line-string global-mode-string))
  (org-clock-restore-frame-title-format)
  (force-mode-line-update)
  (message "Clock canceled")
  (run-hooks 'org-clock-cancel-hook))