Hello I have written a plugin[1] for Vim that enables relative line numbers for pending operations. Unfortunately it's kinda messy to get to 'know' when an operation is pending and when it is executed. You have to remap every operator-command to call your specific plugin function (something like: nnoremap d :call MyFunc()<CR>d). Of course this leads to the problem that you cannot use more than one plugin that needs to know when you are in operation- pending mode. Additionally you somehow need to remap operations that come from other plugins.
A much more elegant solution would be to have an event to be called when an operation is pending. I've looked at the Vim code and added the following three autocommands: - OperationPending: is executed when an operation is called which needs a motion. - OperationExecuted: is executed after the pending operation was executed (i.e. a motion or a second keystroke like yy, dd etc. is passed). - OperationCleared: is executed after every command that doesn't enter operation-pending-mode. (executed after OperationExecuted) I hope you see the reasoning behind my request and add my patch to Vim. I haven't found any hint about your preferred patch format, so I just attached the 'hg diff' output. Best regards, Mohammed [1] http://www.vim.org/scripts/script.php?script_id=4212 -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
diff -r b042d04009d4 runtime/doc/autocmd.txt --- a/runtime/doc/autocmd.txt Sat Oct 06 19:10:36 2012 +0200 +++ b/runtime/doc/autocmd.txt Wed Oct 10 21:21:11 2012 +0200 @@ -314,6 +314,9 @@ |SessionLoadPost| after loading a session file |MenuPopup| just before showing the popup menu +|OperationPending| after a pending operation is called +|OperationExecuted| after a motion is passed to a pending operation +|OperationCleared| after a non-|operator| command is called |CompleteDone| after Insert mode completion is done |User| to be used in combination with ":doautocmd" @@ -707,6 +710,16 @@ o Operator-pending i Insert c Command line + *OperationPending* +OperationPending When Vim waits for a motion after an + |operator| command. + *OperationExecuted* +OperationExecuted When a pending operation is executed. I.e. a + motion is passed or the operator is pressed a + second time (dd, cc, yy etc.). + *OperationCleared* +OperationCleared After a pending operation is either executed + or canceled or after any non-operator command. *QuickFixCmdPre* QuickFixCmdPre Before a quickfix command is run (|:make|, |:lmake|, |:grep|, |:lgrep|, |:grepadd|, diff -r b042d04009d4 runtime/doc/tags --- a/runtime/doc/tags Sat Oct 06 19:10:36 2012 +0200 +++ b/runtime/doc/tags Wed Oct 10 21:21:11 2012 +0200 @@ -4376,6 +4376,9 @@ OS390-open-source os_390.txt /*OS390-open-source* OffTheSpot mbyte.txt /*OffTheSpot* OnTheSpot mbyte.txt /*OnTheSpot* +OperationCleared autocmd.txt /*OperationCleared* +OperationExecuted autocmd.txt /*OperationExecuted* +OperationPending autocmd.txt /*OperationPending* Operator-pending intro.txt /*Operator-pending* Operator-pending-mode intro.txt /*Operator-pending-mode* OverTheSpot mbyte.txt /*OverTheSpot* diff -r b042d04009d4 runtime/syntax/vim.vim --- a/runtime/syntax/vim.vim Sat Oct 06 19:10:36 2012 +0200 +++ b/runtime/syntax/vim.vim Wed Oct 10 21:21:11 2012 +0200 @@ -1,7 +1,7 @@ " Vim syntax file " Language: Vim 7.3 script " Maintainer: Dr. Charles E. Campbell, Jr. <[email protected]> -" Last Change: Jan 11, 2012 +" Last Change: Oct 10, 2012 " Version: 7.3-13 " Automatically generated keyword lists: {{{1 @@ -63,7 +63,7 @@ " AutoCmd Events {{{2 syn case ignore -syn keyword vimAutoEvent contained BufAdd BufCreate BufDelete BufEnter BufFilePost BufFilePre BufHidden BufLeave BufNew BufNewFile BufRead BufReadCmd BufReadPost BufReadPre BufUnload BufWinEnter BufWinLeave BufWipeout BufWrite BufWriteCmd BufWritePost BufWritePre Cmd-event CmdwinEnter CmdwinLeave ColorScheme CursorHold CursorHoldI CursorMoved CursorMovedI EncodingChanged FileAppendCmd FileAppendPost FileAppendPre FileChangedRO FileChangedShell FileChangedShellPost FileEncoding FileReadCmd FileReadPost FileReadPre FileType FileWriteCmd FileWritePost FileWritePre FilterReadPost FilterReadPre FilterWritePost FilterWritePre FocusGained FocusLost FuncUndefined GUIEnter GUIFailed InsertChange InsertCharPre InsertEnter InsertLeave MenuPopup QuickFixCmdPost QuickFixCmdPre RemoteReply SessionLoadPost ShellCmdPost ShellFilterPost SourceCmd SourcePre SpellFileMissing StdinReadPost StdinReadPre SwapExists Syntax TabEnter TabLeave TermChanged TermResponse User UserGettingBored VimEnter VimLeave VimLeavePre VimResized WinEnter WinLeave +syn keyword vimAutoEvent contained BufAdd BufCreate BufDelete BufEnter BufFilePost BufFilePre BufHidden BufLeave BufNew BufNewFile BufRead BufReadCmd BufReadPost BufReadPre BufUnload BufWinEnter BufWinLeave BufWipeout BufWrite BufWriteCmd BufWritePost BufWritePre Cmd-event CmdwinEnter CmdwinLeave ColorScheme CursorHold CursorHoldI CursorMoved CursorMovedI EncodingChanged FileAppendCmd FileAppendPost FileAppendPre FileChangedRO FileChangedShell FileChangedShellPost FileEncoding FileReadCmd FileReadPost FileReadPre FileType FileWriteCmd FileWritePost FileWritePre FilterReadPost FilterReadPre FilterWritePost FilterWritePre FocusGained FocusLost FuncUndefined GUIEnter GUIFailed InsertChange InsertCharPre InsertEnter InsertLeave MenuPopup OperationCleared OperationExecuted OperationPending QuickFixCmdPost QuickFixCmdPre RemoteReply SessionLoadPost ShellCmdPost ShellFilterPost SourceCmd SourcePre SpellFileMissing StdinReadPost StdinReadPre SwapExists Syntax TabEnter TabLeave TermChanged TermResponse User UserGettingBored VimEnter VimLeave VimLeavePre VimResized WinEnter WinLeave " Highlight commonly used Groupnames {{{2 syn keyword vimGroup contained Comment Constant String Character Number Boolean Float Identifier Function Statement Conditional Repeat Label Operator Keyword Exception PreProc Include Define Macro PreCondit Type StorageClass Structure Typedef Special SpecialChar Tag Delimiter SpecialComment Debug Underlined Ignore Error Todo diff -r b042d04009d4 src/fileio.c --- a/src/fileio.c Sat Oct 06 19:10:36 2012 +0200 +++ b/src/fileio.c Wed Oct 10 21:21:11 2012 +0200 @@ -7692,6 +7692,9 @@ {"InsertLeave", EVENT_INSERTLEAVE}, {"InsertCharPre", EVENT_INSERTCHARPRE}, {"MenuPopup", EVENT_MENUPOPUP}, + {"OperationPending",EVENT_OPERATIONPENDING}, + {"OperationExecuted",EVENT_OPERATIONEXECUTED}, + {"OperationCleared",EVENT_OPERATIONCLEARED}, {"QuickFixCmdPost", EVENT_QUICKFIXCMDPOST}, {"QuickFixCmdPre", EVENT_QUICKFIXCMDPRE}, {"QuitPre", EVENT_QUITPRE}, diff -r b042d04009d4 src/normal.c --- a/src/normal.c Sat Oct 06 19:10:36 2012 +0200 +++ b/src/normal.c Wed Oct 10 21:21:11 2012 +0200 @@ -618,6 +618,13 @@ # endif } #endif + // If an operator is pending execute autocmd OperationPending +#ifdef FEAT_AUTOCMD + if (finish_op) + { + apply_autocmds(EVENT_OPERATIONPENDING, NULL, NULL, FALSE, curbuf); + } +#endif /* When not finishing an operator and no register name typed, reset the * count. */ @@ -2211,6 +2218,10 @@ #ifdef FEAT_VISUAL oap->block_mode = FALSE; #endif + // execute autocmd OperationExecuted +#ifdef FEAT_AUTOCMD + apply_autocmds(EVENT_OPERATIONEXECUTED, NULL, NULL, FALSE, curbuf); +#endif clearop(oap); } } @@ -3778,6 +3789,9 @@ oap->regname = 0; oap->motion_force = NUL; oap->use_reg_one = FALSE; +#ifdef FEAT_AUTOCMD + apply_autocmds(EVENT_OPERATIONCLEARED, NULL, NULL, FALSE, curbuf); +#endif } static void diff -r b042d04009d4 src/vim.h --- a/src/vim.h Sat Oct 06 19:10:36 2012 +0200 +++ b/src/vim.h Wed Oct 10 21:21:11 2012 +0200 @@ -1289,6 +1289,9 @@ EVENT_CURSORHOLD, /* cursor in same position for a while */ EVENT_CURSORHOLDI, /* idem, in Insert mode */ EVENT_FUNCUNDEFINED, /* if calling a function which doesn't exist */ + EVENT_OPERATIONPENDING, /* when an operation is pending */ + EVENT_OPERATIONEXECUTED, /* when a pending operation is executed */ + EVENT_OPERATIONCLEARED, /* after a pending operation is executed or canceled */ EVENT_REMOTEREPLY, /* upon string reception from a remote vim */ EVENT_SWAPEXISTS, /* found existing swap file */ EVENT_SOURCEPRE, /* before sourcing a Vim script */
