diff --git a/haskell-docs.cabal b/haskell-docs.cabal
--- a/haskell-docs.cabal
+++ b/haskell-docs.cabal
@@ -1,5 +1,5 @@
 name:                haskell-docs
-version:             4.1.0
+version:             4.1.1
 synopsis:            A program to find and display the docs of a name from a
                      given module.
 description:         Given a module name and a name, it will find and display
diff --git a/src/Haskell/Docs.hs b/src/Haskell/Docs.hs
--- a/src/Haskell/Docs.hs
+++ b/src/Haskell/Docs.hs
@@ -1,4 +1,6 @@
+{-# LANGUAGE ViewPatterns #-}
 {-# LANGUAGE TupleSections #-}
+
 -- | Lookup the documentation of a name in a module (and in a specific
 -- package in the case of ambiguity).
 
@@ -8,35 +10,36 @@
   ,PackageName(..))
   where
 
-import Control.Monad
-import Data.List
 import Haskell.Docs.Formatting
 import Haskell.Docs.Haddock
 import Haskell.Docs.Types
 
+import Control.Monad
+import Data.List
+import Data.Ord
 import GHC hiding (verbosity)
 import GhcMonad (liftIO)
-import System.IO
 
 -- -- | Print the documentation of a name in the given module.
 searchAndPrintDoc
-  :: Maybe PackageName -- ^ Package.
+  :: Bool              -- ^ Print modules only.
+  -> Maybe PackageName -- ^ Package.
   -> Maybe ModuleName  -- ^ Module name.
   -> Identifier        -- ^ Identifier.
   -> Ghc ()
-searchAndPrintDoc pname mname ident =
+searchAndPrintDoc ms pname mname ident =
   do (result,printPkg,printModule) <- search
      case result of
        Left err ->
          error (show err)
-       Right docs ->
-         mapM_ (\(i,doc) -> do when (i > 0)
-                                    (liftIO (putStrLn ""))
-                               printIdentDoc printPkg printModule doc)
-               (zip [0..] (nub docs))
+       Right (sortBy (comparing identDocPackageName) -> docs) ->
+         mapM_ (\(i,doc') ->
+                  do when (not ms && i > 0)
+                          (liftIO (putStrLn ""))
+                     printIdentDoc ms printPkg printModule doc')
+               (zip [0::Int ..] (nub docs))
   where search =
           case (pname,mname) of
             (Just p,Just m) -> fmap (,False,False) (searchPackageModuleIdent Nothing p m ident)
             (Nothing,Just m) -> fmap (,True,False) (searchModuleIdent Nothing m ident)
-            (Nothing,Nothing) -> fmap (,True,True) (searchIdent Nothing ident)
-            _ -> error "arguments: <ident> | <module-name> <ident> [<package-name>]"
+            _ -> fmap (,True,True) (searchIdent Nothing ident)
diff --git a/src/Haskell/Docs/Formatting.hs b/src/Haskell/Docs/Formatting.hs
--- a/src/Haskell/Docs/Formatting.hs
+++ b/src/Haskell/Docs/Formatting.hs
@@ -18,11 +18,17 @@
 -- * Formatting
 
 -- | Print an identifier' documentation.
-printIdentDoc :: Bool -- ^ Print package?
+printIdentDoc :: Bool -- ^ Print modules only?
+              -> Bool -- ^ Print package?
               -> Bool -- ^ Print module?
               -> IdentDoc
               -> Ghc ()
-printIdentDoc printPkg printModule idoc =
+printIdentDoc True _ _ idoc =
+  do d <- getSessionDynFlags
+     maybe (return ())
+            (\i -> liftIO (putStrLn (showppr d (moduleName (nameModule (getName i))))))
+            (identDocIdent idoc)
+printIdentDoc _ printPkg printModule idoc =
   do d <- getSessionDynFlags
      when printPkg
           (liftIO (putStrLn ("Package: " ++ showPackageName (identDocPackageName idoc))))
diff --git a/src/main/Main.hs b/src/main/Main.hs
--- a/src/main/Main.hs
+++ b/src/main/Main.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE ViewPatterns #-}
 -- | Main command-line interface.
 
 module Main where
@@ -19,29 +20,43 @@
 
 -- | Do the printing.
 app :: [String] -> IO ()
-app args =
+app (extract -> (gs,ms,as)) =
   withInitializedPackages
-    []
-    (case args of
+    gs
+    (case as of
        [name] ->
-         searchAndPrintDoc Nothing Nothing (Identifier name)
+         searchAndPrintDoc ms
+                           Nothing
+                           Nothing
+                           (Identifier name)
        [mname,name,pname] ->
-         searchAndPrintDoc (Just (PackageName pname))
+         searchAndPrintDoc ms
+                           (Just (PackageName pname))
                            (Just (makeModuleName mname))
                            (Identifier name)
        [mname,name] ->
-         searchAndPrintDoc Nothing
+         searchAndPrintDoc ms
+                           Nothing
                            (Just (makeModuleName mname))
                            (Identifier name)
        _ -> error "<module-name> <ident> [<package-name>] | <ident>")
 
+-- | Extract arguments.
+extract :: [String] -> ([String],Bool,[String])
+extract = go ([],False,[])
+  where go (gs,ms,as) ("-g":arg:ys)    = go (arg:gs,ms,as) ys
+        go (gs,ms,as) ("--modules":ys) = go (gs,True,as) ys
+        go (gs,ms,as) (y:ys)           = go (gs,ms,y:as) ys
+        go (gs,ms,as) []               = (gs,ms,as)
+
 -- | Print an exception for humans.
 printEx :: DocsException -> String
 printEx e =
   case e of
     NoFindModule -> "Couldn't find any packages with that module."
     NoModulePackageCombo -> "Couldn't match a module with that package."
-    NoInterfaceFiles -> "No interface files to search through! Maybe you need to generate documentation for the package?"
+    NoInterfaceFiles -> "No interface files to search through! \
+                        \Maybe you need to generate documentation for the package?"
     NoParseInterfaceFiles reasons -> "Couldn't parse interface files: " ++
                                      unlines (map printEx reasons)
     NoFindNameInExports -> "Couldn't find that name in an export list."
