Remove manual fuzzy matching, and use the dedicated module

This commit is contained in:
Martin Potier 2023-08-03 09:12:05 +03:00
parent db58691676
commit 6070398070
No known key found for this signature in database
GPG key ID: D4DD957DBA4AD89E

View file

@ -4,11 +4,12 @@ module KeyBindings (
) where
import Control.Monad (void)
import Data.Foldable (forM_)
import Data.List (sort, isSuffixOf)
import Data.Maybe (isJust)
import Graphics.X11.Types
import System.Exit
import Text.EditDistance
-- import Text.EditDistance
import XMonad
import XMonad.Actions.CopyWindow (kill1,copy)
import XMonad.Actions.CycleWS
@ -18,6 +19,7 @@ import XMonad.Layout.ToggleLayouts
import XMonad.Operations
import XMonad.Prompt
import XMonad.Prompt.ConfirmPrompt
import XMonad.Prompt.FuzzyMatch
import XMonad.Prompt.Shell
import XMonad.Prompt.Workspace (workspacePrompt)
import XMonad.Util.EZConfig
@ -107,18 +109,20 @@ promptConfig = def
, font = "xft:Iosevka Samae:style=Regular:size=10:charwidth=6.5"
, height = 24
, promptBorderWidth = 5
-- Fuzzysearch by default
, searchPredicate = fuzzyMatch
, sorter = fuzzySort
}
-- Slightly taken from
-- https://mail.haskell.org/pipermail/xmonad/2010-October/010671.html
data FuzzySpawn = FuzzySpawn deriving (Read, Show)
instance XPrompt FuzzySpawn where showXPrompt _ = "RunC: "
fuzzyPrompt config = do
cmds <- io getCommands
let compl s
| null s = []
| otherwise = let weight c = levenshteinDistance defaultEditCosts s c
in map snd $ take 20 $ sort $ map (\c -> (weight c,c)) cmds
mkXPrompt FuzzySpawn config (return . compl) spawn
-- https://github.com/MasseR/xmonad-masser/blob/master/src/XMonad/Password.hs
-- -- Slightly taken from
-- -- https://mail.haskell.org/pipermail/xmonad/2010-October/010671.html
-- data FuzzySpawn = FuzzySpawn deriving (Read, Show)
-- instance XPrompt FuzzySpawn where showXPrompt _ = "RunC: "
-- fuzzyPrompt config = do
-- cmds <- io getCommands
-- let compl s
-- | null s = []
-- | otherwise = let weight c = levenshteinDistance defaultEditCosts s c
-- in map snd $ take 20 $ sort $ map (\c -> (weight c,c)) cmds
-- mkXPrompt FuzzySpawn config (return . compl) spawn
--