[xmonad] New keybinding parser

Spencer Janssen sjanssen at cse.unl.edu
Tue Feb 26 21:31:55 EST 2008


On Tue, Feb 26, 2008 at 06:05:00PM -0500, David Roundy wrote:
> On Tue, Feb 26, 2008 at 05:39:23PM -0500, Brent Yorgey wrote:
> > Hi all,
> > 
> > I've just pushed (what I hope is) an exciting patch to XMonad.Util.EZConfig.
> > It now exports a bunch of functions for parsing keybindings, emacs-style.
> > That's right, instead of typing
> > 
> >   ((modMask x .|. shiftMask .|. controlMask, xK_F12), action)
> > 
> > or other such boilerplate drudgery, you can now just say
> > 
> >   ("M-S-C-<F12>", action).
> > 
> > Submaps are also supported -- just do something like
> > 
> >   ("M-x p", action1)
> >   ("M-x q", action2)
> > 
> > and it does the right thing.  Detailed documentation is included, so look
> > there for a more thorough explanation and examples.  As always, comments,
> > bug reports, and patches welcome.
> 
> This sounds nice, but I can't help but wonder if we can't do one up, and
> provide our users with a handy interface that doesn't allow them to run
> into run-time parse errors.  Something like
> 
>   (m 'q', action0)
>   (m $ s $ c f12, action1)
>   (m $ s $ c 'x', action2)
> 
> should be trivial to implement (albeit eating up the namespace rather
> ferociously), and would give a bit more safety with only a
> slightly-less-pretty syntax.  Submaps would require a bit more syntax, but
> something like
> 
>   (m x &&& 'q')
> 
> should be implementable.  I'm not sure if this would be deemed worthwhile,
> but it seems to me a bit more elegant than parsing strings into key
> bindings.
> 
> David

Of course the character literals can still cause parse failure at runtime.


More information about the xmonad mailing list