[xmonad] runOrRaise changes
Gwern Branwen
gwern0 at gmail.com
Mon Jun 22 16:18:36 EDT 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
I have just pushed the following patches to XMC. One just tidies up
the haddocks in WindowGo, and one adds a convenience function to
Utils.Run.
The third one changes the internals of WindowGo to use safeSpawn
instead of spawn/going via /bin/sh. I have made the last change
because after looking through the config archive, it seems every use
of the runOrRaise functions simply specifies a program name; so spawn
is just unnecessary & cluttering up the process tree.
As I said, this shouldn't adversely affect anyone who just does stuff
like 'runOrRaise "emacs"' or 'runOrRaise "firefox"'; but it's possible
that there's someone who is doing shell scripting in the argument and
so whose binding would be broken by this. So this is a heads up for
them.
The 4th and fifth patches are because I discovered that when Emacs is
passed "" as an argument, it either bombs out or opens a new file by
that name. (I'm not clear how the latter is possible...) The problem
is the old version of safeSpawn only took a String, and not a
[String]. I could've added a check for "", but it's more principled to
express the need directly.
This, unfortunately, breaks 2 configs and a number of modules. The
fifth patch fixes the modules, but I cannot do anything about Sean or
31d1's configs. (But at least it's easy to update callers.)
Mon Jun 22 15:28:31 EDT 2009 gwern0 at gmail.com
* XMonad.Actions.WindowGo: improve haddocks
{
hunk ./XMonad/Actions/WindowGo.hs 72
- user. Currently, there are three such useful booleans defined in
- "XMonad.ManageHook": title, resource, className. Each one
tests based pretty
+ user. Currently, there are 3 such useful booleans defined in
+ "XMonad.ManageHook": 'title', 'resource', 'className'. Each
one tests based pretty
hunk ./XMonad/Actions/WindowGo.hs 75
- useful of which is (=?). So a useful test might be finding a
Window whose
+ useful of which is (=?). So a useful test might be finding a
@Window@ whose
hunk ./XMonad/Actions/WindowGo.hs 138
- if your variables are simple and look like 'firefox' or 'emacs'. -}
+ if your variables are simple and look like \"firefox\" or
\"emacs\". -}
hunk ./XMonad/Actions/WindowGo.hs 143
-{- | if the window is found the window is focused and the third
argument is called
+{- | If the window is found the window is focused and the third
argument is called
hunk ./XMonad/Actions/WindowGo.hs 145
- See 'raiseMaster' for an example -}
+ See 'raiseMaster' for an example. -}
hunk ./XMonad/Actions/WindowGo.hs 154
-{- | if the window is found the window is focused and the third
argument is called
- otherwise, raisef is called -}
+{- | If a window matching the second arugment is found, the
window is focused and the third argument is called;
+ otherwise, the first argument is called. -}
hunk ./XMonad/Actions/WindowGo.hs 160
- otherwise, the first argument is called
+ otherwise, the first argument is called.
hunk ./XMonad/Actions/WindowGo.hs 162
- raiseMaster (runInTerm \"-title ghci\" \"zsh -c \'ghci\'\")
(title =? \"ghci\") -}
+ > raiseMaster (runInTerm \"-title ghci\" \"zsh -c
\'ghci\'\") (title =? \"ghci\") -}
hunk ./XMonad/Actions/WindowGo.hs 166
-{- | if the window is found the window is focused and set to master
- otherwise, action is run
+{- | If the window is found the window is focused and set to master
+ otherwise, action is run.
hunk ./XMonad/Actions/WindowGo.hs 169
- runOrRaiseMaster \"firefox\" (className =? \"Firefox\")) $
+ > runOrRaiseMaster \"firefox\" (className =? \"Firefox\")) $
}
Shall I push this patch? (3/5) [ynWsfvplxdaqjk], or ? for help: y
Mon Jun 22 15:30:18 EDT 2009 gwern0 at gmail.com
* XMonad.Util.Run: +convenience function for safeSpawn which drops
args to the prog
{
hunk ./XMonad/Util/Run.hs 24
+ safeSpawnProg,
hunk ./XMonad/Util/Run.hs 113
+-- | Like 'safeSpawn', but only takes a program (and no arguments
for it). eg.
+--
+-- > safeSpawnProg "firefox"
+safeSpawnProg :: MonadIO m => FilePath -> m ()
+safeSpawnProg = flip safeSpawn ""
+
}
Shall I push this patch? (4/5) [ynWsfvplxdaqjk], or ? for help: y
Mon Jun 22 15:32:55 EDT 2009 gwern0 at gmail.com
* XMonad.Actions.WindowGo: switch to safeSpawn, since everyone just
passes a prog name (no shell scripting)
{
hunk ./XMonad/Actions/WindowGo.hs 37
-import XMonad (Query(), X(), withWindowSet, spawn, runQuery, liftIO)
+import XMonad (Query(), X(), withWindowSet, runQuery, liftIO)
hunk ./XMonad/Actions/WindowGo.hs 43
+import XMonad.Util.Run (safeSpawnProg)
hunk ./XMonad/Actions/WindowGo.hs 63
--- | 'action' is an executable to be run via 'spawn' (of
"XMonad.Core") if the Window cannot be found.
+-- | 'action' is an executable to be run via 'safeSpawnProg' (of
"XMonad.Util.Run") if the Window cannot be found.
hunk ./XMonad/Actions/WindowGo.hs 66
-runOrRaise = raiseMaybe . spawn
+runOrRaise = raiseMaybe . safeSpawnProg
hunk ./XMonad/Actions/WindowGo.hs 107
-runOrRaiseNext = raiseNextMaybe . spawn
+runOrRaiseNext = raiseNextMaybe . safeSpawnProg
hunk ./XMonad/Actions/WindowGo.hs 158
-runOrRaiseAndDo = raiseAndDo . spawn
+runOrRaiseAndDo = raiseAndDo . safeSpawnProg
}
- -- Mon Jun 22 16:14:01 EDT 2009 gwern0 at gmail.com
* XMonad.Util.Run: improve definition so this can be used with emacs
{
hunk ./XMonad/Util/Run.hs 110
-safeSpawn :: MonadIO m => FilePath -> String -> m ()
-safeSpawn prog arg = liftIO (try (forkProcess $ executeFile prog
True [arg] Nothing) >> return ())
+safeSpawn :: MonadIO m => FilePath -> [String] -> m ()
+safeSpawn prog args = liftIO (try (forkProcess $ executeFile prog
True args Nothing) >> return ())
hunk ./XMonad/Util/Run.hs 117
-safeSpawnProg = flip safeSpawn ""
+safeSpawnProg = flip safeSpawn []
hunk ./XMonad/Util/Run.hs 130
-safeRunInTerm options command = asks (terminal . config) >>= \t
- -> safeSpawn t (options ++ " -e " ++ command)
+safeRunInTerm options command = asks (terminal . config) >>= \t
- -> safeSpawn t [options, " -e " ++ command]
}
Shall I push this patch? (3/4) [ynWsfvplxdaqjk], or ? for help: y
Mon Jun 22 16:14:23 EDT 2009 gwern0 at gmail.com
* update callers of safeSpawn
{
hunk ./XMonad/Actions/Search.hs 234
-search browser site query = safeSpawn browser $ site query
+search browser site query = safeSpawn browser [site query]
hunk ./XMonad/Prompt/Shell.hs 80
- where run = safeSpawn c . encodeOutput
+ where run = safeSpawn c . return . encodeOutput
hunk ./XMonad/Util/XSelection.hs 132
-safePromptSelection app = join $ io $ liftM (safeSpawn app) getSelection
+safePromptSelection app = join $ io $ liftM (safeSpawn app .
return) getSelection
hunk ./XMonad/Util/XSelection.hs 139
-transformPromptSelection f app = join $ io $ liftM (safeSpawn
app) (fmap f getSelection)
+transformPromptSelection f app = join $ io $ liftM (safeSpawn app
. return) (fmap f getSelection)
}
- --
gwern
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEAREKAAYFAko/5xQACgkQvpDo5Pfl1oIpcgCfV41W93RDc/aOS7VjE2ZmFZ5y
wfoAn0H5YlagUmFwNbnSGjyuYzRq4wXA
=zeQZ
-----END PGP SIGNATURE-----
More information about the xmonad
mailing list