diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d986d9..492319e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] ### Added 1. New commands `chronometrist-restart-task`, `chronometrist-extend-task` -2. Menu of commands available in `chronometrist` +2. Menus for `chronometrist` and `chronometrist-key-values` ### Changed 3. Display graph ranges in `chronometrist-spark` column +4. `chronometrist-tags-add` and `chronometrist-key-values-unified-prompt` now also work interactively. ## [0.8.1] - 2021-06-01 ### Changed diff --git a/elisp/chronometrist-key-values.el b/elisp/chronometrist-key-values.el index 0aa04d9..cd6e73a 100644 --- a/elisp/chronometrist-key-values.el +++ b/elisp/chronometrist-key-values.el @@ -166,6 +166,7 @@ INITIAL-INPUT is as used in `completing-read'." "Read tags from the user; add them to the last entry in `chronometrist-file'. _ARGS are ignored. This function always returns t, so it can be used in `chronometrist-before-out-functions'." + (interactive) (let* ((last-expr (chronometrist-last)) (last-name (plist-get last-expr :name)) (_history (chronometrist-tags-history-populate last-name @@ -331,6 +332,7 @@ to add them to the last s-expression in `chronometrist-file', or _ARGS are ignored. This function always returns t, so it can be used in `chronometrist-before-out-functions'." + (interactive) (let* ((buffer (get-buffer-create chronometrist-kv-buffer-name)) (first-key-p t) (last-sexp (chronometrist-last)) @@ -391,9 +393,17 @@ used in `chronometrist-before-out-functions'." (kill-buffer chronometrist-kv-buffer-name) (chronometrist-refresh)) -(defun chronometrist-key-values-unified-prompt (task) +(easy-menu-define chronometrist-key-value-menu chronometrist-mode-map + "Key value menu for Chronometrist mode." + '("Key-Values" + ["Add tags to active/last interval" chronometrist-tags-add] + ["Add key-values to active/last interval" chronometrist-kv-add] + ["Add tags and key-values to active/last interval" chronometrist-key-values-unified-prompt])) + +(cl-defun chronometrist-key-values-unified-prompt (&optional (task (plist-get (chronometrist-sexp-last) :name))) "Query user for tags and key-values to be added for TASK. Return t, to permit use in `chronometrist-before-out-functions'." + (interactive) (let ((key-values (chronometrist-loop-file for plist in chronometrist-file when (equal (plist-get plist :name) task) collect diff --git a/elisp/chronometrist-key-values.org b/elisp/chronometrist-key-values.org index e1c2500..8ebbd24 100644 --- a/elisp/chronometrist-key-values.org +++ b/elisp/chronometrist-key-values.org @@ -300,6 +300,7 @@ INITIAL-INPUT is as used in `completing-read'." "Read tags from the user; add them to the last entry in `chronometrist-file'. _ARGS are ignored. This function always returns t, so it can be used in `chronometrist-before-out-functions'." + (interactive) (let* ((last-expr (chronometrist-last)) (last-name (plist-get last-expr :name)) (_history (chronometrist-tags-history-populate last-name @@ -524,6 +525,7 @@ to add them to the last s-expression in `chronometrist-file', or _ARGS are ignored. This function always returns t, so it can be used in `chronometrist-before-out-functions'." + (interactive) (let* ((buffer (get-buffer-create chronometrist-kv-buffer-name)) (first-key-p t) (last-sexp (chronometrist-last)) @@ -588,6 +590,15 @@ used in `chronometrist-before-out-functions'." (kill-buffer chronometrist-kv-buffer-name) (chronometrist-refresh)) #+END_SRC +*** chronometrist-key-value-menu :menu: +#+BEGIN_SRC emacs-lisp +(easy-menu-define chronometrist-key-value-menu chronometrist-mode-map + "Key value menu for Chronometrist mode." + '("Key-Values" + ["Add tags to active/last interval" chronometrist-tags-add] + ["Add key-values to active/last interval" chronometrist-kv-add] + ["Add tags and key-values to active/last interval" chronometrist-key-values-unified-prompt])) +#+END_SRC ** WIP Single-key prompts [0%] This was initially implemented using Hydra. But, at the moment of reckoning, it turned out that Hydra does not pause Emacs until the user provides an input, and is thus unsuited for use in a hook. Thus, we created a new library called =choice.el= which functions similarly to Hydra (associations of keys, Lisp forms, and hints are passed to a macro which emits a prompt function) and used that. @@ -685,9 +696,10 @@ Return t, to permit use in `chronometrist-before-out-functions'." *** WIP unified-prompt :hook:writer: 1. [ ] Improve appearance - is there an easy way to syntax highlight the plists? #+BEGIN_SRC emacs-lisp -(defun chronometrist-key-values-unified-prompt (task) +(cl-defun chronometrist-key-values-unified-prompt (&optional (task (plist-get (chronometrist-sexp-last) :name))) "Query user for tags and key-values to be added for TASK. Return t, to permit use in `chronometrist-before-out-functions'." + (interactive) (let ((key-values (chronometrist-loop-file for plist in chronometrist-file when (equal (plist-get plist :name) task) collect