Merge branch 'maint'
This commit is contained in:
commit
b687cf37a5
|
@ -564,7 +564,9 @@ of a different task.")
|
|||
(defun org-clock-drawer-name ()
|
||||
"Return clock drawer's name for current entry, or nil."
|
||||
(let ((drawer (org-clock-into-drawer)))
|
||||
(cond ((integerp drawer) (or (org-log-into-drawer) "LOGBOOK"))
|
||||
(cond ((integerp drawer)
|
||||
(let ((log-drawer (org-log-into-drawer)))
|
||||
(if (stringp log-drawer) log-drawer "LOGBOOK")))
|
||||
((stringp drawer) drawer)
|
||||
(t nil))))
|
||||
|
||||
|
|
|
@ -80,6 +80,189 @@ contents. The clocktable doesn't appear in the buffer."
|
|||
;; Remove clocktable.
|
||||
(delete-region (point) (search-forward "#+END:\n"))))
|
||||
|
||||
|
||||
;;; Clock drawer
|
||||
|
||||
(ert-deftest test-org-clock/into-drawer ()
|
||||
"Test `org-clock-into-drawer' specifications."
|
||||
;; When `org-clock-into-drawer' is nil, do not use a clock drawer.
|
||||
(should-not
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer nil)
|
||||
(org-log-into-drawer nil))
|
||||
(org-clock-into-drawer))))
|
||||
(should-not
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer nil)
|
||||
(org-log-into-drawer t))
|
||||
(org-clock-into-drawer))))
|
||||
(should-not
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer nil)
|
||||
(org-log-into-drawer "BAR"))
|
||||
(org-clock-into-drawer))))
|
||||
;; When `org-clock-into-drawer' is a string, use it
|
||||
;; unconditionally.
|
||||
(should
|
||||
(equal "FOO"
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer "FOO")
|
||||
(org-log-into-drawer nil))
|
||||
(org-clock-into-drawer)))))
|
||||
(should
|
||||
(equal "FOO"
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer "FOO")
|
||||
(org-log-into-drawer t))
|
||||
(org-clock-into-drawer)))))
|
||||
(should
|
||||
(equal "FOO"
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer "FOO")
|
||||
(org-log-into-drawer "BAR"))
|
||||
(org-clock-into-drawer)))))
|
||||
;; When `org-clock-into-drawer' is an integer, return it.
|
||||
(should
|
||||
(= 1
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer 1)
|
||||
(org-log-into-drawer nil))
|
||||
(org-clock-into-drawer)))))
|
||||
(should
|
||||
(= 1
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer 1)
|
||||
(org-log-into-drawer t))
|
||||
(org-clock-into-drawer)))))
|
||||
(should
|
||||
(= 1
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer 1)
|
||||
(org-log-into-drawer "BAR"))
|
||||
(org-clock-into-drawer)))))
|
||||
;; Otherwise, any non-nil value defaults to `org-log-into-drawer' or
|
||||
;; "LOGBOOK" if it is nil.
|
||||
(should
|
||||
(equal "LOGBOOK"
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer t)
|
||||
(org-log-into-drawer nil))
|
||||
(org-clock-into-drawer)))))
|
||||
(should
|
||||
(equal "LOGBOOK"
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer t)
|
||||
(org-log-into-drawer t))
|
||||
(org-clock-into-drawer)))))
|
||||
(should
|
||||
(equal "FOO"
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer t)
|
||||
(org-log-into-drawer "FOO"))
|
||||
(org-clock-into-drawer)))))
|
||||
;; A non-nil "CLOCK_INTO_DRAWER" property overrides
|
||||
;; `org-clock-into-drawer' value.
|
||||
(should
|
||||
(equal "LOGBOOK"
|
||||
(org-test-with-temp-text
|
||||
"* H\n:PROPERTIES:\n:CLOCK_INTO_DRAWER: t\n:END:"
|
||||
(let ((org-clock-into-drawer nil)
|
||||
(org-log-into-drawer nil))
|
||||
(org-clock-into-drawer)))))
|
||||
(should
|
||||
(equal "FOO"
|
||||
(org-test-with-temp-text
|
||||
"* H\n:PROPERTIES:\n:CLOCK_INTO_DRAWER: FOO\n:END:"
|
||||
(let ((org-clock-into-drawer nil)
|
||||
(org-log-into-drawer nil))
|
||||
(org-clock-into-drawer)))))
|
||||
(should-not
|
||||
(org-test-with-temp-text
|
||||
"* H\n:PROPERTIES:\n:CLOCK_INTO_DRAWER: nil\n:END:"
|
||||
(let ((org-clock-into-drawer t)
|
||||
(org-log-into-drawer nil))
|
||||
(org-clock-into-drawer))))
|
||||
;; "CLOCK_INTO_DRAWER" can be inherited.
|
||||
(should
|
||||
(equal "LOGBOOK"
|
||||
(org-test-with-temp-text
|
||||
"* H\n:PROPERTIES:\n:CLOCK_INTO_DRAWER: t\n:END:\n** H2<point>"
|
||||
(let ((org-clock-into-drawer nil)
|
||||
(org-log-into-drawer nil))
|
||||
(org-clock-into-drawer)))))
|
||||
(should
|
||||
(equal "FOO"
|
||||
(org-test-with-temp-text
|
||||
"* H\n:PROPERTIES:\n:CLOCK_INTO_DRAWER: FOO\n:END:\n** H2<point>"
|
||||
(let ((org-clock-into-drawer nil)
|
||||
(org-log-into-drawer nil))
|
||||
(org-clock-into-drawer)))))
|
||||
(should-not
|
||||
(org-test-with-temp-text
|
||||
"* H\n:PROPERTIES:\n:CLOCK_INTO_DRAWER: nil\n:END:\n** H2<point>"
|
||||
(let ((org-clock-into-drawer t)
|
||||
(org-log-into-drawer nil))
|
||||
(org-clock-into-drawer)))))
|
||||
|
||||
(ert-deftest test-org-clock/drawer-name ()
|
||||
"Test `org-clock-drawer-name' specifications."
|
||||
;; A nil value for `org-clock-into-drawer' means no drawer is
|
||||
;; expected whatsoever.
|
||||
(should-not
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer nil)
|
||||
(org-log-into-drawer nil))
|
||||
(org-clock-drawer-name))))
|
||||
(should-not
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer nil)
|
||||
(org-log-into-drawer t))
|
||||
(org-clock-drawer-name))))
|
||||
(should-not
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer nil)
|
||||
(org-log-into-drawer "FOO"))
|
||||
(org-clock-drawer-name))))
|
||||
;; A string value for `org-clock-into-drawer' means to use it
|
||||
;; unconditionally.
|
||||
(should
|
||||
(equal "FOO"
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer "FOO")
|
||||
(org-log-into-drawer nil))
|
||||
(org-clock-drawer-name)))))
|
||||
(should
|
||||
(equal "FOO"
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer "FOO")
|
||||
(org-log-into-drawer t))
|
||||
(org-clock-drawer-name)))))
|
||||
(should
|
||||
(equal "FOO"
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer "FOO")
|
||||
(org-log-into-drawer "BAR"))
|
||||
(org-clock-drawer-name)))))
|
||||
;; When the value in `org-clock-into-drawer' is a number, re-use
|
||||
;; `org-log-into-drawer' or use default "LOGBOOK" value.
|
||||
(should
|
||||
(equal "FOO"
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer 1)
|
||||
(org-log-into-drawer "FOO"))
|
||||
(org-clock-drawer-name)))))
|
||||
(should
|
||||
(equal "LOGBOOK"
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer 1)
|
||||
(org-log-into-drawer t))
|
||||
(org-clock-drawer-name)))))
|
||||
(should
|
||||
(equal "LOGBOOK"
|
||||
(org-test-with-temp-text "* H"
|
||||
(let ((org-clock-into-drawer 1)
|
||||
(org-log-into-drawer nil))
|
||||
(org-clock-drawer-name))))))
|
||||
|
||||
|
||||
;;; Clocktable
|
||||
|
|
Loading…
Reference in New Issue