Skip to content

Commit

Permalink
Merge pull request #836 from slotThe/wx-partial
Browse files Browse the repository at this point in the history
Address some `-Wx-Partial` warnings
  • Loading branch information
slotThe authored Oct 20, 2023
2 parents 8c0ca8b + 46a2648 commit 9c4325f
Show file tree
Hide file tree
Showing 40 changed files with 193 additions and 191 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@
- Added `passOTPTypePrompt` to type out one-time-passwords via
`xdotool`.

* `XMonad.Util.Stack`

- Added `zipperFocusedAtFirstOf` to differentiate two lists into a
zipper.

### Other changes

## 0.17.1 (September 3, 2022)
Expand Down
5 changes: 3 additions & 2 deletions XMonad/Actions/CycleSelectedLayouts.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ cycleToNext lst a = do
-- | If the current layout is in the list, cycle to the next layout. Otherwise,
-- apply the first layout from list.
cycleThroughLayouts :: [String] -> X ()
cycleThroughLayouts lst = do
cycleThroughLayouts [] = pure ()
cycleThroughLayouts lst@(x: _) = do
winset <- gets windowset
let ld = description . S.layout . S.workspace . S.current $ winset
let newld = fromMaybe (head lst) (cycleToNext lst ld)
let newld = fromMaybe x (cycleToNext lst ld)
sendMessage $ JumpToLayout newld
10 changes: 0 additions & 10 deletions XMonad/Actions/CycleWindows.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ module XMonad.Actions.CycleWindows (
-- $pointer

-- * Generic list rotations
-- $generic
rotUp, rotDown
) where

Expand Down Expand Up @@ -223,12 +222,3 @@ rotUnfocused' f s@(W.Stack _ [] _ ) = rotSlaves' f s -- Master h
rotUnfocused' f (W.Stack t ls rs) = W.Stack t (reverse revls') rs' -- otherwise
where (master :| revls) = NE.reverse (let l:ll = ls in l :| ll)
(revls',rs') = splitAt (length ls) (f $ master:revls ++ rs)

-- $generic
-- Generic list rotations such that @rotUp [1..4]@ is equivalent to
-- @[2,3,4,1]@ and @rotDown [1..4]@ to @[4,1,2,3]@. They both are
-- @id@ for null or singleton lists.
rotUp :: [a] -> [a]
rotUp l = drop 1 l ++ take 1 l
rotDown :: [a] -> [a]
rotDown = reverse . rotUp . reverse
2 changes: 1 addition & 1 deletion XMonad/Actions/EasyMotion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -387,5 +387,5 @@ handleKeyboard dpy drawFn cancel selected deselected = do
_ -> handleKeyboard dpy drawFn cancel (trim fg) (clear bg) >>= retryBackspace
where
(fg, bg) = partition ((== Just keySym) . listToMaybe . chord) selected
trim = map (\o -> o { chord = tail $ chord o })
trim = map (\o -> o { chord = drop 1 $ chord o })
clear = map (\o -> o { chord = [] })
2 changes: 1 addition & 1 deletion XMonad/Actions/MessageFeedback.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module XMonad.Actions.MessageFeedback
import XMonad ( Window )
import XMonad.Core ( X(), Message, SomeMessage(..), LayoutClass(..), windowset, catchX, WorkspaceId, Layout, whenJust )
import XMonad.Operations ( updateLayout, windowBracket, modifyWindowSet )
import XMonad.Prelude ( isJust, liftA2, void )
import XMonad.Prelude
import XMonad.StackSet ( Workspace, current, workspace, layout, tag )

import Control.Monad.State ( gets )
Expand Down
26 changes: 2 additions & 24 deletions XMonad/Actions/MostRecentlyUsed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,8 @@ module XMonad.Actions.MostRecentlyUsed (
) where

-- base
import Data.Maybe (fromMaybe)
import Data.List.NonEmpty (NonEmpty(..), nonEmpty)
import Data.Monoid (All(..), Any)
import Data.Foldable (for_)
import Data.Functor (($>))
import Data.List.NonEmpty (nonEmpty)
import Data.IORef (newIORef, readIORef, writeIORef, modifyIORef)
import Control.Applicative (liftA2)
import Control.Monad (when, unless, join)
import Control.Monad.IO.Class (MonadIO)

-- mtl
Expand Down Expand Up @@ -68,6 +62,7 @@ import XMonad.Util.PureX
(handlingRefresh, curScreenId, curTag, greedyView, view, peek, focusWindow)
import XMonad.Util.History (History, origin, event, erase, ledger)
import XMonad.Actions.Repeatable (repeatableSt)
import XMonad.Prelude

-- }}}

Expand Down Expand Up @@ -208,20 +203,3 @@ winHistEH ev = All True <$ case ev of
where collect w = XS.modify $ \wh@WinHist{hist} -> wh{ hist = erase w hist }

-- }}}

-- --< Auxiliary Data Type: Stream >-- {{{

-- To satisfy the almighty exhaustivity checker.

data Stream a = !a :~ Stream a
infixr 5 :~

(+~) :: [a] -> Stream a -> Stream a
xs +~ s = foldr (:~) s xs
infixr 5 +~

cycleS :: NonEmpty a -> Stream a
cycleS (x :| xs) = s where s = x :~ xs +~ s

-- }}}

5 changes: 2 additions & 3 deletions XMonad/Actions/Navigation2D.hs
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,7 @@ doCenterNavigation dir (cur, rect) winrects

-- All the points that coincide with the current center and succeed it
-- in the (appropriately ordered) window stack.
onCtr' = L.tail $ L.dropWhile ((cur /=) . fst) onCtr
-- tail should be safe here because cur should be in onCtr
onCtr' = L.drop 1 $ L.dropWhile ((cur /=) . fst) onCtr

-- All the points that do not coincide with the current center and which
-- lie in the (rotated) right cone.
Expand Down Expand Up @@ -885,7 +884,7 @@ swap win winset = W.focusWindow cur
newvisws = zipWith (\ws wns -> ws { W.stack = W.differentiate wns }) visws newwins
newscrs = zipWith (\scr ws -> scr { W.workspace = ws }) scrs newvisws
newwinset = winset { W.current = head newscrs
, W.visible = tail newscrs
, W.visible = drop 1 newscrs
}

-- | Calculates the center of a rectangle
Expand Down
9 changes: 4 additions & 5 deletions XMonad/Actions/OnScreen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module XMonad.Actions.OnScreen (
) where

import XMonad
import XMonad.Prelude (fromMaybe, guard)
import XMonad.Prelude (fromMaybe, guard, empty)
import XMonad.StackSet hiding (new)


Expand Down Expand Up @@ -140,10 +140,9 @@ toggleOrView' f i st = fromMaybe (f i st) $ do
let st' = hidden st
-- make sure we actually have to do something
guard $ i == (tag . workspace $ current st)
guard $ not (null st')
-- finally, toggle!
return $ f (tag . head $ st') st

case st' of
[] -> empty
(h : _) -> return $ f (tag h) st -- finally, toggle!

-- $usage
--
Expand Down
2 changes: 1 addition & 1 deletion XMonad/Actions/Plane.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module XMonad.Actions.Plane

import Data.Map (Map, fromList)

import XMonad.Prelude
import XMonad.Prelude hiding (fromList)
import XMonad
import XMonad.StackSet hiding (workspaces)
import XMonad.Util.Run
Expand Down
23 changes: 18 additions & 5 deletions XMonad/Actions/RotSlaves.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
module XMonad.Actions.RotSlaves (
-- $usage
rotSlaves', rotSlavesUp, rotSlavesDown,
rotAll', rotAllUp, rotAllDown
rotAll', rotAllUp, rotAllDown,

-- * Generic list rotations
-- $generic
rotUp, rotDown
) where

import XMonad
Expand All @@ -44,8 +48,8 @@ import XMonad.Prelude
-- | Rotate the windows in the current stack, excluding the first one
-- (master).
rotSlavesUp,rotSlavesDown :: X ()
rotSlavesUp = windows $ modify' (rotSlaves' (\l -> tail l++[head l]))
rotSlavesDown = windows $ modify' (rotSlaves' (\l -> last l : init l))
rotSlavesUp = windows $ modify' (rotSlaves' rotUp)
rotSlavesDown = windows $ modify' (rotSlaves' rotDown)

-- | The actual rotation, as a pure function on the window stack.
rotSlaves' :: ([a] -> [a]) -> Stack a -> Stack a
Expand All @@ -57,10 +61,19 @@ rotSlaves' f s@(Stack _ ls _ ) = Stack t' (reverse revls') rs' -- otherwise

-- | Rotate all the windows in the current stack.
rotAllUp,rotAllDown :: X ()
rotAllUp = windows $ modify' (rotAll' (\l -> tail l++[head l]))
rotAllDown = windows $ modify' (rotAll' (\l -> last l : init l))
rotAllUp = windows $ modify' (rotAll' rotUp)
rotAllDown = windows $ modify' (rotAll' rotDown)

-- | The actual rotation, as a pure function on the window stack.
rotAll' :: ([a] -> [a]) -> Stack a -> Stack a
rotAll' f s = Stack r (reverse revls) rs
where (revls, notEmpty -> r :| rs) = splitAt (length (up s)) (f (integrate s))

-- $generic
-- Generic list rotations such that @rotUp [1..4]@ is equivalent to
-- @[2,3,4,1]@ and @rotDown [1..4]@ to @[4,1,2,3]@. They both are
-- @id@ for null or singleton lists.
rotUp :: [a] -> [a]
rotUp l = drop 1 l ++ take 1 l
rotDown :: [a] -> [a]
rotDown = reverse . rotUp . reverse
2 changes: 1 addition & 1 deletion XMonad/Actions/Search.hs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ searchEngine name site = searchEngineF name (\s -> site ++ escape s)
inside of a URL instead of in the end) you can use the alternative 'searchEngineF' function.
> searchFunc :: String -> String
> searchFunc s | "wiki:" `isPrefixOf` s = "https://en.wikipedia.org/wiki/" ++ (escape $ tail $ snd $ break (==':') s)
> searchFunc s | "wiki:" `isPrefixOf` s = "https://en.wikipedia.org/wiki/" ++ (escape $ drop 1 $ snd $ break (==':') s)
> | "https://" `isPrefixOf` s = s
> | otherwise = (use google) s
> myNewEngine = searchEngineF "mymulti" searchFunc
Expand Down
4 changes: 2 additions & 2 deletions XMonad/Actions/WorkspaceCursors.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import XMonad.Layout.LayoutModifier(ModifiedLayout(..),
import XMonad(Message, WorkspaceId, X, XState(windowset),
fromMessage, sendMessage, windows, gets)
import XMonad.Util.Stack (reverseS)
import XMonad.Prelude (find, fromJust, guard, liftA2, toList, when, (<=<))
import XMonad.Prelude

-- $usage
--
Expand Down Expand Up @@ -98,7 +98,7 @@ makeCursors :: [[String]] -> Cursors String
makeCursors [] = error "Workspace Cursors cannot be empty"
makeCursors a = concat . reverse <$> foldl addDim x xs
where x = end $ map return $ head a
xs = map (map return) $ tail a
xs = map (map return) $ drop 1 a
-- this could probably be simplified, but this true:
-- toList . makeCursors == map (concat . reverse) . sequence . reverse . map (map (:[]))
-- the strange order is used because it makes the regular M-1..9
Expand Down
2 changes: 1 addition & 1 deletion XMonad/Config/Dmwit.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import XMonad.Layout.Grid
import XMonad.Layout.IndependentScreens hiding (withScreen)
import XMonad.Layout.Magnifier
import XMonad.Layout.NoBorders
import XMonad.Prelude
import XMonad.Prelude hiding (fromList)
import XMonad.Util.Dzen hiding (x, y)
import XMonad.Util.SpawnOnce
-- }}}
Expand Down
13 changes: 8 additions & 5 deletions XMonad/Hooks/CurrentWorkspaceOnTop.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ module XMonad.Hooks.CurrentWorkspaceOnTop (
currentWorkspaceOnTop
) where

import qualified Data.List.NonEmpty as NE (nonEmpty)
import qualified Data.Map as M
import XMonad
import XMonad.Prelude (NonEmpty ((:|)), when)
import qualified XMonad.StackSet as S
import qualified XMonad.Util.ExtensibleState as XS
import XMonad.Prelude (unless, when)
import qualified Data.Map as M

-- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
Expand Down Expand Up @@ -63,7 +64,9 @@ currentWorkspaceOnTop = withDisplay $ \d -> do
wins = fltWins ++ map fst rs -- order: first all floating windows, then the order the layout returned
-- end of reimplementation

unless (null wins) $ do
io $ raiseWindow d (head wins) -- raise first window of current workspace to the very top,
io $ restackWindows d wins -- then use restackWindows to let all other windows from the workspace follow
case NE.nonEmpty wins of
Nothing -> pure ()
Just (w :| ws') -> do
io $ raiseWindow d w -- raise first window of current workspace to the very top,
io $ restackWindows d (w : ws') -- then use restackWindows to let all other windows from the workspace follow
XS.put(CWOTS curTag)
4 changes: 1 addition & 3 deletions XMonad/Hooks/DebugEvents.hs
Original file line number Diff line number Diff line change
Expand Up @@ -687,9 +687,7 @@ dumpString = do
\s -> if null s
then Nothing
else let (w,s'') = break (== '\NUL') s
s' = if null s''
then s''
else tail s''
s' = drop 1 s''
in Just (w,s')
case ss of
[s] -> append $ show s
Expand Down
6 changes: 4 additions & 2 deletions XMonad/Hooks/InsertPosition.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,7 @@ insertDown :: (Eq a) => a -> W.StackSet i l a s sd -> W.StackSet i l a s sd
insertDown w = W.swapDown . W.insertUp w

focusLast' :: W.Stack a -> W.Stack a
focusLast' st = let ws = W.integrate st
in W.Stack (last ws) (tail $ reverse ws) []
focusLast' st =
case reverse (W.integrate st) of
[] -> st
(l : ws) -> W.Stack l ws []
4 changes: 2 additions & 2 deletions XMonad/Hooks/StatusBar/PP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ dzenStrip = strip [] where
strip keep x
| null x = keep
| "^^" `isPrefixOf` x = strip (keep ++ "^") (drop 2 x)
| '^' == head x = strip keep (drop 1 . dropWhile (/= ')') $ x)
| "^" `isPrefixOf` x = strip keep (drop 1 . dropWhile (/= ')') $ x)
| otherwise = let (good,x') = span (/= '^') x
in strip (keep ++ good) x'

Expand Down Expand Up @@ -464,7 +464,7 @@ xmobarStrip = converge (xmobarStripTags ["fc","icon","action"])

converge :: (Eq a) => (a -> a) -> a -> a
converge f a = let xs = iterate f a
in fst $ head $ dropWhile (uncurry (/=)) $ zip xs $ tail xs
in fst $ head $ dropWhile (uncurry (/=)) $ zip xs $ drop 1 xs

xmobarStripTags :: [String] -- ^ tags
-> String -> String -- ^ with all \<tag\>...\</tag\> removed
Expand Down
2 changes: 1 addition & 1 deletion XMonad/Hooks/WallpaperSetter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ getPicPath conf (WallpaperDir dir) = do
direxists <- doesDirectoryExist $ wallpaperBaseDir conf </> dir
if direxists
then do files <- getDirectoryContents $ wallpaperBaseDir conf </> dir
let files' = filter ((/='.').head) files
let files' = filter (not . ("." `isPrefixOf`)) files
file <- pickFrom files'
return $ Just $ wallpaperBaseDir conf </> dir </> file
else return Nothing
Expand Down
4 changes: 2 additions & 2 deletions XMonad/Hooks/WorkspaceHistory.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import Control.DeepSeq
import Prelude
import XMonad
import XMonad.StackSet hiding (delete, filter, new)
import XMonad.Prelude (delete, find, foldl', groupBy, nub, sortBy)
import XMonad.Prelude (delete, find, foldl', groupBy, nub, sortBy, listToMaybe)
import qualified XMonad.Util.ExtensibleState as XS

-- $usage
Expand Down Expand Up @@ -90,7 +90,7 @@ workspaceHistoryWithScreen = XS.gets history

workspaceHistoryByScreen :: X [(ScreenId, [WorkspaceId])]
workspaceHistoryByScreen =
map (\wss -> (fst $ head wss, map snd wss)) .
map (\wss -> (maybe 0 fst (listToMaybe wss), map snd wss)) .
groupBy (\a b -> fst a == fst b) .
sortBy (\a b -> compare (fst a) $ fst b)<$>
workspaceHistoryWithScreen
Expand Down
8 changes: 3 additions & 5 deletions XMonad/Layout/CenteredMaster.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,9 @@ applyPosition :: (LayoutClass l a, Eq a) =>
applyPosition pos wksp rect = do
let stack = W.stack wksp
let ws = W.integrate' stack
if null ws then
runLayout wksp rect
else do
let firstW = head ws
let other = tail ws
case ws of
[] -> runLayout wksp rect
(firstW : other) -> do
let filtStack = stack >>= W.filter (firstW /=)
wrs <- runLayout (wksp {W.stack = filtStack}) rect
return $ first ((firstW, place pos other rect) :) wrs
Expand Down
Loading

0 comments on commit 9c4325f

Please sign in to comment.