unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* `other-window-prefix' command, running anything in the other window
@ 2024-01-22  8:09 Psionic K
  2024-01-22  8:29 ` Emanuel Berg
  2024-01-22 21:06 ` Dmitry Gutov
  0 siblings, 2 replies; 6+ messages in thread
From: Psionic K @ 2024-01-22  8:09 UTC (permalink / raw)
  To: help-gnu-emacs

One of my TODO's is to compress all of the `*-other-window` commands
into a prefix command that will make `find-file` do what
`find-file-other-window` does for example.

I think I have an implementation that makes sense.  I'm not sure if it
makes the most sense.

The solution in my head is to create an `other-window-prefix` command.
The command needs to set a prefix state.  During the
`pre-command-hook`, a hook function would check if the prefix was set
and then:
1. If the command has "other-window" in the name, `user-error' because
the user's workflow is crap and they need to unbind that command and
never use it again
2. If the command has an "other-window" version, run that since it
might be smarter
3. Store the selected window (itself an impressive feat due to
minibuffers and dynamic `selected-window` results), create a window,
run the command, restore the selected window

1 & 2 are optional, but could mitigate silliness.

My biggest source of loathing before hacking this out is understanding
C-u, the command loop with minibuffer, and repeat maps, basically the
edge cases.  I think I can read my way through this, but insights
appreciated.  Commands that break when called in another window are
probably just bugs?

Repeat behavior should, like C-u, preserve the `other-window-prefix'
state.  I don't think `other-window-prefix` + `command` can or should
be repeated.  The user intended to stay where they are, and if they
did not, I'm pretty sure no key sequences can be saved.

Btw, pretty please `user-selected-window` and a hook?  Lisp programs
that need to know what the user is doing, not what an enclosing lisp
program is doing, need to know.  Modeline functions are an example.

Curious for better approaches to my `other-window-prefix'.  I may have
just completed copyright assignment and I think this belongs in Emacs.

IMO we should eliminate all instances of suffixed commands that would
be better prefixed by a modifying command, especially when the key
sequences for the longer version are equal to being invoked with a
prefix and the prefix is more versatile for commands that don't have
multiple versions.  Suffixed commands just clog up completions.

Thnkx <3



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

end of thread, other threads:[~2024-01-22 23:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-22  8:09 `other-window-prefix' command, running anything in the other window Psionic K
2024-01-22  8:29 ` Emanuel Berg
2024-01-22 21:06 ` Dmitry Gutov
2024-01-22 21:50   ` Psionic K
2024-01-22 22:21     ` Psionic K
2024-01-22 23:39       ` Dmitry Gutov

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).