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

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

Re: Can I use 'C-x o o o o o' instead of C-x o C-x o C-x o C-x o C-x o?


From: Emanuel Berg
Subject: Re: Can I use 'C-x o o o o o' instead of C-x o C-x o C-x o C-x o C-x o?
Date: Tue, 28 Apr 2015 19:03:36 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

<keith@cheungsfamily.org> writes:

> Scenario 1 - I split many windows. - I wish to
> switch to some other windows. - I type C-x o, C-x o,
> C-x o repeatedly until the cursor landed on the
> desired window. Is there a way to use C-x
> o o o instead?

You can't do that the normal way because then you'd
have to set up prefix keys, but they themselves would
have to be commands! - so Emacs cannot tell if it is
a prefix key (i.e. it should await more input) or if
it is a command (i.e. it should act).

However, you can do it with programming, as always,
and here's how:

The first command, which you should bind to a key,
should re-bind the keys - all keys. "o" should be
"move to the next window". All other keys should be -
let's say normal behavior is B - all other keys should
be:

    a) exit this window roaming mode
    b) do normal behavior B

This will make for transparency - except for the
particular key "o"! Perhaps you can insert that with
`C-u o' when you don't want to go to the next window
(only necessary in window roaming mode, of course).

This closely resembles what I did (out of someone
else's work) - this code [1] should be understandable
(I hope) and the principle is exactly the same.

Come back with more questions if need be!

> I aware that I can use C-u num C-x o, if I know the
> desired window is num step away. But there are times
> that I do not know 'num'.

OK: instead of iteration, I'd assign each window
a letter (a, b, c...) and show that in the mode bar.
Then do a function that accepts an argument which is
such a letter. Then jump to that window. I'd say this
idea is much better.

> Scenario 2 - I use the windmove package. - I bind
> the windmove-up/down/left/right to C-o i, C-o k, C-o
> j, C-o l respectively. Now, if I want to windmove to
> up-left, I type C-o i, C-o j. Is there a way to use
> C-o i j instead?

First, good bindings! `C-o i' for up etc. are great.
I love the 'ijkl' keys for 2D movements ever since
playing a monochrome Lode Runner on a Mac Plus in
the 80s.

Second, you can't do that for the same prefix/command
reason above. It would require some timeout solution
for the prefix key which would be too slow to use
anyway to be pleasant. Instead, why don't you use the
same principle as you already did and use "u", "o",
".", and "m" for combinations? E.g., "u" is up, then
left? But, here I actually think it is better to use
`C-o i', then `C-o j' and so on. I don't see any
comfort or speed disadvantage to speak of with that.

Good luck!

[1] http://user.it.uu.se/~embe8573/conf/emacs-init/caps-back.el

-- 
underground experts united
http://user.it.uu.se/~embe8573


reply via email to

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