unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* transient questions
@ 2023-03-14  0:05 Joost Kremers
  2023-03-14  1:15 ` triple-backquote (was: Re: transient questions) Emanuel Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Joost Kremers @ 2023-03-14  0:05 UTC (permalink / raw)
  To: gnu-emacs-help

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-15  9:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-14  0:05 transient questions Joost Kremers
2023-03-14  1:15 ` triple-backquote (was: Re: transient questions) Emanuel Berg
2023-03-15  9:25   ` Ruijie Yu via Users list for the GNU Emacs text editor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).