Hi! I improved percent move in Vim keymap -- now it's inclusive, and works as expected if there is no paren in cursor (very helpful for deleting function calls and array lookups in C).
Cavetas: it should somehow raport failure (instead of just staying in place) if match not found (findmatchlimit just returns NULL). With this implementation 'd%' on line without parens does the same stuff as 'x'. How should we approach fixing it? Should we add data ViMove = -- ... + | PossibleArbMove (BufferM (Bool)) With boolean value saying if move has succeeded or not? Cheers, -- Krzysiek --~--~---------~--~----~------------~-------~--~----~ Yi development mailing list yi-devel@googlegroups.com http://groups.google.com/group/yi-devel -~----------~----~----~----~------~----~------~--~---
Tue Dec 2 17:21:05 CET 2008 Krzysztof Goj <[EMAIL PROTECTED]> * Better percent move. New patches: [Better percent move. Krzysztof Goj <[EMAIL PROTECTED]>**20081202162105] hunk ./Yi/Keymap/Vim.hs 173 gen_cmd_move :: KeymapM (RegionStyle, ViMove) gen_cmd_move = choice [ char '0' ?>> return (Exclusive, viMoveToSol) - , char '%' ?>> return (Exclusive, ArbMove (do - c <- readB - case c of '(' -> goUnmatchedB Forward '(' ')' - ')' -> goUnmatchedB Backward '(' ')' - '{' -> goUnmatchedB Forward '{' '}' - '}' -> goUnmatchedB Backward '{' '}' - '[' -> goUnmatchedB Forward '[' ']' - ']' -> goUnmatchedB Backward '[' ']' - _ -> fail $ "Not matchable character: " ++ [c])) + , char '%' ?>> return percentMove , do cnt <- count let x = maybe 1 id cnt hunk ./Yi/Keymap/Vim.hs 1049 beginIns :: (Show x, YiAction a x) => ModeMap -> a -> I Event Action () beginIns self a = write a >> ins_mode self +-- Find the item after or under the cursor and jump to its match +percentMove :: (RegionStyle, ViMove) +percentMove = (Inclusive, ArbMove tryGoingToMatch) + where tryGoingToMatch = do + p <- pointB + foundMatch <- goToMatch + when (not foundMatch) $ moveTo p + return () + go dir a b = goUnmatchedB dir a b >> return True + goToMatch = do + c <- readB + case c of '(' -> go Forward '(' ')' + ')' -> go Backward '(' ')' + '{' -> go Forward '{' '}' + '}' -> go Backward '{' '}' + '[' -> go Forward '[' ']' + ']' -> go Backward '[' ']' + _ -> otherChar + otherChar = do eof <- atEof + eol <- atEol + if (eof || eol) + then return False + else rightB >> goToMatch -- search for matchable character after the cursor + -- -------------------- -- | Keyword kwd_mode :: VimMode Context: [replace all: more helpful message [EMAIL PROTECTED] [fix build [EMAIL PROTECTED] [Better word and WORD motions for Vim keymap. Krzysztof Goj <[EMAIL PROTECTED]>**20081202132813] [doc [EMAIL PROTECTED] [Yi/Users/Gwern.hs: +shorter binding for gotoLn [EMAIL PROTECTED] Ignore-this: 5defc56344c3e1c61bd602d192e06af3 I find the default Emacs binding of M-g g tedious; why not just M-g? ] [doc [EMAIL PROTECTED] [make Accessor instance of Category [EMAIL PROTECTED] [use Control.Category [EMAIL PROTECTED] [Yi.Keymap.Emacs: +standard emacs M-; binding [EMAIL PROTECTED] Ignore-this: 5abf2d7154acfdcce44286f34ec238b9 ] [update to base>=4; replace all Control.Exception with Control.OldException [EMAIL PROTECTED] Ignore-this: 205b7c23a4ffcc16b8612d0b4edc9352 ] [better support for vivid colors [EMAIL PROTECTED] [Main.hs: minor indent [EMAIL PROTECTED] Ignore-this: b53fd55beb556c92b6bba9ee4a49cd61 ] [added C-w and C-u to ex mode Aleksandar Dimitrov <[EMAIL PROTECTED]>**20081201103414] ['ZZ' closes window, not editor, 'ZQ' == ':q!' Aleksandar Dimitrov <[EMAIL PROTECTED]>**20081201103311] [bump version number [EMAIL PROTECTED] [TAG 0.5.2 [EMAIL PROTECTED] Patch bundle hash: 9e9643f5cb208099e5164b3ec9540e908c5f102d