From a3f4c3b13592161ce759aa3b587a20240ef5eb44 Mon Sep 17 00:00:00 2001 From: Michal Minář Date: Sun, 12 Feb 2017 14:48:26 +0100 Subject: Simplified digraph complete function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Minář --- src/XMonad/Local/Prompt.hs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/XMonad/Local/Prompt.hs b/src/XMonad/Local/Prompt.hs index 5734fc8..315e2a7 100644 --- a/src/XMonad/Local/Prompt.hs +++ b/src/XMonad/Local/Prompt.hs @@ -34,13 +34,17 @@ digraphCompletionFunction ∷ String → IO [String] digraphCompletionFunction = return . gen where gen ∷ String → [String] - gen [] = [x:"?" | x <- digraphChars] - gen [x] | x `elem` digraphChars = [[x, y] | y <- '_':digraphChars] - | otherwise = [] - gen [x, y] | x `elem` digraphChars - && y `elem` ('_':digraphChars) = [[x, y]] - | otherwise = [] - gen _ = [] + gen [] = [x:"?" | x <- digraphChars] + gen [x] | isValid 0 x = [[x, y] | y <- '_':digraphChars] + | otherwise = [] + gen [x, y] | isValid 0 x && isValid 1 y = [[x, y]] + | otherwise = [] + gen _ = [] + + isValid :: Int -> Char -> Bool + isValid 0 c = c `elem` digraphChars + isValid 1 c = c `elem` ('_':digraphChars) + isValid _ _ = False vimEchoDigraphConfig ∷ String vimEchoDigraphConfig = unlines [ -- cgit