
On 2007.10.10 11:02:49 -0500, Spencer Janssen
On Monday 08 October 2007 18:02:19 gwern0@gmail.com wrote:
Mon Oct 8 18:27:06 EDT 2007 gwern0@gmail.com * XSelection.hs: a new module for XMonadContrib dealing with copy-and-paste This is based on Andrea Rossato's standalone tools and is meant for integration straight into a Config.hs. It offers two main functions, 'getSelection' and 'putSelection', whose names should be self-explanatory.
Applied. This module could be significantly more efficient if the functions were lifted into the X monad and reused X's Display and such.
Cheers, Spencer Janssen
Yes, it would be more efficient, but I've run into problems with that approach. If you use withDisplay, the result needs to be in the X monad, so the type of getSelection would then be X String, correct? But as far as I've been able to use an X String in my unsafePromptSelection and safePromptSelection, it fails miserably; effectively running the search with an empty string. I've attached a patch showing how I did it; the *PromptSelection functions are again defined thus: promptSelection, safePromptSelection, unsafePromptSelection :: String -> X () promptSelection = safePromptSelection safePromptSelection application = join $ liftM (safeSpawn application) (getSelection) unsafePromptSelection application = join $ liftM unsafeSpawn $ fmap (\x -> application ++ " " ++ x) getSelection It all compiles and runs, however key functionality (for me) is lost. Unless I'm doing something obviously wrong, I think this suggestion is a dead-end. -- gwern schloss 03 Becker Saddam bce Putin (SAIRI) Kennedy BLU-114/B KEDO