To: vim_dev@googlegroups.com Subject: Patch 8.1.2219 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.2219 Problem: No autocommand for open window with terminal. Solution: Add TerminalWinOpen. (Christian Brabandt) Files: runtime/doc/autocmd.txt, src/autocmd.c, src/terminal.c, src/testdir/test_terminal.vim, src/vim.h *** ../vim-8.1.2218/runtime/doc/autocmd.txt 2019-09-16 21:58:08.792800986 +0200 --- runtime/doc/autocmd.txt 2019-10-26 16:08:38.610820276 +0200 *************** *** 268,274 **** |BufCreate| just after adding a buffer to the buffer list |BufDelete| before deleting a buffer from the buffer list |BufWipeout| before completely deleting a buffer - |TerminalOpen| after a terminal buffer was created |BufFilePre| before changing the name of the current buffer |BufFilePost| after changing the name of the current buffer --- 268,273 ---- *************** *** 302,307 **** --- 301,310 ---- |VimLeavePre| before exiting Vim, before writing the viminfo file |VimLeave| before exiting Vim, after writing the viminfo file + Terminal + |TerminalOpen| after a terminal buffer was created + |TerminalWinOpen| after a terminal buffer was created in a new window + Various |FileChangedShell| Vim notices that a file changed since editing started |FileChangedShellPost| After handling a file changed since editing started *************** *** 1082,1087 **** --- 1084,1095 ---- `:terminal` or |term_start()|. This event is triggered even if the buffer is created without a window, with the ++hidden option. + *TerminalWinOpen* + TerminalWinOpen Just after a terminal buffer was created, with + `:terminal` or |term_start()|. This event is + triggered only if the buffer is created + with a window. Can be used to set window + local options for the terminal window. *TermResponse* TermResponse After the response to |t_RV| is received from the terminal. The value of |v:termresponse| *** ../vim-8.1.2218/src/autocmd.c 2019-09-16 21:58:08.792800986 +0200 --- src/autocmd.c 2019-10-26 16:08:38.610820276 +0200 *************** *** 174,179 **** --- 174,180 ---- {"TabLeave", EVENT_TABLEAVE}, {"TermChanged", EVENT_TERMCHANGED}, {"TerminalOpen", EVENT_TERMINALOPEN}, + {"TerminalWinOpen", EVENT_TERMINALWINOPEN}, {"TermResponse", EVENT_TERMRESPONSE}, {"TextChanged", EVENT_TEXTCHANGED}, {"TextChangedI", EVENT_TEXTCHANGEDI}, *** ../vim-8.1.2218/src/terminal.c 2019-10-23 23:16:41.657953362 +0200 --- src/terminal.c 2019-10-26 16:08:38.610820276 +0200 *************** *** 690,695 **** --- 690,697 ---- } apply_autocmds(EVENT_TERMINALOPEN, NULL, NULL, FALSE, newbuf); + if (!opt->jo_hidden && !(flags & TERM_START_SYSTEM)) + apply_autocmds(EVENT_TERMINALWINOPEN, NULL, NULL, FALSE, newbuf); return newbuf; } *** ../vim-8.1.2218/src/testdir/test_terminal.vim 2019-10-20 21:15:07.457905609 +0200 --- src/testdir/test_terminal.vim 2019-10-26 16:13:21.561663437 +0200 *************** *** 68,73 **** --- 68,90 ---- unlet g:job endfunc + func Test_terminal_TerminalWinOpen() + au TerminalWinOpen * let b:done = 'yes' + let buf = Run_shell_in_terminal({}) + call assert_equal('yes', b:done) + call StopShellInTerminal(buf) + " closing window wipes out the terminal buffer with the finished job + close + + if has("unix") + terminal ++hidden ++open sleep 1 + sleep 1 + call assert_fails("echo b:done", 'E121:') + endif + + au! TerminalWinOpen + endfunc + func Test_terminal_make_change() let buf = Run_shell_in_terminal({}) call StopShellInTerminal(buf) *** ../vim-8.1.2218/src/vim.h 2019-10-20 18:17:08.363431719 +0200 --- src/vim.h 2019-10-26 16:08:38.614820260 +0200 *************** *** 1341,1346 **** --- 1341,1347 ---- EVENT_TABNEW, // when entering a new tab page EVENT_TERMCHANGED, // after changing 'term' EVENT_TERMINALOPEN, // after a terminal buffer was created + EVENT_TERMINALWINOPEN, // after a terminal buffer was created and entering its window EVENT_TERMRESPONSE, // after setting "v:termresponse" EVENT_TEXTCHANGED, // text was modified not in Insert mode EVENT_TEXTCHANGEDI, // text was modified in Insert mode *** ../vim-8.1.2218/src/version.c 2019-10-26 14:41:52.426302376 +0200 --- src/version.c 2019-10-26 16:18:08.940352899 +0200 *************** *** 743,744 **** --- 743,746 ---- { /* Add new patch number below this line */ + /**/ + 2219, /**/ -- Female engineers become irresistible at the age of consent and remain that way until about thirty minutes after their clinical death. Longer if it's a warm day. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///