help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

`other-window-prefix' command, running anything in the other window


From: Psionic K
Subject: `other-window-prefix' command, running anything in the other window
Date: Mon, 22 Jan 2024 17:09:16 +0900

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]