[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
transient questions
From: |
Joost Kremers |
Subject: |
transient questions |
Date: |
Tue, 14 Mar 2023 01:05:46 +0100 |
User-agent: |
mu4e 1.8.14; emacs 29.0.60 |
Hi all,
I'm in the process of translating my hydras to transient, mainly to learn a bit
about how transients work, and I'm running into something I don't get.
I've concocted the following:
```
(transient-define-prefix jk-move-transient ()
:transient-non-suffix #'transient--do-leave
[:class transient-row
("SPC" "" scroll-up-command :transient t)
("C-v" "" scroll-up-command :transient t)
("<backspace>" "" scroll-down-command :transient t)
("M-v" "" scroll-down-command :transient t)
("<up>" "" scroll-up-line :transient t)
("<down>" "" scroll-down-line :transient t)
("<left>" "" scroll-right :transient t)
("<right>" "" scroll-left :transient t)
("b" "(Un)set bookmark" bm-toggle :transient t)
("g" "Top of buffer" beginning-of-buffer :transient t)
("G" "End of buffer" end-of-buffer :transient t)
("l" "Goto line" consult-goto-line)
("m" "Goto mark" consult-mark)
("n" "Next bookmark" bm-next)
("o" "Outline" consult-outline)
("t" "Previous bookmark" bm-previous)
("z" "Avy line" avy-goto-line)])
```
>From how I understand the manual, the line
:transient-non-suffix #'transient--do-leave
Should allow non-suffix keys to exit the transient and be executed. That doesn't
seem to work, though. When I type a non-suffix key, the command bound to it does
get executed, (I can move the cursor with C-n, C-p, etc.), but the transient
stays active. So I'm wondering what I'm misunderstanding here and if there's a
way to get what I want. (Which is that any key not bound in the transient exits
the transient and gets executed.)
Secondly, I was wondering if there's a way to call a transient suffix directly,
have it executed and activate the transient. In a hydra, you can bind not only
the body of the hydra but also its heads to keys. The hydra on which the
transient above is modelled, is this:
```
(defhydra jk-move-hydra (:hint nil)
"Jump"
("SPC" scroll-up-command)
("C-v" scroll-up-command)
("<backspace>" scroll-down-command)
("M-v" scroll-down-command)
("<up>" scroll-up-line)
("<down>" scroll-down-line)
("<left>" scroll-right)
("<right>" scroll-left)
("b" bm-toggle "(Un)set bookmark")
("g" beginning-of-buffer "Top of buffer")
("G" end-of-buffer "End of buffer")
("l" consult-goto-line "Goto line")
("m" consult-mark "Goto mark")
("n" bm-next "Next bookmark")
("o" consult-outline)
("t" bm-previous "Previous bookmark")
("z" avy-goto-line "Avy line"))
(bind-key "C-v" #'jk-move-hydra/scroll-up-command)
(bind-key "M-v" #'jk-move-hydra/scroll-down-command)
(bind-key "M-g" #'jk-move-hydra/body)
(bind-key "M-G" #'jk-move-hydra/end-of-buffer)
```
I've bound `M-g` to the body of the hydra (the prefix, in transient parlance),
but also a few other keys to heads (suffixes, in transient parlance). With this
setup, `C-v` will execute `jk-move-hydra/scroll-up-command` (i.e.,
`scroll-up-command`) plus activate the hydra.
Is something similar possible with transients? I haven't been able to find
anything like it, but perhaps I'm just not looking in the right place.
TIA
--
Joost Kremers
Life has its moments
- transient questions,
Joost Kremers <=