aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-25 01:25:43 -0500
committerCraig Jennings <c@cjennings.net>2026-05-25 01:25:43 -0500
commit619d4ce0294ff318a96e2f82a8f9401111bb619d (patch)
tree09afcbe17151ed3dda5a2043fd6625264611146c /tests
parent56511a51afc66bc7efebee657bf040624defde65 (diff)
downloadpearl-619d4ce0294ff318a96e2f82a8f9401111bb619d.tar.gz
pearl-619d4ce0294ff318a96e2f82a8f9401111bb619d.zip
feat: add the pearl-prefix-map keymap and regroup the transient menu
The command surface had no muscle-memory path. Everything went through M-x or the transient, and the transient grouped commands by an ad-hoc mix (issue-at-point, create, org-sync) rather than by what you're doing. I added pearl-prefix-map, an opt-in prefix keymap organized as save / edit / new / delete. It isn't bound at load, because a global multi-key prefix isn't reliably free across terminals and GUIs. Each binding is a (label . command) menu item, so which-key shows the label without pearl depending on which-key. The user binds the map to a free prefix (the README suggests C-; L). So C-; L s s saves the ticket at point, s a saves the whole file, e p edits priority, n t creates a ticket, m opens the transient. I regrouped the transient to mirror those categories: Save, Edit, New, Delete for ticket actions, and Fetch, View, Setup for the workspace. I added the two save commands and relabeled every entry to the verb wording. The per-field push entries (edit-desc, edit-title) are gone since the save model subsumes them, though the commands still work from M-x. I pulled the org-sync commands (enable, disable, push-file) from the menu too, since they're plumbing, tracked separately for going private. The keymap binds the existing command names. Aligning those names with the labels (edit-state, new-comment) is a separate task, as is the delete-comment command that will fill the d c slot.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-pearl-keymap.el94
-rw-r--r--tests/test-pearl-menu.el3
2 files changed, 96 insertions, 1 deletions
diff --git a/tests/test-pearl-keymap.el b/tests/test-pearl-keymap.el
new file mode 100644
index 0000000..97d8440
--- /dev/null
+++ b/tests/test-pearl-keymap.el
@@ -0,0 +1,94 @@
+;;; test-pearl-keymap.el --- Tests for the opt-in prefix keymap -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2026 Craig Jennings
+
+;; Author: Craig Jennings <c@cjennings.net>
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Tests for `pearl-prefix-map' (see docs/ticket-save-model-spec.org, the
+;; keybinding section): the opt-in prefix keymap that organizes the commands
+;; under save / edit / new / delete sub-maps with which-key labels. The map is
+;; defined but never bound at load -- the user binds it to a free prefix.
+
+;;; Code:
+
+(require 'test-bootstrap (expand-file-name "test-bootstrap.el"))
+
+(defun test-pearl-keymap--label-of (map command)
+ "Return the menu-item label bound to COMMAND in MAP, or nil.
+Walks MAP looking for a labeled binding (\"label\" . COMMAND)."
+ (let (found)
+ (map-keymap
+ (lambda (_ev binding)
+ (when (and (consp binding) (stringp (car binding))
+ (eq (cdr binding) command))
+ (setq found (car binding))))
+ map)
+ found))
+
+(ert-deftest test-pearl-prefix-map-is-a-keymap ()
+ "`pearl-prefix-map' is defined as a keymap."
+ (should (keymapp pearl-prefix-map)))
+
+(ert-deftest test-pearl-prefix-map-resolves-leaf-commands ()
+ "Each chord resolves to its command (existing names, not yet renamed)."
+ (should (eq 'pearl-save-issue (lookup-key pearl-prefix-map (kbd "s s"))))
+ (should (eq 'pearl-save-all (lookup-key pearl-prefix-map (kbd "s a"))))
+ (should (eq 'pearl-compose-current-description (lookup-key pearl-prefix-map (kbd "e d"))))
+ (should (eq 'pearl-edit-current-comment (lookup-key pearl-prefix-map (kbd "e c"))))
+ (should (eq 'pearl-set-priority (lookup-key pearl-prefix-map (kbd "e p"))))
+ (should (eq 'pearl-set-state (lookup-key pearl-prefix-map (kbd "e s"))))
+ (should (eq 'pearl-set-assignee (lookup-key pearl-prefix-map (kbd "e a"))))
+ (should (eq 'pearl-set-labels (lookup-key pearl-prefix-map (kbd "e l"))))
+ (should (eq 'pearl-new-issue (lookup-key pearl-prefix-map (kbd "n t"))))
+ (should (eq 'pearl-add-comment (lookup-key pearl-prefix-map (kbd "n c"))))
+ (should (eq 'pearl-delete-current-issue (lookup-key pearl-prefix-map (kbd "d t"))))
+ (should (eq 'pearl-menu (lookup-key pearl-prefix-map (kbd "m")))))
+
+(ert-deftest test-pearl-prefix-map-sub-prefixes-are-keymaps ()
+ "The category keys are sub-prefixes, not commands."
+ (should (keymapp (lookup-key pearl-prefix-map (kbd "s"))))
+ (should (keymapp (lookup-key pearl-prefix-map (kbd "e"))))
+ (should (keymapp (lookup-key pearl-prefix-map (kbd "n"))))
+ (should (keymapp (lookup-key pearl-prefix-map (kbd "d")))))
+
+(ert-deftest test-pearl-prefix-map-no-delete-comment-yet ()
+ "Delete-comment is not bound -- the command is a separate task."
+ (should-not (commandp (lookup-key pearl-prefix-map (kbd "d c")))))
+
+(ert-deftest test-pearl-prefix-map-not-bound-at-load ()
+ "Loading pearl does not bind the commands to any active key (opt-in)."
+ (should-not (where-is-internal 'pearl-save-issue))
+ (should-not (where-is-internal 'pearl-save-all)))
+
+(ert-deftest test-pearl-prefix-map-which-key-labels ()
+ "Leaf bindings carry the edit/new verb labels; sub-prefixes carry +labels."
+ (should (string= "edit priority"
+ (test-pearl-keymap--label-of pearl-edit-map 'pearl-set-priority)))
+ (should (string= "edit description"
+ (test-pearl-keymap--label-of pearl-edit-map 'pearl-compose-current-description)))
+ (should (string= "new ticket"
+ (test-pearl-keymap--label-of pearl-new-map 'pearl-new-issue)))
+ (should (string= "new comment"
+ (test-pearl-keymap--label-of pearl-new-map 'pearl-add-comment)))
+ (should (string= "save ticket"
+ (test-pearl-keymap--label-of pearl-save-map 'pearl-save-issue)))
+ ;; sub-prefix label on the base map
+ (should (string= "+edit" (test-pearl-keymap--label-of pearl-prefix-map pearl-edit-map))))
+
+(provide 'test-pearl-keymap)
+;;; test-pearl-keymap.el ends here
diff --git a/tests/test-pearl-menu.el b/tests/test-pearl-menu.el
index 1362b2e..8af4bb8 100644
--- a/tests/test-pearl-menu.el
+++ b/tests/test-pearl-menu.el
@@ -62,7 +62,8 @@ menu entry that still points at it fails here."
(dolist (expected '(pearl-list-issues
pearl-run-view
pearl-run-saved-query
- pearl-sync-current-issue
+ pearl-save-issue
+ pearl-save-all
pearl-set-state
pearl-add-comment
pearl-new-issue