Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2015-09-01 10:32:26 +02:00
commit 410ea62fc8
1 changed files with 21 additions and 16 deletions

View File

@ -556,6 +556,13 @@ of a different task.")
(mapc (lambda (m) (org-check-and-save-marker m beg end)) (mapc (lambda (m) (org-check-and-save-marker m beg end))
org-clock-history)) org-clock-history))
(defun org-clock-drawer-name ()
"Return clock drawer's name for current entry, or nil."
(let ((drawer (org-clock-into-drawer)))
(cond ((integerp drawer) (org-log-into-drawer))
((stringp drawer) drawer)
(t nil))))
(defun org-clocking-buffer () (defun org-clocking-buffer ()
"Return the clocking buffer if we are currently clocking a task or nil." "Return the clocking buffer if we are currently clocking a task or nil."
(marker-buffer org-clock-marker)) (marker-buffer org-clock-marker))
@ -1451,10 +1458,7 @@ line and position cursor in that line."
(let* ((beg (line-beginning-position 2)) (let* ((beg (line-beginning-position 2))
(end (save-excursion (outline-next-heading) (point))) (end (save-excursion (outline-next-heading) (point)))
(org-clock-into-drawer (org-clock-into-drawer)) (org-clock-into-drawer (org-clock-into-drawer))
(drawer (cond (drawer (org-clock-drawer-name)))
((not org-clock-into-drawer) nil)
((stringp org-clock-into-drawer) org-clock-into-drawer)
(t "LOGBOOK"))))
;; Look for a running clock if FIND-UNCLOSED in non-nil. ;; Look for a running clock if FIND-UNCLOSED in non-nil.
(when find-unclosed (when find-unclosed
(let ((open-clock-re (let ((open-clock-re
@ -1646,18 +1650,19 @@ to, overriding the existing value of `org-clock-out-switch-to-state'."
(add-hook 'org-clock-out-hook 'org-clock-remove-empty-clock-drawer) (add-hook 'org-clock-out-hook 'org-clock-remove-empty-clock-drawer)
(defun org-clock-remove-empty-clock-drawer nil (defun org-clock-remove-empty-clock-drawer ()
"Remove empty clock drawer in the current subtree." "Remove empty clock drawers in current subtree."
(let ((clock-drawer (org-log-into-drawer)) (save-excursion
(end (save-excursion (org-end-of-subtree t t)))) (org-back-to-heading t)
(when clock-drawer (org-map-tree
(save-excursion (lambda ()
(org-back-to-heading t) (let ((drawer (org-clock-drawer-name))
(while (and (< (point) end) (case-fold-search t))
(search-forward clock-drawer end t)) (when drawer
(goto-char (match-beginning 0)) (let ((re (format "^[ \t]*:%s:[ \t]*$" (regexp-quote drawer)))
(org-remove-empty-drawer-at (point)) (end (save-excursion (outline-next-heading))))
(forward-line 1)))))) (while (re-search-forward re end t)
(org-remove-empty-drawer-at (point))))))))))
(defun org-clock-timestamps-up (&optional n) (defun org-clock-timestamps-up (&optional n)
"Increase CLOCK timestamps at cursor. "Increase CLOCK timestamps at cursor.