prompt completion: case-sensitivity

Provide a way to perform case-insensitive file / directory completion.
We're using compgen to generate completion candidates, and this is
case-sensitive by default. We can control this by setting the
completion-ignore-case Readline variable prior to invoking compgen. If
we're running a Bash with Readline support, this works as expected.
Otherwise, it has no effect -- completion candidates are still returned,
but compgen generates them in a case-sensitive manner.

To avoid breaking changes, the signatures and behavior of existing
exported functions are unchanged:
  - XMonad.Layout.WorkspaceDir.changeDir
  - XMonad.Prompt.Directory.directoryPrompt
  - XMonad.Prompt.Shell.getShellCompl

New variations of these functions are provided, allowing the caller
to specify the desired case-sensitivity via a ComplCaseSensitivity
argument:
  - XMonad.Layout.WorkspaceDir.changeDir'
  - XMonad.Prompt.Directory.directoryPrompt'
  - XMonad.Prompt.Shell.getShellCompl'

The XMonad.Prompt.Shell exports a couple new functions:
  - compgenDirectories
  - compgenFiles

We make use of this in XMonad.Prompt.Directory to avoid duplicating the
compgen code.
This commit is contained in:
ivanbrennan
2020-09-14 17:01:09 -04:00
parent b5105381bf
commit 795be75a58
4 changed files with 45 additions and 13 deletions

View File

@@ -60,6 +60,7 @@ module XMonad.Prompt
, moveHistory, setSuccess, setDone, setModeDone
, Direction1D(..)
, ComplFunction
, ComplCaseSensitivity(..)
-- * X Utilities
-- $xutils
, mkUnmanagedWindow
@@ -200,6 +201,8 @@ type ComplFunction = String -> IO [String]
type XPMode = XPType
data XPOperationMode = XPSingleMode ComplFunction XPType | XPMultipleModes (W.Stack XPType)
newtype ComplCaseSensitivity = ComplCaseSensitive Bool
instance Show XPType where
show (XPT p) = showXPrompt p