Permalink
Browse files

Removed automation of Cmd events

  • Loading branch information...
1 parent d433add commit 9215e4de2998b45d26babf794e483cd84daa0f4e @monokrome committed Apr 12, 2012
Showing with 17 additions and 41 deletions.
  1. +12 −41 vimpy/autocommands.py
  2. +5 −0 vimpy/plugins.py
View
@@ -1,15 +1,14 @@
+# Defines a map which relates handler method names to autocommand event names.
+# Autocommand event names must be provided in the same exact caps as provided
+# in the documentation, or unpredictable behavior will occur within Vim.
autocommands_map = {
'pre_stdin_read': 'StdinReadPre',
'post_buf_write': 'BufWritePost',
'focus_lost': 'FocusLost',
'cursor_moved_i': 'CursorMovedI',
'pre_file_read': 'FileReadPre',
'file_type': 'FileType',
-
-# TODO: Implement Cmd-events, which require that these actions are taken by Python
-# instead of Vim.
-# 'buf_write_cmd': 'BufWriteCmd',
-
+ 'buf_write_cmd': 'BufWriteCmd',
'pre_buf_read': 'BufReadPre',
'term_response': 'TermResponse',
'buf_new_fil': 'BufNewFile',
@@ -33,11 +32,7 @@
'post_file_changed_shell': 'FileChangedShellPost',
'guienter': 'GUIEnter',
'insert_enter': 'InsertEnter',
-
-# TODO: Implement Cmd-events, which require that these actions are taken by Python
-# instead of Vim.
-# 'source_cmd': 'SourceCmd',
-
+ 'source_cmd': 'SourceCmd',
'post_file_read': 'FileReadPost',
'buf_win_leave': 'BufWinLeave',
'insert_change': 'InsertChange',
@@ -49,16 +44,9 @@
'cursor_hold': 'CursorHold',
'func_undefined': 'FuncUndefined',
'spell_file_missing': 'SpellFileMissing',
-
-# TODO: Implement Cmd-events, which require that these actions are taken by Python
-# instead of Vim.
-# 'pre_quick_fix_cmd': 'QuickFixCmdPre',
-
+ 'pre_quick_fix_cmd': 'QuickFixCmdPre',
'pre_filter_read': 'FilterReadPre',
-
-# TODO: Implement Cmd-events, which require that these actions are taken by Python
-# instead of Vim.
-# 'post_shell_cmd': 'ShellCmdPost',
+ 'post_shell_cmd': 'ShellCmdPost',
'cursor_moved': 'CursorMoved',
'post_session_load': 'SessionLoadPost',
'pre_filter_write': 'FilterWritePre',
@@ -68,40 +56,23 @@
'user': 'User',
'color_scheme': 'ColorScheme',
'cmdwin_enter': 'CmdwinEnter',
-
-# TODO: Implement Cmd-events, which require that these actions are taken by Python
-# instead of Vim.
-# 'file_append_cmd': 'FileAppendCmd',
-# 'file_write_cmd': 'FileWriteCmd',
-
+ 'file_append_cmd': 'FileAppendCmd',
+ 'file_write_cmd': 'FileWriteCmd',
'post_filter_read': 'FilterReadPost',
-
-# TODO: Implement Cmd-events, which require that these actions are taken by Python
-# instead of Vim.
-# 'buf_read_cmd': 'BufReadCmd',
-
+ 'buf_read_cmd': 'BufReadCmd',
'buf_enter': 'BufEnter',
'focus_gained': 'FocusGained',
-
-# TODO: Implement Cmd-events, which require that these actions are taken by Python
-# instead of Vim.
-# 'file_read_cmd': 'FileReadCmd',
-
+ 'file_read_cmd': 'FileReadCmd',
'pre_file_write': 'FileWritePre',
'post_stdin_read': 'StdinReadPost',
-
'syntax': 'Syntax',
'cursor_hold_i': 'CursorHoldI',
'vim_enter': 'VimEnter',
'win_leave': 'WinLeave',
'post_buf_read': 'BufReadPost',
'remote_reply': 'RemoteReply',
'post_buf_file': 'BufFilePost',
-
-# TODO: Implement Cmd-events, which require that these actions are taken by Python
-# instead of Vim.
-# 'post_quick_fix_cmd': 'QuickFixCmdPost',
-
+ 'post_quick_fix_cmd': 'QuickFixCmdPost',
'encoding_changed': 'EncodingChanged',
'swap_exists': 'SwapExists',
'pre_file_append': 'FileAppendPre',
View
@@ -11,6 +11,11 @@ def call_observers(event_name):
vim.command("python from vimpy.plugins import call_observers")
for command in autocommands_map:
+ # Automating Cmd-Events is bad news. These must instead
+ # be bound manually by the plugin.
+ if autocommands_map[command][-3:] == 'Cmd':
+ continue
+
au_command = 'autocmd {0} * :python call_observers("{0}");'.format(autocommands_map[command])
vim.command(au_command)

0 comments on commit 9215e4d

Please sign in to comment.