stumpwm-devel
[Top][All Lists]
Advanced

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

Re: [STUMP] Prefix-Lock


From: J. David Smith
Subject: Re: [STUMP] Prefix-Lock
Date: Sun, 30 Mar 2014 13:20:43 -0400

I started looking into this today and made some interesting finds:

1. command-mode is almost exactly what I wanted -- except that half the binds seem to be missing. I found that *root-map* does not contain the default bindings when I look at it in my slime REPL.
2. handle-keymap (https://github.com/stumpwm/stumpwm/blob/master/events.lisp#L212-L246) seems to be the ideal location to place logic that matches Bjergaard's suggestion. It's a recursive function that executes the key bindings. If it were prevented from leaving the top level of recursion, then it'd be the same as 'holding' the prefix key.

I'm going to look at implementing #2 (which I like more), but there were a few oddities with keymaps that I'd like to point out:

1. the bindings for ? and C-h are hard-coded into handle-keymap. I think the idea is that this prevents users from ever being stuck unable to do anything because PREFIX ? will always bring up the command list. However, this method of doing it strikes me as odd.
2. The command list (PREFIX ? or PREFIX C-h) lists all of my custom bindings + the defaults. However, when I eval *root-map* in the REPL it seems to contain only my custom bindings. When I do (push-top-map *root-map*) [what command-mode does], I can use my keys (eg 'b' for chromium, 'a' for evince) but not the defaults (eg 'n'/'C-n' for next-hidden-window).


On Thu, Mar 27, 2014 at 12:24 PM, David Bjergaard <address@hidden> wrote:
Hi David,

(I know that others have replied to this thread, but the topic has
shifted a little from your original post.)

Responses inline:
"J. David Smith" <address@hidden> writes:

> Hey all:
>
> I was demo'ing Stump to a coworker this afternoon and in order to
> cycle through windows it was constantly PREFIX n, PREFIX n, PREFIX n.
> Normally not a big deal, but with 6-7 windows and without having set
> binds for half of them it gets a bit annoying; he picked it up and
> commented on it.
>
> So, here's my idea: Have a binding like PREFIX C-l that locks the
> PREFIX key on. Each time a keychord completes, it'd revert to having
> just PREFIX entered.
>
> For example:
>
> PREFIX C-l
> n
> n
> n
> ESC
>
I (personally) want to have the following behavior:
PREFIX n,
(check if modifier (ie ctrl) is still pressed)

If it is, then the "sticky map" is activated (ie n or p cycles you
through windows).

When modifier is released, return to normal state.

This would make commands like resizing frames in iresize, or moving
windows much more natural.  Those commands tend to use an awkward number
of prefix presses (or in the case of resize, it hijacks the entire
keymap until you press RET). Unfortunately my idea is harder to
implement than yours, more details below.

> instead of the former. I have a couple of questions about this.
>
> 1) is this a good idea? Any major pitfalls that I'm not seeing?
I agree heartily with your idea. In fact, the way you propose it would
not be difficult at all.
> 2) if it's a reasonable idea, is there already a built-in way to do
> this?
Yes, you bind a keymap (say *prefix-lock-map*) to the *top-map* to C-l,
then when in that map you have whatever commands you want to be "sticky"
(n p for cycling windows etc) including a binding to ESC that puts you
back on the *top-map* (ie un-sticks the prefix key).  This is already
done in iresize.lisp.
> 3) if it doesn't already exist, what's a good way to go about it?
Read iresize.lisp :).  This could easily start out as a contrib module,
and if there's wider adoption it could be integrated into the core.
>
> Ideally I'd like to be able to do it on submaps as well (eg s-w s-m is
> my prefix for MPD control).
>
> -- David
>

Cheers,

    Dave


reply via email to

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