summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init.el3
-rw-r--r--modules/linear-config.el24
-rw-r--r--tests/test-linear-config.el23
3 files changed, 45 insertions, 5 deletions
diff --git a/init.el b/init.el
index 19d8e269..b910e75c 100644
--- a/init.el
+++ b/init.el
@@ -71,7 +71,8 @@
(require 'diff-config) ;; diff and merge functionality w/in Emacs
(require 'erc-config) ;; seamless IRC client
(require 'slack-config) ;; slack client via emacs-slack
-(require 'linear-config) ;; Linear.app issue tracking (deepsat workspace)
+;; (require 'linear-config) ;; Linear.app issue tracking — disabled while linear-emacs is reworked; config needs rework after
+
(require 'telega-config) ;; telegram client via telega.el (TDLib in docker)
(require 'eshell-config) ;; emacs shell configuration
(require 'vterm-config) ;; vterm + F12 toggle + tmux history copy
diff --git a/modules/linear-config.el b/modules/linear-config.el
index f92c13ce..479f72e4 100644
--- a/modules/linear-config.el
+++ b/modules/linear-config.el
@@ -50,6 +50,17 @@ GPG prompt fires at most once per session and only when Linear is actually used.
Named (not a lambda) so the advice is idempotent across reloads and removable."
(cj/linear--ensure-api-key))
+(defun cj/linear--install-key-advice ()
+ "Install the lazy API-key loader on every entry point that needs the key.
+The GraphQL request funnels all real operations. `linear-emacs-check-setup'
+reads `linear-emacs-api-key' directly without making a request, so it needs the
+loader too — otherwise it reports \"not set\" on a fresh session before the key
+has ever been fetched."
+ (advice-add 'linear-emacs--graphql-request-async :before
+ #'cj/linear--ensure-key-before)
+ (advice-add 'linear-emacs-check-setup :before
+ #'cj/linear--ensure-key-before))
+
(use-package linear-emacs
:ensure nil ;; local checkout, not from an archive
:load-path "~/code/linear-emacs"
@@ -63,10 +74,15 @@ Named (not a lambda) so the advice is idempotent across reloads and removable."
linear-emacs-check-setup)
:config
(setq linear-emacs-default-team-id cj/linear-team-id)
- ;; Load the key before any GraphQL request — lazy, and it retries if the key
- ;; was added to authinfo after a first (failed) attempt this session.
- (advice-add 'linear-emacs--graphql-request-async :before
- #'cj/linear--ensure-key-before))
+ ;; Keep the synced org file inside emacs home, next to the calendar-sync
+ ;; output (gcal.org / pcal.org / dcal.org). Without this it falls back to
+ ;; `org-directory'/gtd/linear.org and silently creates a stray ~/org tree.
+ (setq linear-emacs-org-file-path
+ (expand-file-name "data/linear.org" user-emacs-directory))
+ ;; Load the key lazily before any operation that reads it — both the GraphQL
+ ;; request and the check-setup diagnostic. Retries if the key was added to
+ ;; authinfo after a first (failed) attempt this session.
+ (cj/linear--install-key-advice))
;; ------------------------------ Keybindings ----------------------------------
diff --git a/tests/test-linear-config.el b/tests/test-linear-config.el
index c3e702d8..5a6e36a8 100644
--- a/tests/test-linear-config.el
+++ b/tests/test-linear-config.el
@@ -41,6 +41,29 @@
(cj/linear--ensure-api-key)
(should-not linear-emacs-api-key))))
+(ert-deftest test-linear-install-key-advice-loads-before-check-setup ()
+ "Error-regression: `linear-emacs-check-setup' loads the key before reading it.
+The lazy loader originally only advised the GraphQL request entry point, so
+`check-setup' — which reads `linear-emacs-api-key' directly without making a
+request — falsely reported \"not set\" on a fresh session."
+ (let ((linear-emacs-api-key nil)
+ (key-at-read :unread))
+ (cl-letf (((symbol-function 'cj/auth-source-secret-value)
+ (lambda (&rest _) "lin_api_test"))
+ ((symbol-function 'linear-emacs--graphql-request-async)
+ (lambda (&rest _) nil))
+ ((symbol-function 'linear-emacs-check-setup)
+ (lambda () (setq key-at-read linear-emacs-api-key))))
+ (cj/linear--install-key-advice)
+ (unwind-protect
+ (progn
+ (linear-emacs-check-setup)
+ (should (equal key-at-read "lin_api_test")))
+ (advice-remove 'linear-emacs--graphql-request-async
+ #'cj/linear--ensure-key-before)
+ (advice-remove 'linear-emacs-check-setup
+ #'cj/linear--ensure-key-before)))))
+
(ert-deftest test-linear-keymap-bound-under-prefix ()
"Smoke: C-; L holds the linear keymap and the entry commands are bound."
(should (keymapp cj/linear-keymap))