Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing requires #194

Merged
merged 4 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 24 additions & 26 deletions org-gtd-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

;;;; Requirements

(require 'f)
(require 'org-agenda-property)

(require 'org-gtd-backward-compatibility)
Expand Down Expand Up @@ -160,11 +161,6 @@ See `org-todo-keywords' for definition."

;;;; Variables

(defvar org-gtd-archive-location)
(defvar org-gtd-delegate-property)
(defvar org-gtd-project-headings)
(defvar org-gtd-stuck-projects)

(defvar-local org-gtd--loading-p nil
"`Org-gtd' sets this variable after it has changed the state in this buffer.")

Expand All @@ -174,28 +170,30 @@ See `org-todo-keywords' for definition."
(defmacro with-org-gtd-context (&rest body)
"Wrap BODY... in this macro to inherit the org-gtd settings for your logic."
(declare (debug t) (indent 2))
`(let* ((org-use-property-inheritance "ORG_GTD")
(org-todo-keywords `((sequence ,(string-join `(,org-gtd-next ,org-gtd-next-suffix))
,(string-join `(,org-gtd-todo ,org-gtd-todo-suffix))
,(string-join `(,org-gtd-wait ,org-gtd-wait-suffix))
"|"
,(string-join `(,org-gtd-done ,org-gtd-done-suffix))
,(string-join `(,org-gtd-canceled ,org-gtd-canceled-suffix)))))
;; (org-log-done 'time)
;; (org-log-done-with-time t)
;; (org-log-refile 'time)
(org-archive-location (funcall org-gtd-archive-location))
;(org-refile-use-outline-path nil)
(org-stuck-projects org-gtd-stuck-projects)
(org-odd-levels-only nil)
(org-agenda-files (org-gtd-core--agenda-files))
(org-agenda-property-list `(,org-gtd-delegate-property)))
(unwind-protect
`(progn
(require 'org-gtd)
(let* ((org-use-property-inheritance "ORG_GTD")
(org-todo-keywords `((sequence ,(string-join `(,org-gtd-next ,org-gtd-next-suffix))
,(string-join `(,org-gtd-todo ,org-gtd-todo-suffix))
,(string-join `(,org-gtd-wait ,org-gtd-wait-suffix))
"|"
,(string-join `(,org-gtd-done ,org-gtd-done-suffix))
,(string-join `(,org-gtd-canceled ,org-gtd-canceled-suffix)))))
;; (org-log-done 'time)
;; (org-log-done-with-time t)
;; (org-log-refile 'time)
(org-archive-location (funcall org-gtd-archive-location))
;(org-refile-use-outline-path nil)
(org-stuck-projects org-gtd-stuck-projects)
(org-odd-levels-only nil)
(org-agenda-files (org-gtd-core--agenda-files))
(org-agenda-property-list `(,org-gtd-delegate-property)))
(unwind-protect
(progn
(advice-add 'org-agenda-files :filter-return #'org-gtd-core--uniq)
,@body)
(progn
(advice-add 'org-agenda-files :filter-return #'org-gtd-core--uniq)
,@body)
(progn
(advice-remove 'org-agenda-files #'org-gtd-core--uniq)))))
(advice-remove 'org-agenda-files #'org-gtd-core--uniq))))))

;;;; Functions

Expand Down
65 changes: 65 additions & 0 deletions test/autoload-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
(load "test/helpers/setup.el")
(require 'buttercup)
(describe
"autoloaded entry point"

(it "org-gtd-archive-completed-items"
(expect
(ogt--recursive-eldev-test
"autoload-tests/org-gtd-archive-completed-items-test.el")
:to-equal 0))

(it "org-gtd-capture"
(expect
(ogt--recursive-eldev-test
"autoload-tests/org-gtd-capture-test.el")
:to-equal 0))

(it "org-gtd-clarify-item"
(expect
(ogt--recursive-eldev-test
"autoload-tests/org-gtd-clarify-item-test.el")
:to-equal 0))

(it "org-gtd-clarify-mode"
(expect
(ogt--recursive-eldev-test
"autoload-tests/org-gtd-clarify-mode-test.el")
:to-equal 0))

(it "org-gtd-engage"
(expect
(ogt--recursive-eldev-test "autoload-tests/org-gtd-engage-test.el")
:to-equal 0))

(it "org-gtd-inbox-path"
(expect
(ogt--recursive-eldev-test
"autoload-tests/org-gtd-inbox-path-test.el")
:to-equal 0))

(it "org-gtd-mode"
(expect
(ogt--recursive-eldev-test
"autoload-tests/org-gtd-mode-test.el")
:to-equal 0))

(it "org-gtd-process-inbox"
(expect
(ogt--recursive-eldev-test
"autoload-tests/org-gtd-process-inbox-test.el")
:to-equal 0))

(it "org-gtd-review-stuck-projects"
(expect
(ogt--recursive-eldev-test
"autoload-tests/org-gtd-review-stuck-projects-test.el")
:to-equal 0))

(it "org-gtd-show-all-next"
(expect
(ogt--recursive-eldev-test
"autoload-tests/org-gtd-show-all-next-test.el")
:to-equal 0))

)
12 changes: 12 additions & 0 deletions test/autoload-tests/org-gtd-archive-completed-items-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(load "org-gtd-autoloads")
(load "test/helpers/autoload-setup.el")

(describe
"autoload management (recursive)"
(before-each (ogt--prepare-gtd-directory))
(after-each (ogt--clear-gtd-directory))

(it "org-gtd-archive-completed-items"
(org-gtd-archive-completed-items)))
12 changes: 12 additions & 0 deletions test/autoload-tests/org-gtd-capture-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(load "org-gtd-autoloads")
(load "test/helpers/autoload-setup.el")

(describe
"autoload management (recursive)"
(before-each (ogt--prepare-gtd-directory))
(after-each (ogt--clear-gtd-directory))

(it "org-gtd-capture"
(org-gtd-capture nil "i")))
15 changes: 15 additions & 0 deletions test/autoload-tests/org-gtd-clarify-item-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(load "org-gtd-autoloads")
(load "test/helpers/utils.el")
(load "test/helpers/autoload-setup.el")

(describe
"autoload management (recursive)"
(before-each (ogt--prepare-gtd-directory))
(after-each (ogt--clear-gtd-directory))

(it "org-gtd-clarify-item"
(ogt--with-temp-org-buffer
"* This is the heading to clarify"
(org-gtd-clarify-item))))
9 changes: 9 additions & 0 deletions test/autoload-tests/org-gtd-clarify-mode-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(load "org-gtd-autoloads")

(describe
"autoload management (recursive)"

(it "org-gtd-clarify-mode"
(org-gtd-clarify-mode)))
12 changes: 12 additions & 0 deletions test/autoload-tests/org-gtd-engage-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(load "org-gtd-autoloads")
(load "test/helpers/autoload-setup.el")

(describe
"autoload management (recursive)"
(before-each (ogt--prepare-gtd-directory))
(after-each (ogt--clear-gtd-directory))

(it "org-gtd-engage"
(org-gtd-engage)))
13 changes: 13 additions & 0 deletions test/autoload-tests/org-gtd-inbox-path-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(load "org-gtd-autoloads")

(load "test/helpers/autoload-setup.el")

(describe
"autoload management (recursive)"
(before-each (ogt--prepare-gtd-directory))
(after-each (ogt--clear-gtd-directory))

(it "org-gtd-inbox-path"
(org-gtd-inbox-path)))
8 changes: 8 additions & 0 deletions test/autoload-tests/org-gtd-mode-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(load "org-gtd-autoloads")

(describe
"autoload management (recursive)"
(it "org-gtd-mode"
(org-gtd-mode)))
12 changes: 12 additions & 0 deletions test/autoload-tests/org-gtd-process-inbox-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(load "org-gtd-autoloads")
(load "test/helpers/autoload-setup.el")

(describe
"autoload management (recursive)"
(before-each (ogt--prepare-gtd-directory))
(after-each (ogt--clear-gtd-directory))

(it "org-gtd-process-inbox"
(org-gtd-process-inbox)))
14 changes: 14 additions & 0 deletions test/autoload-tests/org-gtd-review-stuck-projects-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(load "org-gtd-autoloads")
(load "test/helpers/autoload-setup.el")

(describe
"autoload management (recursive)"
(before-each (ogt--prepare-gtd-directory))
(after-each (ogt--clear-gtd-directory))

(it "org-gtd-review-stuck-projects"
(org-gtd-review-stuck-projects)))


12 changes: 12 additions & 0 deletions test/autoload-tests/org-gtd-show-all-next-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(load "org-gtd-autoloads")
(load "test/helpers/autoload-setup.el")

(describe
"autoload management (recursive)"
(before-each (ogt--prepare-gtd-directory))
(after-each (ogt--clear-gtd-directory))

(it "org-gtd-show-all-next"
(org-gtd-show-all-next)))
22 changes: 22 additions & 0 deletions test/helpers/autoload-setup.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
;; NEVER put loads or requires in here. That's the point of this helper: to
;; help test things in an environment where things aren't loaded.

(defun ogt--prepare-gtd-directory ()
"Run before autoload test that needs the gtd directory to exist."
(setq org-gtd-directory (make-temp-file "org-gtd" t)))

(defmacro ogt--with-temp-org-buffer (contents &rest body)
"Like `with-temp-buffer', but in Org mode.

CONTENTS is inserted and point is set to the buffer's beginning
before running BODY."
(declare (debug t))
`(with-temp-buffer
(org-mode)
(insert ,contents)
(goto-char 1)
,@body))

(defun ogt--clear-gtd-directory ()
"Clean up after `ogt--prepare-gtd-directory'."
(delete-directory org-gtd-directory t))
14 changes: 14 additions & 0 deletions test/helpers/setup.el
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,17 @@
(with-current-buffer buffer
(revert-buffer t t)))
(kill-buffer buffer))

(defun ogt--recursive-eldev-test (file)
(unless (file-readable-p (file-name-concat "test" file))
(error "Cannot find or read file %s" file))
(with-temp-buffer
(prog1 (call-process
eldev-shell-command
nil
t
nil
"test"
"-f"
file)
(princ (buffer-substring 1 (point-max))))))