[xmonad] Partial match in prompt

Владимир Сидоренко yoyavova at gmail.com
Tue Mar 3 16:03:16 EST 2009


Yes, thank you.

Now i have new problem. maybe it's even a bug.
If I define prompt in this way:

data Songs = Songs
instance XPrompt Songs where
    showXPrompt Songs  = "Song: "

songsPrompt :: XPConfig -> X ()
songsPrompt c = do
    cmds <- io $ getSongs
    mkXPrompt Songs c (mkComplFunFromList' cmds) (\s -> spawn "mpc play")

getSongs = return ["Nigthwish - 1", "Nightwish - 2"]

(Notice song names)

Then i call this prompt and hit <tab> twice to select second "song", and i
get this in prompt:
"Song: Nightwish - Nightwish - 1"
if i hit tab more, i get:
"Song: Nightwish - Nightwish - Nightwish - Nightwish - 1"

But if remove spaces:
getSongs = return ["Nigthwish-1", "Nightwish-2"]
Everything works fine.

This behaviour is made on purpose? Or it's my mistake somewhere? )

Thank you.

2009/3/3 Daniel Schoepe <asgaroth_ at gmx.de>

> Владимир Сидоренко wrote:
> > Hi
> >
> > I wrote my custom prompts for selecting playlists and songs in mpd and
> > used mkComplFunFromList to make completion function.
> > What is the easiest way to enable partial matching of input against
> > completion list. I mean so that compare was like
> > select .. from ... where ... like '%input%'
> > ?
> >
> > Thank you.
>
> As far as I know, you'd have to define a custom completion function
> instead of creating it with mkComplFunFromList. So something like this
> should work:
>
> infixCompl _ [] = return []
> infixCompl l s = return $ filter (s `isInfixOf`) l
>
> That would create a function that returns all the matches in the list
> if, the input string occurs in the element.
>
> _______________________________________________
> xmonad mailing list
> xmonad at haskell.org
> http://www.haskell.org/mailman/listinfo/xmonad
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/xmonad/attachments/20090303/ba85defb/attachment.htm


More information about the xmonad mailing list