emacsorphanage / god-mode

Minor mode for God-like command entering
GNU General Public License v3.0
854 stars 51 forks source link

God mode does not work in Transient UI #130

Open rudolf-adamkovic opened 3 years ago

rudolf-adamkovic commented 3 years ago

Magit uses the Transient package to show dialogs, and God does not work inside of these buffers. Does anyone know how to work around this problem?

darth10 commented 3 years ago

Transient doesn't allow entering any keys (including M-x) other than the ones shown in the popup dialog.

You could try customising god-exempt-major-modes (which currently includes magit-popup-mode) and see if that helps.

rudolf-adamkovic commented 3 years ago

@darth10 Wait, but god-exempt-major-modes will not allow me to control Magit popups with God, will it?

darth10 commented 3 years ago

Given the way transient works, I doubt it, but it's worth a shot. I've tried it out, and that doesn't work.

A more important question would be whether God mode is actually needed to control transient UI popups. IMHO the popups generally have single key bindings, so you wouldn't gain a lot through God mode.

rudolf-adamkovic commented 3 years ago

I think the main reason is accessibility. If someone uses God to avoid RSI, or recover from RSI, they might prefer to use ESC g instead of C-g (given that m is M-), and the like. Another reason is consistency; once one gets used to God, they do not need to context switch.

darth10 commented 3 years ago

That makes sense for C-g vs. ESC g, but for any other bindings, transient will print an Unbound suffix: ... message.

Maybe some more examples of what you're trying to achieve would be helpful here. Is it just ESC g that you need?

rudolf-adamkovic commented 3 years ago

Here is a real-world example:

Working in Org, I wanted to export a document as an HTML fragment.

I hit c e in God mode. Then, in the transient window:

More generally, these transient UIs can (and do) have C--bound shortcuts.

darth10 commented 3 years ago

That's a great example, but c e in org-mode invokes org-export-dispatch (ox.el) which doesn't use transient 😄

Coming back to transient specifically, have you tried customising transient-map to fit your workflow?

(define-key transient-map (kbd "<escape> g") 'transient-quit-one) ;; ESC g

I understand this is hard to do for every command you intend to use, but it's even harder to implement in God mode for every popup dialog mode that Emacs supports. For example, for org-export-dispatch, since the popup buffer uses read-char-exclusive to read keys in org-export--dispatch-action, there's nothing to hook God mode into for the purpose of adding modifier keys. Transient on the other hand uses keymaps, so might be a bit more straightforward to implement. Evil doesn't support transient UI buffers though (see emacs-evil/evil-magit#77). Regardless, God mode needs be aware of every popup mode out there to have 100% consistency in all popups.

There was some potential in using set-transient-map in #113, but that has been abandoned as it wouldn't support Magit.

I'll explore how this can be implemented cleanly, but it could take a while.

rudolf-adamkovic commented 3 years ago

@darth10

have you tried customising

To be honest, customizing a single key binding is not what I am after. Instead, I would like to see a solution that would always work reliably in all buffers, with no exceptions.