How to disable history in XMonad.Actions.Search.

Hi, I have recently started using XMonad.Actions.Search in conjunction with XMonad.Actions.Submap and am finding it very useful. I'm not overly keen on it presenting previous search terms in the prompt though and would like to turn them off somehow. I thought the easiest way would be to use the historyFilter field in XPConfig but am not having any luck. I have tried both of these: historyFilter = \x -> [] and historyFilter =\[x] -> [] Unfortunately my history is still saved to .xmonad/history and previous search terms are presented to me the next time I search. Is there an easy way to change this behaviour in xmonad.hs or would it mean a change to XMonad.Actions.Search? Regards, Mike

On Sun, Sep 20, 2009 at 4:23 AM, Mike Sampson
Hi, I have recently started using XMonad.Actions.Search in conjunction with XMonad.Actions.Submap and am finding it very useful. I'm not overly keen on it presenting previous search terms in the prompt though and would like to turn them off somehow. I thought the easiest way would be to use the historyFilter field in XPConfig but am not having any luck. I have tried both of these:
historyFilter = \x -> []
and
historyFilter =\[x] -> []
Code tip: you could also write '\_ -> []', or just 'const []'.
Unfortunately my history is still saved to .xmonad/history and previous search terms are presented to me the next time I search. Is there an easy way to change this behaviour in xmonad.hs or would it mean a change to XMonad.Actions.Search?
Regards,
Mike
If you look in Search, you'll see: {- | Like 'search', but for use with the output from a Prompt; it grabs the Prompt's result, passes it to a given searchEngine and opens it in a given browser. -} promptSearchBrowser ∷ XPConfig → Browser → SearchEngine → X () promptSearchBrowser config browser (SearchEngine name site) = mkXPrompt (Search name) config historyCompletion $ search browser site That is, 'config' is not asked for the history completion function nor is any filter ran upon it; rather, it uses the canned historyCompletion function from XMonad.Prompt. It's possible to grab the historyFilter from the XPConfig that promptSearchBrowser has access to; if you could test out my attached patch? -- gwern

Gwern,
On Mon, Sep 21, 2009 at 12:10 AM, Gwern Branwen
Code tip: you could also write '\_ -> []', or just 'const []'.
Yes, my Haskell leaves a lot to be desired. :) I went with const []. Thanks.
If you look in Search, you'll see:
{- | Like 'search', but for use with the output from a Prompt; it grabs the Prompt's result, passes it to a given searchEngine and opens it in a given browser. -} promptSearchBrowser ∷ XPConfig → Browser → SearchEngine → X () promptSearchBrowser config browser (SearchEngine name site) = mkXPrompt (Search name) config historyCompletion $ search browser site
That is, 'config' is not asked for the history completion function nor is any filter ran upon it; rather, it uses the canned historyCompletion function from XMonad.Prompt.
Ahh. I did browse this file but missed the finer details of that function.
It's possible to grab the historyFilter from the XPConfig that promptSearchBrowser has access to; if you could test out my attached patch?
Applied. This seems to be working perfectly. When the above historyFilter is used, the history file is still created but contains an empty list. Perfect. Your assistance is much appreciated. Once again the xmonad mailing list comes through for me. Many thanks, Mike

On Sun, Sep 20, 2009 at 11:42 AM, Mike Sampson
Gwern,
On Mon, Sep 21, 2009 at 12:10 AM, Gwern Branwen
wrote: Code tip: you could also write '\_ -> []', or just 'const []'.
Yes, my Haskell leaves a lot to be desired. :) I went with const []. Thanks.
If you look in Search, you'll see:
{- | Like 'search', but for use with the output from a Prompt; it grabs the Prompt's result, passes it to a given searchEngine and opens it in a given browser. -} promptSearchBrowser ∷ XPConfig → Browser → SearchEngine → X () promptSearchBrowser config browser (SearchEngine name site) = mkXPrompt (Search name) config historyCompletion $ search browser site
That is, 'config' is not asked for the history completion function nor is any filter ran upon it; rather, it uses the canned historyCompletion function from XMonad.Prompt.
Ahh. I did browse this file but missed the finer details of that function.
It's possible to grab the historyFilter from the XPConfig that promptSearchBrowser has access to; if you could test out my attached patch?
Applied. This seems to be working perfectly. When the above historyFilter is used, the history file is still created but contains an empty list. Perfect.
Your assistance is much appreciated. Once again the xmonad mailing list comes through for me.
Many thanks,
Mike
This patch isn't perfect, though. I reflected on it and realized that it doesn't make sense to have invokers of mkXPrompt do the filtering themselves, when mkXPrompt has access to the XPConfig and the Completion functions - one could just write the filtering once, in mkXPrompt, and not every caller. But when I went to add it, I saw that mkXPrompt wraps mkXPromptWithReturn, and the latter calls 'historyFilter conf'! Which mystifies me. I'm now not sure why my patch worked or what to do next: mkXPromptWithReturn ∷ XPrompt p ⇒ p → XPConfig → ComplFunction → (String → X a) → X (Maybe a) mkXPromptWithReturn t conf compl action = do c ← ask let d = display c rw = theRoot c s ← gets $ screenRect · W.screenDetail · W.current · windowset hist ← liftIO $ readHistory w ← liftIO $ createWin d rw conf s liftIO $ selectInput d w $ exposureMask .|. keyPressMask gc ← liftIO $ createGC d w liftIO $ setGraphicsExposures d gc False fs ← initXMF (font conf) let hs = fromMaybe [] $ Map.lookup (showXPrompt t) hist st = initState d rw w s compl gc fs (XPT t) hs conf st' ← liftIO $ execStateT runXP st releaseXMF fs liftIO $ freeGC d gc if successful st' then do liftIO $ writeHistory $ Map.insertWith (λxs ys → take (historySize conf) · historyFilter conf $ xs ++ ys) (showXPrompt t) [command st'] hist Just <$> action (command st') else return Nothing -- gwern

On Mon, Sep 21, 2009 at 3:56 AM, Gwern Branwen
This patch isn't perfect, though. I reflected on it and realized that it doesn't make sense to have invokers of mkXPrompt do the filtering themselves, when mkXPrompt has access to the XPConfig and the Completion functions - one could just write the filtering once, in mkXPrompt, and not every caller.
But when I went to add it, I saw that mkXPrompt wraps mkXPromptWithReturn, and the latter calls 'historyFilter conf'! Which mystifies me. I'm now not sure why my patch worked or what to do next:
As I mentioned my Haskell skills are quite limited but from what I understand this functionality should have been working as is? Anything using MkXPrompt should honour the historyFilter field. If that is so perhaps the real question is why wasn't it working to begin with? I will try reverting your patch, rebuilding and double check that the historyFilter field of XPConfig is in fact ignored. I hope I haven't missed a step here or something and led you on a wild goose chase. I will try this after work and report back.
mkXPromptWithReturn ∷ XPrompt p ⇒ p → XPConfig → ComplFunction → (String → X a) → X (Maybe a) mkXPromptWithReturn t conf compl action = do c ← ask let d = display c rw = theRoot c s ← gets $ screenRect · W.screenDetail · W.current · windowset hist ← liftIO $ readHistory w ← liftIO $ createWin d rw conf s liftIO $ selectInput d w $ exposureMask .|. keyPressMask gc ← liftIO $ createGC d w liftIO $ setGraphicsExposures d gc False fs ← initXMF (font conf) let hs = fromMaybe [] $ Map.lookup (showXPrompt t) hist st = initState d rw w s compl gc fs (XPT t) hs conf st' ← liftIO $ execStateT runXP st
releaseXMF fs liftIO $ freeGC d gc if successful st' then do liftIO $ writeHistory $ Map.insertWith (λxs ys → take (historySize conf) · historyFilter conf $ xs ++ ys) (showXPrompt t) [command st'] hist Just <$> action (command st') else return Nothing
-- gwern

On Sun, Sep 20, 2009 at 06:23:46PM +1000, Mike Sampson wrote:
Unfortunately my history is still saved to .xmonad/history and previous search terms are presented to me the next time I search. Is there an easy way to change this behaviour in xmonad.hs or would it mean a change to XMonad.Actions.Search?
I pushed a patch that should fix your issue. Using historyFilter = \x -> [] or historyFilter = const [] should now work as expected.

On Mon, Sep 21, 2009 at 8:18 AM, Daniel Schoepe
On Sun, Sep 20, 2009 at 06:23:46PM +1000, Mike Sampson wrote:
I pushed a patch that should fix your issue. Using historyFilter = \x -> [] or historyFilter = const [] should now work as expected.
Thanks Daniel. I will try this out when I get home after work.
participants (3)
-
Daniel Schoepe
-
Gwern Branwen
-
Mike Sampson