[xmonad] Changes to XPrompt

Carlos López Camey c.lopez at kmels.net
Wed Jun 6 16:59:39 CEST 2012


> I'm not sure I understand. Why is providing a data structure that stores two
> values better than supplying the two values? What can the internal code do
> with an XPMode that it couldn't do with a completion function and an action?
> (...and even if there is an answer to this, why can't the API wrap its two
> arguments in an XPMode before doing whatever it is it's doing?)

A XPMode with these two values isn't really more powerful than the two
values by themselves I guess :)
--

So I've worked a bit on this [0], XMonad.Actions.Launcher uses
mkXPromptWithModes to build a new Prompt, this prompt allows switching
between modes, each one with its own autocomplete function.

Right now there are 3 modes listed in Launcher, they autocomplete to
file paths. When something is searched and a file path is selected,
the Prompt executes the action function, with type String -> X(), that
was provided to mkXPromptWithModes.

However, I'd like it to have {- my question #1 -}
1. An action per mode. Have the prompt execute the action that the
current mode contains, instead of the same one for every mode.
2. Allow the action to have the type String -> X a.

About 1. I tried to follow Don Stewart's comments on stackoverflow but
I couldn't convince GHC yet. Maybe I should try again and ask with the
code I tried
About 2. If 1. is possible and the action has type String -> X a, you
can't implement one with type String -> X (), can you? If yes, problem
solved. If not, I'd appreciate help with that.

{- my question #2 -}
The locate mode is slower than recollq, that is ok. The problem is
when I write characters too fast, it becomes *slow*. I guess it's
because all the spawned processes.. Should I do each autocompletion in
a different thread? or are they already in another thread? I'd
appreciate help here too

If you would like to try it, take a look at my xmonad (around the line
#179 in here: https://gist.github.com/2882350).

Thanks for your time,
Carlos

[0] https://github.com/kmels/xmonad-contrib-launcher/commit/a534f0cd475215a4fd9d73be6f0e16421537186e,
this code is very unclean, e.g. there are things hardcoded. When in
Launcher.hs, ignore the comments on how it works, it was only the
initial idea.



More information about the xmonad mailing list