finishRecordingMacroBinding :: VimBinding
finishRecordingMacroBinding = VimBindingE (f . T.unpack . _unEv)
    where f "q" (VimState { vsMode = Normal
                          , vsCurrentMacroRecording = Just (macroName, Ev macroBody) })
                = WholeMatch $ do
                      let reg = Register Exclusive (R.fromText (T.drop 2 macroBody))
                      modifyStateE $ \s ->
                          s { vsCurrentMacroRecording = Nothing
                              , vsRegisterMap = singleton macroName reg
                                              <> vsRegisterMap s
                              }
                      return Finish
          f _ _ = NoMatch
finishRecordingMacroBinding :: VimBinding
finishRecordingMacroBinding = VimBindingE (f . T.unpack . _unEv)
    where f "q" (VimState { vsMode = Normal
                          , vsCurrentMacroRecording = Just (macroName, Ev macroBody) })
                = WholeMatch $ do
                      let reg = Register Exclusive (R.fromText (T.drop 2 macroBody))
                      modifyStateE $ \s ->
                          s { vsCurrentMacroRecording = Nothing
                              , vsRegisterMap = singleton macroName reg
                                              <> vsRegisterMap s
                              }
                      return Finish
          f _ _ = NoMatch
finishRecordingMacroBinding = VimBindingE (f . T.unpack . _unEv)
    where f "q" (VimState { vsMode = Normal
                          , vsCurrentMacroRecording = Just (macroName, Ev macroBody) })
                = WholeMatch $ do
                      let reg = Register Exclusive (R.fromText (T.drop 2 macroBody))
                      modifyStateE $ \s ->
                          s { vsCurrentMacroRecording = Nothing
                              , vsRegisterMap = singleton macroName reg
                                              <> vsRegisterMap s
                              }
                      return Finish
          f _ _ = NoMatch