From 6206fde5acfd48f9eba2ab231c1fe1d32717c98e Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 1 Jun 2026 17:46:34 -0500 Subject: feat(views): add create and edit local views with a metadata-preserving writer I added pearl-create-local-view and pearl-edit-local-view, plus the writer and guards the spec calls for. pearl--save-local-view replaces the old rebuild-from-scratch writer. It copies an existing entry and updates only the filter, sort, and order, so a published view keeps its :linear-view-* tracking link and a copied-down view keeps its provenance. A new entry gets the active account stamped under pearl-accounts. pearl--require-local-view-account is the one guard every read or mutate command shares, and pearl-run-local-view now calls it instead of an inline check. pearl--resolve-local-view-name carries the Replace/Rename/Cancel collision policy for create, edit-rename, and copy-down. The ad-hoc builder's save offer routes through the preserving writer and reads "save this as a local view". Edit re-runs the builder when you choose to rebuild and otherwise keeps the stored filter. Full per-dimension pre-seeding of the builder is deferred, since it needs the id-to-name reverse resolution that copy-down's reverse-compile introduces. I filed it as a follow-up. Phase 2 of the views spec. Tests cover metadata preservation, the account guard, the collision policy, and the metadata-preserving rename. Suite, compile, and lint are green. --- tests/test-pearl-adhoc.el | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/test-pearl-adhoc.el') diff --git a/tests/test-pearl-adhoc.el b/tests/test-pearl-adhoc.el index 4959840..68a920c 100644 --- a/tests/test-pearl-adhoc.el +++ b/tests/test-pearl-adhoc.el @@ -155,22 +155,22 @@ candidate list, so completion still works the way the framework expects." (should (string= "user-1" (plist-get f :assignee-id))) (should-not (plist-member f :assignee)))) -;;; --save-query +;;; --save-local-view -(ert-deftest test-pearl-save-query-adds-entry () - "Saving a query adds it to the saved-queries variable." +(ert-deftest test-pearl-save-local-view-adds-entry () + "Saving a local view adds it to `pearl-local-views'." (let ((pearl-local-views nil)) (cl-letf (((symbol-function 'customize-save-variable) (lambda (&rest _) nil))) - (pearl--save-query "My filter" '(:open t :labels ("bug"))) + (pearl--save-local-view "My filter" '(:open t :labels ("bug"))) (let ((entry (assoc "My filter" pearl-local-views))) (should entry) (should (equal '(:open t :labels ("bug")) (plist-get (cdr entry) :filter))))))) -(ert-deftest test-pearl-save-query-replaces-same-name () - "Saving under an existing name replaces that entry rather than duplicating." +(ert-deftest test-pearl-save-local-view-replaces-same-name () + "Saving under an existing name updates that entry rather than duplicating." (let ((pearl-local-views '(("Dup" :filter (:open t))))) (cl-letf (((symbol-function 'customize-save-variable) (lambda (&rest _) nil))) - (pearl--save-query "Dup" '(:priority 1)) + (pearl--save-local-view "Dup" '(:priority 1)) (should (= 1 (cl-count "Dup" pearl-local-views :key #'car :test #'string=))) (should (equal '(:priority 1) -- cgit v1.2.3