[Xmonad] darcs patch: simplify StackSet.delete

David Roundy droundy at darcs.net
Mon Jun 25 11:18:44 EDT 2007


On Mon, Jun 25, 2007 at 02:43:03PM +1000, Donald Bruce Stewart wrote:
> droundy:
> > Sun Jun 24 07:48:54 PDT 2007  David Roundy <droundy at darcs.net>
> >   * simplify StackSet.delete
> > 
> 
> Content-Description: A darcs patch for your repository!
> > 
> > New patches:
> > 
> > [simplify StackSet.delete
> > David Roundy <droundy at darcs.net>**20070624144854] 
> > <
> > > {
> > hunk ./StackSet.hs 431
> >  --   * otherwise, delete doesn't affect the master.
> > -delete w s | Just w == peek s = remove s -- common case. 
> > +delete w s | Just w == peek s = modify Nothing (filter (/= w)) s -- common case.
> >             | otherwise = maybe s (removeWindow.tag.workspace.current $ s) (findIndex w s)
> >    where
> >      -- find and remove window script
> > hunk ./StackSet.hs 435
> > -    removeWindow o n = foldr ($) s [view o,remove,view n]
> > -
> > -    -- actual removal logic, and focus/master logic:
> > -    remove = modify Nothing $ \c ->
> > -      if focus c == w
> > -      then case c of
> > -        Stack _ ls     (r:rs) -> Just $ Stack r ls rs    -- try down first
> > -        Stack _ (l:ls) []     -> Just $ Stack l ls []    -- else up
> > -        Stack _ []     []     -> Nothing
> > -      else Just $ c { up = w `L.delete` up c, down = w `L.delete` down c }
> > +    removeWindow o n = foldr ($) s [view o,modify Nothing (filter (/= w)),view n]
> 
> How does this ensure the old semantics for where focus goes, is preserved?
> Does it rely on filter implementing the same focus semantics as 'remove' did?

Yes, that's what it relies on, which filter currently does.  It seems
better to enforce this in filter, so there'd be just one piece of code
defining the desired semantics.
-- 
David Roundy
Department of Physics
Oregon State University


More information about the Xmonad mailing list