anonimitoraf / exercism.el

Emacs integration for https://exercism.org
GNU General Public License v3.0
32 stars 2 forks source link

Error with transient: "No key for ," #2

Closed bertulli closed 1 year ago

bertulli commented 1 year ago

Hi!

I've installed the package via package.el. If I call M-x exercism, the minibuffer shows No key for ,, and the *Messages* buffer the slightly more informative transient-setup: No key for , message. Setting debug-on-error to t, I see the following backtrace:

Debugger entered--Lisp error: (error "No key for ,")
  transient--exit-and-debug(error (error "No key for ,"))
  error("No key for %s" \,)
  #f(compiled-function (obj) #<bytecode 0x16f079a71feb4398>)(#<transient-suffix transient-suffix-1567496b1c9e>)
  apply(#f(compiled-function (obj) #<bytecode 0x16f079a71feb4398>) #<transient-suffix transient-suffix-1567496b1c9e> nil)
  transient--init-suffix-key(#<transient-suffix transient-suffix-1567496b1c9e>)
  transient--init-suffix(nil (1 transient-suffix (:command \,)))
  transient--init-child(nil (1 transient-suffix (:command \,)))
  #f(compiled-function (c) #<bytecode -0x142f4552386c748e>)((1 transient-suffix (:command \,)))
  cl-mapcan(#f(compiled-function (c) #<bytecode -0x142f4552386c748e>) ((1 transient-suffix (:command \,)) (1 transient-suffix (:key "c" :description "Configure" :command exercism-configure)) (1 transient-suffix (:key "t" :description "Set current track" :command exercism-set-track)) (1 transient-suffix (:key "o" :description "Open an exercise" :command exercism-open-exercise)) (1 transient-suffix (:key "s" :description "Submit" :command exercism-submit)) (1 transient-suffix (:key "S" :description "Submit (then open in browser)" :command exercism-submit-then-open-in-browser))))
  transient--init-group(nil [1 transient-column nil ((1 transient-suffix (:command \,)) (1 transient-suffix (:key "c" :description "Configure" :command exercism-configure)) (1 transient-suffix (:key "t" :description "Set current track" :command exercism-set-track)) (1 transient-suffix (:key "o" :description "Open an exercise" :command exercism-open-exercise)) (1 transient-suffix (:key "s" :description "Submit" :command exercism-submit)) (1 transient-suffix (:key "S" :description "Submit (then open in browser)" :command exercism-submit-then-open-in-browser)))])
  transient--init-child(nil [1 transient-column nil ((1 transient-suffix (:command \,)) (1 transient-suffix (:key "c" :description "Configure" :command exercism-configure)) (1 transient-suffix (:key "t" :description "Set current track" :command exercism-set-track)) (1 transient-suffix (:key "o" :description "Open an exercise" :command exercism-open-exercise)) (1 transient-suffix (:key "s" :description "Submit" :command exercism-submit)) (1 transient-suffix (:key "S" :description "Submit (then open in browser)" :command exercism-submit-then-open-in-browser)))])
  #f(compiled-function (c) #<bytecode -0x142f4552386c748e>)([1 transient-column nil ((1 transient-suffix (:command \,)) (1 transient-suffix (:key "c" :description "Configure" :command exercism-configure)) (1 transient-suffix (:key "t" :description "Set current track" :command exercism-set-track)) (1 transient-suffix (:key "o" :description "Open an exercise" :command exercism-open-exercise)) (1 transient-suffix (:key "s" :description "Submit" :command exercism-submit)) (1 transient-suffix (:key "S" :description "Submit (then open in browser)" :command exercism-submit-then-open-in-browser)))])
  cl-mapcan(#f(compiled-function (c) #<bytecode -0x142f4552386c748e>) ([1 transient-column nil ((1 transient-suffix (:command \,)) (1 transient-suffix (:key "c" :description "Configure" :command exercism-configure)) (1 transient-suffix (:key "t" :description "Set current track" :command exercism-set-track)) (1 transient-suffix (:key "o" :description "Open an exercise" :command exercism-open-exercise)) (1 transient-suffix (:key "s" :description "Submit" :command exercism-submit)) (1 transient-suffix (:key "S" :description "Submit (then open in browser)" :command exercism-submit-then-open-in-browser)))] [1 transient-columns (:hide #f(compiled-function () #<bytecode 0x173d57d0d29f3402>)) ([1 transient-column (:description "Value commands") ((1 transient-suffix (:key "C-x s  " :description "Set" :command transient-set)) (1 transient-suffix (:key "C-x C-s" :description "Save" :command transient-save)) (1 transient-suffix (:key "C-x C-k" :description "Reset" :command transient-reset)) (1 transient-suffix (:key "C-x p  " :description "Previous value" :command transient-history-prev)) (1 transient-suffix (:key "C-x n  " :description "Next value" :command transient-history-next)))] [1 transient-column (:description "Sticky commands") ((1 transient-suffix (:key "C-g" :description "Quit prefix or transient" :command transient-quit-one)) (1 transient-suffix (:key "C-q" :description "Quit transient stack" :command transient-quit-all)) (1 transient-suffix (:key "C-z" :description "Suspend transient stack" :command transient-suspend)))] [1 transient-column (:description "Customize") ((1 transient-suffix (:key "C-x t" :command transient-toggle-common :description #f(compiled-function () #<bytecode 0x1e0d3d48bddb43b5>))) (1 transient-suffix (:key "C-x l" :description "Show/hide suffixes" :command transient-set-level)))])]))
  transient--init-suffixes(exercism)
  transient--init-objects(exercism nil nil)
  transient-setup(exercism)
  exercism()
  funcall-interactively(exercism)
  command-execute(exercism record)
  execute-extended-command(nil "exercism" nil)
  funcall-interactively(execute-extended-command nil "exercism" nil)
  command-execute(execute-extended-command)

What could be the cause?

It doesn't matter if I loaded the package via require or use-package. I'm on Arch Linux, GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.35, cairo version 1.17.6) of 2022-12-05.

Thanks!

anonimitoraf commented 1 year ago

Hey, thanks for raising. Can you try configuring your API token?

If that works, I'll update the error message to be less cryptic

Trisk3lion commented 1 year ago

Hello, I also got this error after updating through melpa.

I don't think you can evaluate a function within a vector like this. It will be treated like a literal and that's why it tries to find a suffix called ','.

I'm referring to the change in the latest commit.

bertulli commented 1 year ago

IIUC, The point seems to be that in transient having code as the description of a group is not permitted. Backquoting the vector, using (eval ...) or the :description keyword also don't work. :-/

anonimitoraf commented 1 year ago

Thanks for the info, guys! Do you mind checking if this commit fixes the issue?

(Pretty hacky solution, let me know if you think there are edge cases here)

bertulli commented 1 year ago

Partially. It does now compile and should work (I haven't tried an exercise yet). However, it still isn't providing the functionality you want: right now, it always display as the transient title "Exercism (no track selected yet)". IIUC, this is because the variable exercism--transient-name does get updated, but the title of the transient is "installed" only when the macro transient-define-prefix is evaluated. Therefore, inspecting the variable I see, for instance, "Exercism actions (current track: rust)", but the title is not updated, because it uses a copy created in the transient definition.

EDIT: yes, the basic functionalities work

Trisk3lion commented 1 year ago

Almost works, as @bertulli said.

The last touch that is needed is to:

  1. Turn exercism--transient-name into a function. For example just this works:

    (defun exercism--transient-name ()
    exercism--transient-name)
  2. Add :description before exercism--transient-name in exercism transient.

    (transient-define-prefix exercism ()
    "Bring up the Exercism action menu."
    [:description exercism--transient-name
                ("c" "Configure" exercism-configure)
                ("t" "Set current track" exercism-set-track)
                ("o" "Open an exercise" exercism-open-exercise)
                ("s" "Submit" exercism-submit)
                ;; TODO Use a transient flag instead of a separate prefix
                ("S" "Submit (then open in browser)" exercism-submit-then-open-in-browser)])
bertulli commented 1 year ago

Good! And I have an addition about the current status: when the code gets reloaded (for instance, upon Emacs restart) the title gets properly updated (as the transient prefix gets reinstalled with the correct title). @Trisk3lion do you want to do a PR or I'll do it?

anonimitoraf commented 1 year ago

Thanks for that @Trisk3lion @bertulli! I've pushed in a commit for it. PTAL, thanks

bertulli commented 1 year ago

It seems it works now! :confetti_ball: 🎉 Thanks! If @Trisk3lion doesn't have anything else to add, I'd say this can be closed.

Trisk3lion commented 1 year ago

Nothing more from me! @bertulli you can close it.