[commit: haskeline] master: Fix #115: make the "df" and "dt" commands behave as in vim and readline. (b30bf5d)
Ian Lynagh
igloo at earth.li
Wed Oct 19 16:12:01 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/haskeline
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/b30bf5d22007526483fe961504f5bcf8b7052f46
>---------------------------------------------------------------
commit b30bf5d22007526483fe961504f5bcf8b7052f46
Author: Judah Jacobson <judah.jacobson at gmail.com>
Date: Sun Oct 16 21:28:29 2011 +0000
Fix #115: make the "df" and "dt" commands behave as in vim and readline.
>---------------------------------------------------------------
System/Console/Haskeline/Vi.hs | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/System/Console/Haskeline/Vi.hs b/System/Console/Haskeline/Vi.hs
index 28a7e16..c5618cb 100644
--- a/System/Console/Haskeline/Vi.hs
+++ b/System/Console/Haskeline/Vi.hs
@@ -144,27 +144,34 @@ repeatedCommands = choiceCmd [argumented, doBefore noArg repeatableCommands]
]
pureMovements :: InputKeyCmd (ArgMode CommandMode) CommandMode
-pureMovements = choiceCmd $
- map mkCharCommand charMovements
- ++ map mkSimpleCommand movements
+pureMovements = choiceCmd $ charMovements ++ map mkSimpleCommand movements
where
+ charMovements = [ charMovement 'f' $ \c -> goRightUntil $ overChar (==c)
+ , charMovement 'F' $ \c -> goLeftUntil $ overChar (==c)
+ , charMovement 't' $ \c -> goRightUntil $ beforeChar (==c)
+ , charMovement 'T' $ \c -> goLeftUntil $ afterChar (==c)
+ ]
mkSimpleCommand (k,move) = k +> change (applyCmdArg move)
- mkCharCommand (k,move) = k +> keyChoiceCmd [
+ charMovement c move = simpleChar c +> keyChoiceCmd [
useChar (change . applyCmdArg . move)
, withoutConsuming (change argState)
]
useMovementsForKill :: Command m s t -> (KillHelper -> Command m s t) -> KeyCommand m s t
useMovementsForKill alternate useHelper = choiceCmd $
- map mkCharCommand charMovements
- ++ specialCases
+ specialCases
++ map (\(k,move) -> k +> useHelper (SimpleMove move)) movements
where
specialCases = [ simpleChar 'e' +> useHelper (SimpleMove goToWordDelEnd)
, simpleChar 'E' +> useHelper (SimpleMove goToBigWordDelEnd)
, simpleChar '%' +> useHelper (GenericKill deleteMatchingBrace)
+ -- Note 't' and 'f' behave differently than in pureMovements.
+ , charMovement 'f' $ \c -> goRightUntil $ afterChar (==c)
+ , charMovement 'F' $ \c -> goLeftUntil $ overChar (==c)
+ , charMovement 't' $ \c -> goRightUntil $ overChar (==c)
+ , charMovement 'T' $ \c -> goLeftUntil $ afterChar (==c)
]
- mkCharCommand (k,move) = k +> keyChoiceCmd [
+ charMovement c move = simpleChar c +> keyChoiceCmd [
useChar (useHelper . SimpleMove . move)
, withoutConsuming alternate]
@@ -275,13 +282,6 @@ movements = [ (simpleChar 'h', goLeft)
, (simpleChar 'E', goRightUntil (atEnd isBigWordChar))
]
-charMovements :: [(Key, Char -> InsertMode -> InsertMode)]
-charMovements = [ (simpleChar 'f', \c -> goRightUntil $ overChar (==c))
- , (simpleChar 'F', \c -> goLeftUntil $ overChar (==c))
- , (simpleChar 't', \c -> goRightUntil $ beforeChar (==c))
- , (simpleChar 'T', \c -> goLeftUntil $ afterChar (==c))
- ]
-
{-
From IEEE 1003.1:
A "bigword" consists of: a maximal sequence of non-blanks preceded and followed by blanks
More information about the Cvs-libraries
mailing list