diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-28 01:11:22 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-28 01:11:22 -0500 |
| commit | b34909973bcf9f0fed940cab5e3192e54708ad7f (patch) | |
| tree | c5a8714fbd7e22d41e4e88199b08140c2bcc5df0 /pearl.el | |
| parent | b75e6ecc1eb0bc16ffd7f8ca6c8a42229419c8d6 (diff) | |
| download | pearl-b34909973bcf9f0fed940cab5e3192e54708ad7f.tar.gz pearl-b34909973bcf9f0fed940cab5e3192e54708ad7f.zip | |
feat(saved): add pearl-delete-saved-query and a sentinel cancel for run
`pearl-saved-queries' was write-only from a user's perspective. Save was bound to the builder, run was bound to a key, but removing a stale entry meant `M-x customize-variable RET pearl-saved-queries RET` and a manual delete from the Customize buffer. `pearl-delete-saved-query` under `C-; L k q` (and `q` in the transient's Delete group) closes that gap: completes over the saved query names with `[ None. ]` at the top as a cancel, confirms, removes the entry, and persists via `customize-save-variable`. Linear is untouched. Saved queries are local. Pushing them up to Linear as custom views is a separate spec.
While in the same path, `pearl-run-saved-query` got the same sentinel cancel. Both prompts use the keep-order completion table so `[ None. ]` stays at the top regardless of the user's completion sorter. Both error cleanly when `pearl-saved-queries` is empty rather than offering an empty picker. Six tests cover the new command (delete-on-yes, no-at-confirm, sentinel-cancels, unknown-name-errors, empty-list-errors) plus run's sentinel cancel.
Diffstat (limited to 'pearl.el')
| -rw-r--r-- | pearl.el | 42 |
1 files changed, 39 insertions, 3 deletions
@@ -3212,8 +3212,15 @@ Interactively, completes over the configured query names. Compiles the stored filter, fetches, sorts per the query's `:sort'/`:order', and renders into the active file with the query recorded as the source." (interactive - (list (completing-read "Saved query: " - (mapcar #'car pearl-saved-queries) nil t))) + (list (if (null pearl-saved-queries) + (user-error "No saved queries configured") + (completing-read + "Saved query: " + (pearl--completion-table-keep-order + (pearl--with-none (mapcar #'car pearl-saved-queries))) + nil t)))) + (when (pearl--filter-none-value-p name) + (user-error "Cancelled; no saved query run")) (let ((entry (assoc name pearl-saved-queries))) (unless entry (user-error "No saved query named %s" name)) @@ -3447,6 +3454,33 @@ choice; selecting it drops that dimension. The assignee prompt offers `me' :test #'string=)))) open state project labels assignee))) +;;;###autoload +(defun pearl-delete-saved-query (name) + "Delete the saved query NAME from `pearl-saved-queries' after confirmation. +Interactively, completes over the configured query names with +`pearl--filter-none' at the top as a cancel. Local-only: removes the entry +from the customized list and persists via `customize-save-variable'. Linear +is untouched (saved queries are local; syncing them up is a separate spec)." + (interactive + (list (if (null pearl-saved-queries) + (user-error "No saved queries to delete") + (completing-read + "Delete saved query: " + (pearl--completion-table-keep-order + (pearl--with-none (mapcar #'car pearl-saved-queries))) + nil t)))) + (cond + ((pearl--filter-none-value-p name) + (message "Cancelled; no saved query deleted")) + ((not (assoc name pearl-saved-queries)) + (user-error "No saved query named %s" name)) + ((yes-or-no-p (format "Delete saved query %s? " name)) + (setq pearl-saved-queries + (cl-remove name pearl-saved-queries :key #'car :test #'string=)) + (customize-save-variable 'pearl-saved-queries pearl-saved-queries) + (message "Deleted saved query %s" name)) + (t (message "Kept saved query %s" name)))) + (defun pearl--save-query (name filter-plist &optional sort order) "Save FILTER-PLIST as the saved query NAME, replacing any entry of that NAME. Persists `pearl-saved-queries' via Customize. SORT and ORDER are @@ -5153,7 +5187,8 @@ body stay." ("c" "create comment" pearl-create-comment)] ["Delete" ("k" "delete issue" pearl-delete-current-issue) - ("K" "delete comment" pearl-delete-current-comment)]] + ("K" "delete comment" pearl-delete-current-comment) + ("q" "delete saved query" pearl-delete-saved-query)]] ["Workspace" ["Fetch" ("P" "pick source" pearl-pick-source) @@ -5227,6 +5262,7 @@ body stay." (let ((map (make-sparse-keymap))) (define-key map "t" (cons "delete issue" #'pearl-delete-current-issue)) (define-key map "c" (cons "delete comment" #'pearl-delete-current-comment)) + (define-key map "q" (cons "delete saved query" #'pearl-delete-saved-query)) map) "Pearl delete commands; a sub-keymap of `pearl-prefix-map'.") |
