From 0239acb11fe4bfe9b525ea90b782759da5eb7704 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 11 Apr 2016 21:02:54 +0200 Subject: [PATCH 01/29] patch 7.4.1722 Problem: Crash when calling garbagecollect() after starting a job. Solution: Set the copyID on job and channel. (Hirohito Higashi, Ozaki Kiichi) --- src/eval.c | 2 ++ src/version.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/eval.c b/src/eval.c index 1c5a31658bdd38..0c270b928d4c68 100644 --- a/src/eval.c +++ b/src/eval.c @@ -7326,6 +7326,7 @@ set_ref_in_item( if (job != NULL && job->jv_copyID != copyID) { + job->jv_copyID = copyID; if (job->jv_channel != NULL) { dtv.v_type = VAR_CHANNEL; @@ -7350,6 +7351,7 @@ set_ref_in_item( if (ch != NULL && ch->ch_copyID != copyID) { + ch->ch_copyID = copyID; for (part = PART_SOCK; part <= PART_IN; ++part) { for (jq = ch->ch_part[part].ch_json_head.jq_next; jq != NULL; diff --git a/src/version.c b/src/version.c index ef777cf1643da6..4f8bc2ef5bd2f0 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1722, /**/ 1721, /**/ From f73d3bc253fa79ad220f52f04b93e782e95a9d43 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 11 Apr 2016 21:55:15 +0200 Subject: [PATCH 02/29] patch 7.4.1723 Problem: When using try/catch in 'tabline' it is still considered an error and the tabline will be disabled. Solution: Check did_emsg instead of called_emsg. (haya14busa, closes #746) --- src/screen.c | 8 +++---- src/testdir/test_alot.vim | 1 + src/testdir/test_tabline.vim | 43 ++++++++++++++++++++++++++++++++++++ src/version.c | 2 ++ 4 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 src/testdir/test_tabline.vim diff --git a/src/screen.c b/src/screen.c index dc5d175d8a2597..8044079b52ec90 100644 --- a/src/screen.c +++ b/src/screen.c @@ -10266,16 +10266,16 @@ draw_tabline(void) /* Use the 'tabline' option if it's set. */ if (*p_tal != NUL) { - int save_called_emsg = called_emsg; + int saved_did_emsg = did_emsg; /* Check for an error. If there is one we would loop in redrawing the * screen. Avoid that by making 'tabline' empty. */ - called_emsg = FALSE; + did_emsg = FALSE; win_redr_custom(NULL, FALSE); - if (called_emsg) + if (did_emsg) set_string_option_direct((char_u *)"tabline", -1, (char_u *)"", OPT_FREE, SID_ERROR); - called_emsg |= save_called_emsg; + did_emsg |= saved_did_emsg; } else #endif diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim index 1eb76a6decbec8..7f9a1a78fed8db 100644 --- a/src/testdir/test_alot.vim +++ b/src/testdir/test_alot.vim @@ -24,6 +24,7 @@ source test_set.vim source test_sort.vim source test_statusline.vim source test_syn_attr.vim +source test_tabline.vim source test_timers.vim source test_undolevels.vim source test_unlet.vim diff --git a/src/testdir/test_tabline.vim b/src/testdir/test_tabline.vim new file mode 100644 index 00000000000000..6c7a02d6500164 --- /dev/null +++ b/src/testdir/test_tabline.vim @@ -0,0 +1,43 @@ +function! TablineWithCaughtError() + let s:func_in_tabline_called = 1 + try + call eval('unknown expression') + catch + endtry + return '' +endfunction + +function! TablineWithError() + let s:func_in_tabline_called = 1 + call eval('unknown expression') + return '' +endfunction + +function! Test_caught_error_in_tabline() + let showtabline_save = &showtabline + set showtabline=2 + let s:func_in_tabline_called = 0 + let tabline = '%{TablineWithCaughtError()}' + let &tabline = tabline + redraw! + call assert_true(s:func_in_tabline_called) + call assert_equal(tabline, &tabline) + set tabline= + let &showtabline = showtabline_save +endfunction + +function! Test_tabline_will_be_disabled_with_error() + let showtabline_save = &showtabline + set showtabline=2 + let s:func_in_tabline_called = 0 + let tabline = '%{TablineWithError()}' + try + let &tabline = tabline + redraw! + catch + endtry + call assert_true(s:func_in_tabline_called) + call assert_equal('', &tabline) + set tabline= + let &showtabline = showtabline_save +endfunction diff --git a/src/version.c b/src/version.c index 4f8bc2ef5bd2f0..0713142b0787f5 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1723, /**/ 1722, /**/ From 73cd8fb3e87e4b29dfc489f58e56dee1839c18e5 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 11 Apr 2016 22:49:03 +0200 Subject: [PATCH 03/29] patch 7.4.1724 Problem: Tabline test fails in GUI. Solution: Remove 'e' from 'guioptions'. --- src/testdir/test_tabline.vim | 6 ++++++ src/version.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/testdir/test_tabline.vim b/src/testdir/test_tabline.vim index 6c7a02d6500164..b08f299fd023e9 100644 --- a/src/testdir/test_tabline.vim +++ b/src/testdir/test_tabline.vim @@ -14,6 +14,9 @@ function! TablineWithError() endfunction function! Test_caught_error_in_tabline() + if has('gui') + set guioptions-=e + endif let showtabline_save = &showtabline set showtabline=2 let s:func_in_tabline_called = 0 @@ -27,6 +30,9 @@ function! Test_caught_error_in_tabline() endfunction function! Test_tabline_will_be_disabled_with_error() + if has('gui') + set guioptions-=e + endif let showtabline_save = &showtabline set showtabline=2 let s:func_in_tabline_called = 0 diff --git a/src/version.c b/src/version.c index 0713142b0787f5..e422527ef2a506 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1724, /**/ 1723, /**/ From 03413f44167c4b5cd0012def9bb331e2518c83cf Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 12 Apr 2016 21:07:15 +0200 Subject: [PATCH 04/29] Updated runtime files. --- runtime/autoload/vimball.vim | 32 ++--- runtime/doc/Makefile | 2 + runtime/doc/eval.txt | 34 +++-- runtime/doc/gui_x11.txt | 4 +- runtime/doc/help.txt | 3 +- runtime/doc/helphelp.txt | 6 +- runtime/doc/options.txt | 6 +- runtime/doc/pattern.txt | 6 +- runtime/doc/pi_logipat.txt | 40 +++--- runtime/doc/pi_vimball.txt | 23 +-- runtime/doc/quickref.txt | 3 +- runtime/doc/repeat.txt | 50 +++++-- runtime/doc/starting.txt | 9 +- runtime/doc/syntax.txt | 40 +++--- runtime/doc/tags | 68 +++++++-- runtime/doc/todo.txt | 97 +++++++++---- runtime/doc/usr_41.txt | 5 +- runtime/doc/version7.txt | 6 +- runtime/doc/version8.txt | 233 +++++++++++++++++++++++++++++++ runtime/doc/vim.1 | 2 +- runtime/gvim.desktop | 1 + runtime/plugin/vimballPlugin.vim | 29 ++-- runtime/syntax/c.vim | 8 +- runtime/syntax/mysql.vim | 30 ++-- runtime/syntax/sh.vim | 21 ++- runtime/syntax/tex.vim | 14 +- runtime/syntax/vim.vim | 78 ++++++----- runtime/vim.desktop | 1 + 28 files changed, 629 insertions(+), 222 deletions(-) create mode 100644 runtime/doc/version8.txt diff --git a/runtime/autoload/vimball.vim b/runtime/autoload/vimball.vim index 9a5a73c3c190c3..1af6b19c885f2a 100644 --- a/runtime/autoload/vimball.vim +++ b/runtime/autoload/vimball.vim @@ -1,9 +1,9 @@ " vimball.vim : construct a file containing both paths and files -" Author: Charles E. Campbell, Jr. -" Date: Jan 17, 2012 -" Version: 35 +" Author: Charles E. Campbell +" Date: Apr 11, 2016 +" Version: 37 " GetLatestVimScripts: 1502 1 :AutoInstall: vimball.vim -" Copyright: (c) 2004-2011 by Charles E. Campbell, Jr. +" Copyright: (c) 2004-2011 by Charles E. Campbell " The VIM LICENSE applies to Vimball.vim, and Vimball.txt " (see |copyright|) except use "Vimball" instead of "Vim". " No warranty, express or implied. @@ -14,7 +14,7 @@ if &cp || exists("g:loaded_vimball") finish endif -let g:loaded_vimball = "v35" +let g:loaded_vimball = "v37" if v:version < 702 echohl WarningMsg echo "***warning*** this version of vimball needs vim 7.2" @@ -142,7 +142,7 @@ fun! vimball#MkVimball(line1,line2,writelevel,...) range let lastline= line("$") + 1 if lastline == 2 && getline("$") == "" - call setline(1,'" Vimball Archiver by Charles E. Campbell, Jr., Ph.D.') + call setline(1,'" Vimball Archiver by Charles E. Campbell') call setline(2,'UseVimball') call setline(3,'finish') let lastline= line("$") + 1 @@ -179,7 +179,7 @@ fun! vimball#MkVimball(line1,line2,writelevel,...) range " remove the evidence setlocal nomod bh=wipe exe "tabn ".curtabnr - exe "tabc ".vbtabnr + exe "tabc! ".vbtabnr " restore options call vimball#RestoreSettings() @@ -280,7 +280,7 @@ fun! vimball#Vimball(really,...) " when AsNeeded/filename is filereadable or was present in VimballRecord if fname =~ '\ instead of <".fname.">") let fname= anfname endif @@ -379,10 +379,10 @@ fun! vimball#Vimball(really,...) call s:RecordInFile(home) " restore events, delete tab and buffer - exe "tabn ".vbtabnr + exe "sil! tabn ".vbtabnr setlocal nomod bh=wipe - exe "tabn ".curtabnr - exe "tabc ".vbtabnr + exe "sil! tabn ".curtabnr + exe "sil! tabc! ".vbtabnr call vimball#RestoreSettings() call s:ChgDir(curdir) @@ -555,7 +555,7 @@ fun! vimball#ShowMesg(level,msg) set noruler noshowcmd redraw! - if &fo =~ '[ta]' + if &fo =~# '[ta]' echomsg "***vimball*** ".a:msg else if a:level == s:WARNING || a:level == s:USAGE @@ -715,7 +715,7 @@ fun! vimball#SaveSettings() " call Dfunc("SaveSettings()") let s:makeep = getpos("'a") let s:regakeep= @a - if exists("&acd") + if exists("+acd") let s:acdkeep = &acd endif let s:eikeep = &ei @@ -728,7 +728,7 @@ fun! vimball#SaveSettings() let s:vekeep = &ve let s:ffkeep = &l:ff let s:swfkeep = &l:swf - if exists("&acd") + if exists("+acd") setlocal ei=all ve=all noacd nofen noic report=999 nohid bt= ma lz pm= ff=unix noswf else setlocal ei=all ve=all nofen noic report=999 nohid bt= ma lz pm= ff=unix noswf @@ -743,7 +743,7 @@ endfun fun! vimball#RestoreSettings() " call Dfunc("RestoreSettings()") let @a = s:regakeep - if exists("&acd") + if exists("+acd") let &acd = s:acdkeep endif let &l:fen = s:fenkeep @@ -760,7 +760,7 @@ fun! vimball#RestoreSettings() " call Decho("restore mark-a: makeep=".string(makeep)) call setpos("'a",s:makeep) endif - if exists("&acd") + if exists("+acd") unlet s:acdkeep endif unlet s:regakeep s:eikeep s:fenkeep s:hidkeep s:ickeep s:repkeep s:vekeep s:makeep s:lzkeep s:pmkeep s:ffkeep diff --git a/runtime/doc/Makefile b/runtime/doc/Makefile index d36f2ce069e078..33a09be42944ae 100644 --- a/runtime/doc/Makefile +++ b/runtime/doc/Makefile @@ -142,6 +142,7 @@ DOCS = \ version5.txt \ version6.txt \ version7.txt \ + version8.txt \ vi_diff.txt \ visual.txt \ windows.txt \ @@ -275,6 +276,7 @@ HTMLS = \ version5.html \ version6.html \ version7.html \ + version8.html \ vi_diff.html \ vimindex.html \ visual.html \ diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index b0b847953edafb..1b4b3b7b978d04 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.4. Last change: 2016 Mar 29 +*eval.txt* For Vim version 7.4. Last change: 2016 Apr 12 VIM REFERENCE MANUAL by Bram Moolenaar @@ -411,7 +411,8 @@ only appear once. Examples: > A key is always a String. You can use a Number, it will be converted to a String automatically. Thus the String '4' and the number 4 will find the same entry. Note that the String '04' and the Number 04 are different, since the -Number will be converted to the String '4'. +Number will be converted to the String '4'. The empty string can be used as a +key. A value can be any expression. Using a Dictionary for a value creates a nested Dictionary: > @@ -874,11 +875,11 @@ These three can be repeated and mixed. Examples: expr8 *expr8* ----- expr8[expr1] item of String or |List| *expr-[]* *E111* - *E909* + *E909* *subscript* If expr8 is a Number or String this results in a String that contains the expr1'th single byte from expr8. expr8 is used as a String, expr1 as a Number. This doesn't recognize multi-byte encodings, see |byteidx()| for -an alternative. +an alternative, or use `split()` to turn the string into a list of characters. Index zero gives the first byte. This is like it works in C. Careful: text column numbers start with one! Example, to get the byte under the @@ -2046,6 +2047,7 @@ range( {expr} [, {max} [, {stride}]]) readfile( {fname} [, {binary} [, {max}]]) List get list of lines from file {fname} reltime( [{start} [, {end}]]) List get time value +reltimefloat( {time}) Float turn the time value into a Float reltimestr( {time}) String turn time value into a String remote_expr( {server}, {string} [, {idvar}]) String send expression @@ -2183,6 +2185,7 @@ writefile( {list}, {fname} [, {flags}]) Number write list of lines to file {fname} xor( {expr}, {expr}) Number bitwise XOR + abs({expr}) *abs()* Return the absolute value of {expr}. When {expr} evaluates to a |Float| abs() returns a |Float|. When {expr} can be @@ -2996,6 +2999,7 @@ cursor({list}) When there is one argument {list} this is used as a |List| with two, three or four item: + [{lnum}, {col}] [{lnum}, {col}, {off}] [{lnum}, {col}, {off}, {curswant}] This is like the return value of |getpos()| or |getcurpos()|, @@ -3400,7 +3404,10 @@ feedkeys({string} [, {mode}]) *feedkeys()* similar to using ":normal!". You can call feedkeys() several times without 'x' and then one time with 'x' (possibly with an empty {string}) to execute all the - typeahead. + typeahead. Note that when Vim ends in Insert mode it + will behave as if is typed, to avoid getting + stuck, waiting for a character to be typed before the + script continues. Return value is always 0. filereadable({file}) *filereadable()* @@ -4633,7 +4640,7 @@ job_status({job}) *job_status()* *E916* "fail" job failed to start "dead" job died or was stopped after running - If an exit callback was set with the "exit-cb" option and the + If an exit callback was set with the "exit_cb" option and the job is now detected to be "dead" the callback will be invoked. For more information see |job_info()|. @@ -5642,7 +5649,8 @@ readfile({fname} [, {binary} [, {max}]]) reltime([{start} [, {end}]]) *reltime()* Return an item that represents a time value. The format of the item depends on the system. It can be passed to - |reltimestr()| to convert it to a string. + |reltimestr()| to convert it to a string or |reltimefloat()| + to convert to a Float. Without an argument it returns the current time. With one argument is returns the time passed since the time specified in the argument. @@ -5652,6 +5660,16 @@ reltime([{start} [, {end}]]) *reltime()* reltime(). {only available when compiled with the |+reltime| feature} +reltimefloat({time}) *reltimefloat()* + Return a Float that represents the time value of {time}. + Example: > + let start = reltime() + call MyFunction() + let seconds = reltimefloat(reltime(start)) +< See the note of reltimestr() about overhead. + Also see |profiling|. + {only available when compiled with the |+reltime| feature} + reltimestr({time}) *reltimestr()* Return a String that represents the time value of {time}. This is the number of seconds, a dot and the number of @@ -7340,7 +7358,7 @@ win_gotoid({expr}) *win_gotoid()* tabpage. Return 1 if successful, 0 if the window cannot be found. -win_id2tabwin({expr} *win_id2tabwin()* +win_id2tabwin({expr}) *win_id2tabwin()* Return a list with the tab number and window number of window with ID {expr}: [tabnr, winnr]. Return [0, 0] if the window cannot be found. diff --git a/runtime/doc/gui_x11.txt b/runtime/doc/gui_x11.txt index 605b998af44518..c6577906179e52 100644 --- a/runtime/doc/gui_x11.txt +++ b/runtime/doc/gui_x11.txt @@ -1,4 +1,4 @@ -*gui_x11.txt* For Vim version 7.4. Last change: 2014 Mar 08 +*gui_x11.txt* For Vim version 7.4. Last change: 2016 Apr 08 VIM REFERENCE MANUAL by Bram Moolenaar @@ -305,7 +305,7 @@ If a name is used that exists on other systems, but not in X11, the default "arrow" pointer is used. ============================================================================== -5. GTK version *gui-gtk* *GTK+* *GTK* +5. GTK version *gui-gtk* *GTK+* *GTK* *GTK3* The GTK version of the GUI works a little bit different. diff --git a/runtime/doc/help.txt b/runtime/doc/help.txt index 09cb32533cb7b7..23d981a5621443 100644 --- a/runtime/doc/help.txt +++ b/runtime/doc/help.txt @@ -1,4 +1,4 @@ -*help.txt* For Vim version 7.4. Last change: 2016 Feb 27 +*help.txt* For Vim version 7.4. Last change: 2016 Mar 31 VIM - main help file k @@ -178,6 +178,7 @@ Versions ~ |version5.txt| Differences between Vim version 4.6 and 5.x |version6.txt| Differences between Vim version 5.7 and 6.x |version7.txt| Differences between Vim version 6.4 and 7.x +|version8.txt| Differences between Vim version 7.4 and 8.x *sys-file-list* Remarks about specific systems ~ |os_390.txt| OS/390 Unix diff --git a/runtime/doc/helphelp.txt b/runtime/doc/helphelp.txt index 2d52d13f4a1f3f..2a06b636d07a15 100644 --- a/runtime/doc/helphelp.txt +++ b/runtime/doc/helphelp.txt @@ -1,4 +1,4 @@ -*helphelp.txt* For Vim version 7.4. Last change: 2016 Mar 28 +*helphelp.txt* For Vim version 7.4. Last change: 2016 Apr 01 VIM REFERENCE MANUAL by Bram Moolenaar @@ -322,6 +322,10 @@ aligned on a line. When referring to an existing help tag and to create a hot-link, place the name between two bars (|) eg. |help-writing|. +When referring to a Vim command and to create a hot-link, place the +name between two backticks, eg. inside `:filetype`. You will see this is +highlighted as a command, like a code block (see below). + When referring to a Vim option in the help file, place the option name between two single quotes, eg. 'statusline' diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 6ddf07673aa5c9..b354ddf5841ffd 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 7.4. Last change: 2016 Apr 03 +*options.txt* For Vim version 7.4. Last change: 2016 Apr 12 VIM REFERENCE MANUAL by Bram Moolenaar @@ -2646,7 +2646,7 @@ A jump table for the options with a short description can be found at |Q_op|. also 'gdefault' option. Switching this option on is discouraged! - *'emoji'* *'emo'* + *'emoji'* *'emo'* *'noemoji'* *'noemo'* 'emoji' 'emo' boolean (default: on) global {not in Vi} @@ -3634,7 +3634,7 @@ A jump table for the options with a short description can be found at |Q_op|. HANGEUL, HEBREW, JOHAB, MAC, OEM, RUSSIAN, SHIFTJIS, SYMBOL, THAI, TURKISH, VIETNAMESE ANSI and BALTIC. Normally you would use "cDEFAULT". - qXX - quality XX. Valid charsets are: PROOF, DRAFT, + qXX - quality XX. Valid quality names are: PROOF, DRAFT, ANTIALIASED, UNANTIALIASED, CLEARTYPE, DEFAULT. Normally you would use "qDEFAULT". Some quality values isn't supported in legacy OSs. diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt index 2a3d2c482da1c7..9cb6e11860aefe 100644 --- a/runtime/doc/pattern.txt +++ b/runtime/doc/pattern.txt @@ -1,4 +1,4 @@ -*pattern.txt* For Vim version 7.4. Last change: 2016 Jan 03 +*pattern.txt* For Vim version 7.4. Last change: 2016 Apr 03 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1104,8 +1104,8 @@ x A single character, with no special meaning, matches itself '/', alphabetic, numeric, '_' or '~'. These items only work for 8-bit characters, except [:lower:] and [:upper:] also work for multi-byte characters when using the new - regexp engine. In the future these items may work for multi-byte - characters. + regexp engine. See |two-engines|. In the future these items may + work for multi-byte characters. */[[=* *[==]* - An equivalence class. This means that characters are matched that have almost the same meaning, e.g., when ignoring accents. This diff --git a/runtime/doc/pi_logipat.txt b/runtime/doc/pi_logipat.txt index ea3acda822e1f0..d2eac8055859b6 100644 --- a/runtime/doc/pi_logipat.txt +++ b/runtime/doc/pi_logipat.txt @@ -1,25 +1,25 @@ -*pi_logipat.txt* Logical Patterns Mar 13, 2013 +*logiPat.txt* Logical Patterns Jun 22, 2015 Author: Charles E. Campbell -Copyright: (c) 2004-2013 by Charles E. Campbell *logipat-copyright* +Copyright: (c) 2004-2015 by Charles E. Campbell *logiPat-copyright* The VIM LICENSE applies to LogiPat.vim and LogiPat.txt (see |copyright|) except use "LogiPat" instead of "Vim" No warranty, express or implied. Use At-Your-Own-Risk. ============================================================================== -1. Contents *logipat* *logipat-contents* +1. Contents *logiPat* *logiPat-contents* - 1. Contents.................: |logipat-contents| - 2. LogiPat Manual...........: |logipat-manual| - 3. LogiPat Examples.........: |logipat-examples| - 4. Caveat...................: |logipat-caveat| - 5. LogiPat History..........: |logipat-history| + 1. Contents.................: |logiPat-contents| + 2. LogiPat Manual...........: |logiPat-manual| + 3. LogiPat Examples.........: |logiPat-examples| + 4. Caveat...................: |logiPat-caveat| + 5. LogiPat History..........: |logiPat-history| -============================================================================== -2. LogiPat Manual *logipat-manual* *logipat-man* +============================================================================== +2. LogiPat Manual *logiPat-manual* *logiPat-man* - *logipat-arg* *logipat-input* *logipat-pattern* *logipat-operators* + *logiPat-arg* *logiPat-input* *logiPat-pattern* *logiPat-operators* Boolean logic patterns are composed of operators ! = not @@ -30,13 +30,12 @@ Copyright: (c) 2004-2013 by Charles E. Campbell *logipat-copyright* :LogiPat {boolean-logic pattern} *:LogiPat* :LogiPat is a command which takes a boolean-logic - argument (|logipat-arg|). + argument (|logiPat-arg|). :LP {boolean-logic pattern} *:LP* :LP is a shorthand command version of :LogiPat - (|:LogiPat|). - :ELP {boolean-logic pattern} *:ELP* + :LPE {boolean-logic pattern} *:LPE* No search is done, but the conversion from the boolean logic pattern to the regular expression is performed and echoed onto the display. @@ -59,8 +58,9 @@ Copyright: (c) 2004-2013 by Charles E. Campbell *logipat-copyright* To get a " inside a pattern, as opposed to having it delimit the pattern, double it. + ============================================================================== -3. LogiPat Examples *logipat-examples* +3. LogiPat Examples *logiPat-examples* LogiPat takes Boolean logic arguments and produces a regular expression which implements the choices. A series of examples @@ -96,22 +96,26 @@ Copyright: (c) 2004-2013 by Charles E. Campbell *logipat-copyright* ============================================================================== -4. Caveat *logipat-caveat* +4. Caveat *logiPat-caveat* The "not" operator may be fragile; ie. it may not always play well with the & (logical-and) and | (logical-or) operators. Please try out your patterns, possibly with :set hls, to insure that what is matching is what you want. + ============================================================================== -3. LogiPat History *logipat-history* +3. LogiPat History *logiPat-history* + v4 Jun 22, 2015 * LogiPat has been picked up by Bram M for standard + plugin distribution; hence the name change v3 Sep 25, 2006 * LP_Or() fixed; it now encapsulates its output in \%(...\) parentheses - Dec 12, 2011 * |:ELP| added + Dec 12, 2011 * |:LPE| added * "" is mapped to a single " and left inside patterns v2 May 31, 2005 * LPF and LogiPatFlags commands weren't working v1 May 23, 2005 * initial release + ============================================================================== vim:tw=78:ts=8:ft=help diff --git a/runtime/doc/pi_vimball.txt b/runtime/doc/pi_vimball.txt index bbc74988ca61f9..68103b50ff6226 100644 --- a/runtime/doc/pi_vimball.txt +++ b/runtime/doc/pi_vimball.txt @@ -1,12 +1,12 @@ -*pi_vimball.txt* For Vim version 7.4. Last change: 2012 Jan 17 +*pi_vimball.txt* For Vim version 7.4. Last change: 2016 Apr 11 ---------------- Vimball Archiver ---------------- -Author: Charles E. Campbell, Jr. +Author: Charles E. Campbell (remove NOSPAM from Campbell's email first) -Copyright: (c) 2004-2012 by Charles E. Campbell, Jr. *Vimball-copyright* +Copyright: (c) 2004-2015 by Charles E. Campbell *Vimball-copyright* The VIM LICENSE (see |copyright|) applies to the files in this package, including vimballPlugin.vim, vimball.vim, and pi_vimball.txt. except use "vimball" instead of "VIM". Like anything else that's free, @@ -99,10 +99,10 @@ MAKING DIRECTORIES VIA VIMBALLS *g:vimball_mkdir* If it doesn't exist, then if g:vimball_mkdir doesn't exist, it is set as follows: > - |g:netrw_local_mkdir|, if it exists - "mkdir" , if it is executable - "makedir" , if it is executable - Otherwise , it is undefined. + |g:netrw_localmkdir|, if it exists + "mkdir" , if it is executable + "makedir" , if it is executable + Otherwise , it is undefined. < One may explicitly specify the directory making command using g:vimball_mkdir. This command is used to make directories that are needed as indicated by the vimball. @@ -120,8 +120,7 @@ CONTROLLING THE VIMBALL EXTRACTION DIRECTORY *g:vimball_home* source the file to extract its contents. Extraction will only proceed if the first line of a putative vimball - file holds the "Vimball Archiver by Charles E. Campbell, Jr., Ph.D." - line. + file holds the "Vimball Archiver by Charles E. Campbell" line. LISTING FILES IN A VIMBALL *:VimballList* @@ -182,13 +181,16 @@ WINDOWS *vimball-windows* ============================================================================== 4. Vimball History *vimball-history* {{{1 + 37 : Jul 18, 2014 * (by request of T. Miedema) added augroup around + the autocmds in vimballPlugin.vim + Jul 06, 2015 * there are two uses of tabc; changed to tabc! 34 : Sep 22, 2011 * "UseVimball path" now supports a non-full path by prepending the current directory to it. 33 : Apr 02, 2011 * Gave priority to *.vmb over *.vba * Changed silent! to sil! (shorter) * Safed |'swf'| setting (during vimball extraction, its now turned off) - 32 : May 19, 2010 * (Christian Brabandt) :so someplugin.vba and + 32 : May 19, 2010 * (Christian Brabrandt) :so someplugin.vba and :so someplugin.vba.gz (and the other supported compression types) now works * (Jan Steffens) added support for xz compression @@ -200,6 +202,7 @@ WINDOWS *vimball-windows* MkVimball, however, now will create *.vmb files. Feb 11, 2011 * motoyakurotsu reported an error with vimball's handling of zero-length files + Feb 18, 2016 * Changed =~ to =~# where appropriate 30 : Dec 08, 2008 * fnameescape() inserted to protect error messaging using corrupted filenames from causing problems diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index 8d415ae82d1787..f42ea82f09cc35 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -1,4 +1,4 @@ -*quickref.txt* For Vim version 7.4. Last change: 2016 Feb 24 +*quickref.txt* For Vim version 7.4. Last change: 2016 Mar 30 VIM REFERENCE MANUAL by Bram Moolenaar @@ -679,6 +679,7 @@ Short explanation of each option: *option-list* 'display' 'dy' list of flags for how to display text 'eadirection' 'ead' in which direction 'equalalways' works 'edcompatible' 'ed' toggle flags of ":substitute" command +'emoji' 'emo' emoji characters are considered full width 'encoding' 'enc' encoding used internally 'endofline' 'eol' write for last line in file 'equalalways' 'ea' windows are automatically made the same size diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index e2c4c2f5f4790e..92ab58566d41f3 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -1,4 +1,4 @@ -*repeat.txt* For Vim version 7.4. Last change: 2016 Mar 27 +*repeat.txt* For Vim version 7.4. Last change: 2016 Apr 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -72,8 +72,8 @@ examples. The global commands work by first scanning through the [range] lines and marking each line where a match occurs (for a multi-line pattern, only the start of the match matters). -In a second scan the [cmd] is executed for each marked line with its line -number prepended. For ":v" and ":g!" the command is executed for each not +In a second scan the [cmd] is executed for each marked line, as if the cursor +was in that line. For ":v" and ":g!" the command is executed for each not marked line. If a line is deleted its mark disappears. The default for [range] is the whole buffer (1,$). Use "CTRL-C" to interrupt the command. If an error message is given for a line, the command for that @@ -234,8 +234,11 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. there yet. Note that {name} is the directory name, not the name - of the .vim file. If the "{name}/plugin" directory - contains more than one file they are all sourced. + of the .vim file. All the files matching the pattern + pack/*/opt/{name}/plugin/**/*.vim ~ + will be sourced. This allows for using subdirectories + below "plugin", just like with plugins in + 'runtimepath'. If the filetype detection was not enabled yet (this is usually done with a "syntax enable" or "filetype @@ -251,15 +254,24 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. Also see |pack-add|. *:packl* *:packloadall* -:packloadall[!] Load all packages in the "start" directories under - 'packpath'. The directories found are added to - 'runtimepath'. +:packl[oadall][!] Load all packages in the "start" directory under each + entry in 'packpath'. + + First all the directories found are added to + 'runtimepath', then the plugins found in the + directories are sourced. This allows for a plugin to + depend on something of another plugin, e.g. an + "autoload" directory. See |packload-two-steps| for + how this can be useful. + This is normally done automatically during startup, after loading your .vimrc file. With this command it can be done earlier. + Packages will be loaded only once. After this command it won't happen again. When the optional ! is added this command will load packages even when done before. + An error only causes sourcing the script where it happens to be aborted, further plugins will be loaded. See |packages|. @@ -471,8 +483,9 @@ You would now have these files under ~/.vim: pack/foo/opt/foodebug/plugin/debugger.vim When Vim starts up, after processing your .vimrc, it scans all directories in -'packpath' for plugins under the "pack/*/start" directory and loads them. The -directory is added to 'runtimepath'. +'packpath' for plugins under the "pack/*/start" directory. First all those +directories are added to 'runtimepath'. Then all the plugins are loaded. +See |packload-two-steps| for how these two steps can be useful. In the example Vim will find "pack/foo/start/foobar/plugin/foo.vim" and adds "~/.vim/pack/foo/start/foobar" to 'runtimepath'. @@ -599,6 +612,23 @@ the command after changing the plugin help: > :helptags path/start/foobar/doc :helptags path/opt/fooextra/doc + +Dependencies between plugins ~ + *packload-two-steps* +Suppose you have a two plugins that depend on the same functionality. You can +put the common functionality in an autoload directory, so that it will be +found automatically. Your package would have these files: + + pack/foo/start/one/plugin/one.vim > + call foolib#getit() +< pack/foo/start/two/plugin/two.vim > + call foolib#getit() +< pack/foo/start/lib/autoload/foolib.vim > + func foolib#getit() + +This works, because loading packages will first add all found directories to +'runtimepath' before sourcing the plugins. + ============================================================================== 7. Debugging scripts *debug-scripts* diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index d2c44b90b7f873..050afcd9f7fb45 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1,4 +1,4 @@ -*starting.txt* For Vim version 7.4. Last change: 2016 Mar 26 +*starting.txt* For Vim version 7.4. Last change: 2016 Apr 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -865,9 +865,10 @@ accordingly. Vim proceeds in this order: commands from the command line have not been executed yet. You can use "--cmd 'set noloadplugins'" |--cmd|. - Plugin packs are loaded. These are plugins, as above, but found in - 'packpath' "start" directories. Every plugin directory found is added - in 'runtimepath'. See |packages|. + Packages are loaded. These are plugins, as above, but found in the + "start" directory of each entry in 'packpath'. Every plugin directory + found is added in 'runtimepath' and then the plugins are sourced. See + |packages|. 5. Set 'shellpipe' and 'shellredir' The 'shellpipe' and 'shellredir' options are set according to the diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index f6351119c60e3f..ab5c0835b548d0 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -1,4 +1,4 @@ -*syntax.txt* For Vim version 7.4. Last change: 2016 Mar 12 +*syntax.txt* For Vim version 7.4. Last change: 2016 Apr 10 VIM REFERENCE MANUAL by Bram Moolenaar @@ -941,26 +941,27 @@ To disable them use ":unlet". Example: > :unlet c_comment_strings Variable Highlight ~ -c_gnu GNU gcc specific items -c_comment_strings strings and numbers inside a comment -c_space_errors trailing white space and spaces before a -c_no_trail_space_error ... but no trailing spaces -c_no_tab_space_error ... but no spaces before a -c_no_bracket_error don't highlight {}; inside [] as errors -c_no_curly_error don't highlight {}; inside [] and () as errors; +*c_gnu* GNU gcc specific items +*c_comment_strings* strings and numbers inside a comment +*c_space_errors* trailing white space and spaces before a +*c_no_trail_space_error* ... but no trailing spaces +*c_no_tab_space_error* ... but no spaces before a +*c_no_bracket_error* don't highlight {}; inside [] as errors +*c_no_curly_error* don't highlight {}; inside [] and () as errors; except { and } in first column -c_curly_error highlight a missing }; this forces syncing from the +*c_curly_error* highlight a missing }; this forces syncing from the start of the file, can be slow -c_no_ansi don't do standard ANSI types and constants -c_ansi_typedefs ... but do standard ANSI types -c_ansi_constants ... but do standard ANSI constants -c_no_utf don't highlight \u and \U in strings -c_syntax_for_h for *.h files use C syntax instead of C++ and use objc +*c_no_ansi* don't do standard ANSI types and constants +*c_ansi_typedefs* ... but do standard ANSI types +*c_ansi_constants* ... but do standard ANSI constants +*c_no_utf* don't highlight \u and \U in strings +*c_syntax_for_h* for *.h files use C syntax instead of C++ and use objc syntax instead of objcpp -c_no_if0 don't highlight "#if 0" blocks as comments -c_no_cformat don't highlight %-formats in strings -c_no_c99 don't highlight C99 standard items -c_no_c11 don't highlight C11 standard items +*c_no_if0* don't highlight "#if 0" blocks as comments +*c_no_cformat* don't highlight %-formats in strings +*c_no_c99* don't highlight C99 standard items +*c_no_c11* don't highlight C11 standard items +*c_no_bsd* don't highlight BSD specific types When 'foldmethod' is set to "syntax" then /* */ comments and { } blocks will become a fold. If you don't want comments to become a fold use: > @@ -5047,6 +5048,9 @@ defaults back: > :syntax reset +It is a bit of a wrong name, since it does not reset any syntax items, it only +affects the highlighting. + This doesn't change the colors for the 'highlight' option. Note that the syntax colors that you set in your vimrc file will also be reset diff --git a/runtime/doc/tags b/runtime/doc/tags index a11cf6ca869300..ec0e58083a51c9 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -538,6 +538,8 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX* 'noed' options.txt /*'noed'* 'noedcompatible' options.txt /*'noedcompatible'* 'noek' options.txt /*'noek'* +'noemo' options.txt /*'noemo'* +'noemoji' options.txt /*'noemoji'* 'noendofline' options.txt /*'noendofline'* 'noeol' options.txt /*'noeol'* 'noequalalways' options.txt /*'noequalalways'* @@ -1867,7 +1869,6 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX* :CompilerSet usr_41.txt /*:CompilerSet* :DiffOrig diff.txt /*:DiffOrig* :DoMatchParen pi_paren.txt /*:DoMatchParen* -:ELP pi_logipat.txt /*:ELP* :Explore pi_netrw.txt /*:Explore* :GLVS pi_getscript.txt /*:GLVS* :GetLatestVimScripts_dat pi_getscript.txt /*:GetLatestVimScripts_dat* @@ -1876,6 +1877,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX* :GnatTags ft_ada.txt /*:GnatTags* :Hexplore pi_netrw.txt /*:Hexplore* :LP pi_logipat.txt /*:LP* +:LPE pi_logipat.txt /*:LPE* :LPF pi_logipat.txt /*:LPF* :Lexplore pi_netrw.txt /*:Lexplore* :LogiPat pi_logipat.txt /*:LogiPat* @@ -4502,6 +4504,7 @@ G motion.txt /*G* GNOME gui_x11.txt /*GNOME* GTK gui_x11.txt /*GTK* GTK+ gui_x11.txt /*GTK+* +GTK3 gui_x11.txt /*GTK3* GUI gui.txt /*GUI* GUI-X11 gui_x11.txt /*GUI-X11* GUIEnter autocmd.txt /*GUIEnter* @@ -4952,6 +4955,8 @@ assert_exception() eval.txt /*assert_exception()* assert_fails() eval.txt /*assert_fails()* assert_false() eval.txt /*assert_false()* assert_match() eval.txt /*assert_match()* +assert_notequal() eval.txt /*assert_notequal()* +assert_notmatch() eval.txt /*assert_notmatch()* assert_true() eval.txt /*assert_true()* at motion.txt /*at* atan() eval.txt /*atan()* @@ -5073,6 +5078,7 @@ bufwinnr() eval.txt /*bufwinnr()* bug-fixes-5 version5.txt /*bug-fixes-5* bug-fixes-6 version6.txt /*bug-fixes-6* bug-fixes-7 version7.txt /*bug-fixes-7* +bug-fixes-8 version8.txt /*bug-fixes-8* bug-reports intro.txt /*bug-reports* bugreport.vim intro.txt /*bugreport.vim* bugs intro.txt /*bugs* @@ -5166,7 +5172,25 @@ c_Insert cmdline.txt /*c_Insert* c_Left cmdline.txt /*c_Left* c_Right cmdline.txt /*c_Right* c_Up cmdline.txt /*c_Up* +c_ansi_constants syntax.txt /*c_ansi_constants* +c_ansi_typedefs syntax.txt /*c_ansi_typedefs* +c_comment_strings syntax.txt /*c_comment_strings* +c_curly_error syntax.txt /*c_curly_error* c_digraph cmdline.txt /*c_digraph* +c_gnu syntax.txt /*c_gnu* +c_no_ansi syntax.txt /*c_no_ansi* +c_no_bracket_error syntax.txt /*c_no_bracket_error* +c_no_bsd syntax.txt /*c_no_bsd* +c_no_c11 syntax.txt /*c_no_c11* +c_no_c99 syntax.txt /*c_no_c99* +c_no_cformat syntax.txt /*c_no_cformat* +c_no_curly_error syntax.txt /*c_no_curly_error* +c_no_if0 syntax.txt /*c_no_if0* +c_no_tab_space_error syntax.txt /*c_no_tab_space_error* +c_no_trail_space_error syntax.txt /*c_no_trail_space_error* +c_no_utf syntax.txt /*c_no_utf* +c_space_errors syntax.txt /*c_space_errors* +c_syntax_for_h syntax.txt /*c_syntax_for_h* c_wildchar cmdline.txt /*c_wildchar* call() eval.txt /*call()* carriage-return intro.txt /*carriage-return* @@ -5327,6 +5351,7 @@ compatible-default starting.txt /*compatible-default* compile-changes-5 version5.txt /*compile-changes-5* compile-changes-6 version6.txt /*compile-changes-6* compile-changes-7 version7.txt /*compile-changes-7* +compile-changes-8 version8.txt /*compile-changes-8* compiler-compaqada ft_ada.txt /*compiler-compaqada* compiler-decada ft_ada.txt /*compiler-decada* compiler-gcc quickfix.txt /*compiler-gcc* @@ -6783,6 +6808,7 @@ improved-viminfo version5.txt /*improved-viminfo* improvements-5 version5.txt /*improvements-5* improvements-6 version6.txt /*improvements-6* improvements-7 version7.txt /*improvements-7* +improvements-8 version8.txt /*improvements-8* in_bot channel.txt /*in_bot* in_buf channel.txt /*in_buf* in_mode channel.txt /*in_mode* @@ -6795,6 +6821,7 @@ incomp-small-6 version6.txt /*incomp-small-6* incompatible-5 version5.txt /*incompatible-5* incompatible-6 version6.txt /*incompatible-6* incompatible-7 version7.txt /*incompatible-7* +incompatible-8 version8.txt /*incompatible-8* indent() eval.txt /*indent()* indent-expression indent.txt /*indent-expression* indent.txt indent.txt /*indent.txt* @@ -6988,18 +7015,19 @@ location-list quickfix.txt /*location-list* location-list-window quickfix.txt /*location-list-window* log() eval.txt /*log()* log10() eval.txt /*log10()* -logipat pi_logipat.txt /*logipat* -logipat-arg pi_logipat.txt /*logipat-arg* -logipat-caveat pi_logipat.txt /*logipat-caveat* -logipat-contents pi_logipat.txt /*logipat-contents* -logipat-copyright pi_logipat.txt /*logipat-copyright* -logipat-examples pi_logipat.txt /*logipat-examples* -logipat-history pi_logipat.txt /*logipat-history* -logipat-input pi_logipat.txt /*logipat-input* -logipat-man pi_logipat.txt /*logipat-man* -logipat-manual pi_logipat.txt /*logipat-manual* -logipat-operators pi_logipat.txt /*logipat-operators* -logipat-pattern pi_logipat.txt /*logipat-pattern* +logiPat pi_logipat.txt /*logiPat* +logiPat-arg pi_logipat.txt /*logiPat-arg* +logiPat-caveat pi_logipat.txt /*logiPat-caveat* +logiPat-contents pi_logipat.txt /*logiPat-contents* +logiPat-copyright pi_logipat.txt /*logiPat-copyright* +logiPat-examples pi_logipat.txt /*logiPat-examples* +logiPat-history pi_logipat.txt /*logiPat-history* +logiPat-input pi_logipat.txt /*logiPat-input* +logiPat-man pi_logipat.txt /*logiPat-man* +logiPat-manual pi_logipat.txt /*logiPat-manual* +logiPat-operators pi_logipat.txt /*logiPat-operators* +logiPat-pattern pi_logipat.txt /*logiPat-pattern* +logiPat.txt pi_logipat.txt /*logiPat.txt* long-lines version5.txt /*long-lines* love intro.txt /*love* lowercase change.txt /*lowercase* @@ -7452,6 +7480,7 @@ network pi_netrw.txt /*network* new-5 version5.txt /*new-5* new-6 version6.txt /*new-6* new-7 version7.txt /*new-7* +new-8 version8.txt /*new-8* new-GTK-GUI version5.txt /*new-GTK-GUI* new-MzScheme version7.txt /*new-MzScheme* new-Select-mode version5.txt /*new-Select-mode* @@ -7484,6 +7513,7 @@ new-highlighting version5.txt /*new-highlighting* new-indent-flex version6.txt /*new-indent-flex* new-items-6 version6.txt /*new-items-6* new-items-7 version7.txt /*new-items-7* +new-items-8 version8.txt /*new-items-8* new-line-continuation version5.txt /*new-line-continuation* new-location-list version7.txt /*new-location-list* new-lua version7.txt /*new-lua* @@ -7526,6 +7556,7 @@ new-user-manual version6.txt /*new-user-manual* new-utf-8 version6.txt /*new-utf-8* new-vertsplit version6.txt /*new-vertsplit* new-vim-script version7.txt /*new-vim-script* +new-vim-script-8 version8.txt /*new-vim-script-8* new-vim-server version6.txt /*new-vim-server* new-vimgrep version7.txt /*new-vimgrep* new-virtedit version6.txt /*new-virtedit* @@ -7611,6 +7642,7 @@ p change.txt /*p* pack-add repeat.txt /*pack-add* package-create repeat.txt /*package-create* packages repeat.txt /*packages* +packload-two-steps repeat.txt /*packload-two-steps* page-down intro.txt /*page-down* page-up intro.txt /*page-up* page_down intro.txt /*page_down* @@ -7619,6 +7651,7 @@ pager message.txt /*pager* papp.vim syntax.txt /*papp.vim* paragraph motion.txt /*paragraph* pascal.vim syntax.txt /*pascal.vim* +patches-8 version8.txt /*patches-8* pathshorten() eval.txt /*pathshorten()* pattern pattern.txt /*pattern* pattern-atoms pattern.txt /*pattern-atoms* @@ -7670,7 +7703,6 @@ php3.vim syntax.txt /*php3.vim* phtml.vim syntax.txt /*phtml.vim* pi_getscript.txt pi_getscript.txt /*pi_getscript.txt* pi_gzip.txt pi_gzip.txt /*pi_gzip.txt* -pi_logipat.txt pi_logipat.txt /*pi_logipat.txt* pi_netrw.txt pi_netrw.txt /*pi_netrw.txt* pi_paren.txt pi_paren.txt /*pi_paren.txt* pi_spec.txt pi_spec.txt /*pi_spec.txt* @@ -7871,6 +7903,7 @@ registers change.txt /*registers* regular-expression pattern.txt /*regular-expression* reload editing.txt /*reload* reltime() eval.txt /*reltime()* +reltimefloat() eval.txt /*reltimefloat()* reltimestr() eval.txt /*reltimestr()* remote.txt remote.txt /*remote.txt* remote_expr() eval.txt /*remote_expr()* @@ -8260,6 +8293,7 @@ sub-replace-special change.txt /*sub-replace-special* sublist eval.txt /*sublist* submatch() eval.txt /*submatch()* subscribe-maillist intro.txt /*subscribe-maillist* +subscript eval.txt /*subscript* substitute() eval.txt /*substitute()* substitute-CR version6.txt /*substitute-CR* suffixes cmdline.txt /*suffixes* @@ -8919,6 +8953,7 @@ version-7.1 version7.txt /*version-7.1* version-7.2 version7.txt /*version-7.2* version-7.3 version7.txt /*version-7.3* version-7.4 version7.txt /*version-7.4* +version-8.0 version8.txt /*version-8.0* version-variable eval.txt /*version-variable* version4.txt version4.txt /*version4.txt* version5.txt version5.txt /*version5.txt* @@ -8929,6 +8964,8 @@ version7.2 version7.txt /*version7.2* version7.3 version7.txt /*version7.3* version7.4 version7.txt /*version7.4* version7.txt version7.txt /*version7.txt* +version8.0 version8.txt /*version8.0* +version8.txt version8.txt /*version8.txt* vi intro.txt /*vi* vi-differences vi_diff.txt /*vi-differences* vi: options.txt /*vi:* @@ -8937,6 +8974,8 @@ view starting.txt /*view* view-diffs diff.txt /*view-diffs* view-file starting.txt /*view-file* views-sessions starting.txt /*views-sessions* +vim-7.4 version7.txt /*vim-7.4* +vim-8 version8.txt /*vim-8* vim-additions vi_diff.txt /*vim-additions* vim-announce intro.txt /*vim-announce* vim-arguments starting.txt /*vim-arguments* @@ -8950,6 +8989,7 @@ vim-script-intro usr_41.txt /*vim-script-intro* vim-variable eval.txt /*vim-variable* vim.vim syntax.txt /*vim.vim* vim7 version7.txt /*vim7* +vim8 version8.txt /*vim8* vim: options.txt /*vim:* vim_did_enter-variable eval.txt /*vim_did_enter-variable* vim_starting eval.txt /*vim_starting* diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt index e9a6d911c6a762..ff359b1680fac8 100644 --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -1,4 +1,4 @@ -*todo.txt* For Vim version 7.4. Last change: 2016 Mar 29 +*todo.txt* For Vim version 7.4. Last change: 2016 Apr 11 VIM REFERENCE MANUAL by Bram Moolenaar @@ -27,14 +27,31 @@ Priority classification: See |develop.txt| for development plans. You can vote for which items should be worked on, but only if you sponsor Vim development. See |sponsor|. -Issues can also be entered online: http://code.google.com/p/vim/issues/list +Issues can also be entered online: https://github.com/vim/vim/issues Updates will be forwarded to the vim_dev maillist. Issues entered there will not be repeated below, unless there is extra information. *known-bugs* -------------------- Known bugs and current work ----------------------- -Using free memory. (Dominique, 2016 Mar 27) +Crash in garbagecollect() after starting a job. (Yasuhiro Matsumoto) + :let g:a = job_start(['ls']) + :call garbagecollect() +-> Need to find a way to call garbagecollect() in a test. + +Channel closes unexpectedly. (Christian Robinson, 2016 Apr 10) +Log file later. +Remarks from Kazunobu Kuriyama. Fix from Hirohito, suggested by Ozaki Kiichi. + +When test_partial start_job() has a non-existing command memory leaks. + +Vim 8 features to mention: +* TabNew, TabNewEntered and TabClosed autocommand events. + +Also keep a list of loaded plugins, skip when encountered again? + +Memory leak in test49 +Memory leak in test_alot, with matchstrpos() +channel: - When a message in the queue but there is no callback, drop it after a while? @@ -50,23 +67,17 @@ Later - job_start(): run job in a newly opened terminal. With xterm could use -S{pty}. -Partial: -- Maybe we also need VAR_PARTIAL support in if_mzsch. +Test for try/catch in 'tabline'. #746, Haya, 2016 Apr 10. Make it so that the window ID can be used where currently a window nr is used -Patch to add "q" item to guifont. #720, Kim Brouer, 2016 Mar 29 -Better patch from Yasuhiro Matsumoto, 2016 Jan 4. - Patch to make tag jump work on function({expr}). (Hirohito Higashi, 2016 Mar 25) -Allow for an empty dictionary key? - Patch to improve I/O for Perl. (Damien, 2016 Jan 9, update Jan 22 2nd one) -Patch to fix ml_get error. (Alexander Freiherr von Buddenbrock, 2016 Mar 4, -#676) +Add strgetchar(): get a character by index from a string. + using [] is a byte index. Regexp problems: - The regexp engines are not reentrant, causing havoc when interrupted by a @@ -89,6 +100,7 @@ Regexp problems: - NFA regexp doesn't handle \% :e `=foo . ".c"` Skip over the expression in `=expr` when looking for comments, |, % and #. @@ -10158,7 +10158,7 @@ an error. Was caused by patch 7.2.132. Make the references to features in the help more consistent. (Sylvain Hitier) ============================================================================== -VERSION 7.4 *version-7.4* *version7.4* +VERSION 7.4 *version-7.4* *version7.4* *vim-7.4* This section is about improvements made between version 7.3 and 7.4. diff --git a/runtime/doc/version8.txt b/runtime/doc/version8.txt new file mode 100644 index 00000000000000..8d14a870f7d4d5 --- /dev/null +++ b/runtime/doc/version8.txt @@ -0,0 +1,233 @@ +*version8.txt* For Vim version 8.0. Last change: 2016 Apr 12 + + + VIM REFERENCE MANUAL by Bram Moolenaar + +NOTE: THIS FILE IS STILL BEING WORKED ON + + *vim8* *vim-8* *version-8.0* *version8.0* +Welcome to Vim 8! A large number of bugs have been fixed and several +features have been added. This file mentions all the new items and changes to +existing features since Vim 7.4. Bug fixes, the patches for Vim 7.4, can be +found below |vim-7.4|. Use this command to see the version you are using: > + :version + +See |vi_diff.txt| for an overview of differences between Vi and Vim 7.0. +See |version4.txt| for differences between Vim 3.x and Vim 4.x. +See |version5.txt| for differences between Vim 4.x and Vim 5.x. +See |version6.txt| for differences between Vim 5.x and Vim 6.x. +See |version7.txt| for differences between Vim 6.x and Vim 7.x. + +INCOMPATIBLE CHANGES |incompatible-8| + +NEW FEATURES |new-8| + +Vim script enhancements |new-vim-script-8| + +IMPROVEMENTS |improvements-8| + +COMPILE TIME CHANGES |compile-changes-8| + +PATCHES |patches-8| + + +============================================================================== +INCOMPATIBLE CHANGES *incompatible-8* + +These changes are incompatible with previous releases. Check this list if you +run into a problem when upgrading from Vim 7.4 to 8.0. + +The support for MS-DOS has been removed. + + +Minor incompatibilities: + +For filetype detection: ... + +============================================================================== +NEW FEATURES *new-8* + +First a list to the bigger new features. A comprehensive list is below. + + +Asynchronous I/O support, channels ~ + +Vim can now exchange messages with another process in the background. The +message are received and handled while Vim is waiting for a character. See +|channel-demo| for an example, communicating with a Python server. + +Closely related to channels is JSON support. JSON is widely supported and can +easily be used for inter-process communication, allowing for writing a server +in any language. The functions to use are |json_encode()| and |json_decode()|. + + +Jobs ~ + +Vim can now start a job, communicate with it and stop it. This is very useful +to run a process for completion, syntax checking, etc. Channels are used to +communicate with the job. Jobs can also read from or write to a buffer or a +file. See |job_start()|. + + +Timers ~ + +Also asynchronous are timers. They can fire once or repeatedly and invoke a +function to do any work. For example: > + let tempTimer = timer_start(4000, 'CheckTemp') +This will make call 4 seconds later, like: > + call CheckTemp() + + +Partials ~ + +Vim already had a Funcref, a reference to a function. A partial also refers +to a function, and additionally binds arguments and/or a dictionary. This is +especially useful for callbacks on channels and timers. E.g., for the timer +example above, to pass an argument to the function: > + let tempTimer = timer_start(4000, function('CheckTemp', ['out'])) +This will make call 4 seconds later, like: > + call CheckTemp('out') + + +Packages ~ + +Plugins keep growing and more of them are available then ever before. To keep +the collection of plugins manageable package support has been added. This is +a convenient way to get one or more plugins, drop them in a directory and +possibly keep them updated. Vim will load them automatically, or only when +desired. See |packages|. + + +New style tests ~ + +This is for Vim developers. So far writing tests for Vim has not been easy. +Vim 8 adds assert functions and a framework to run tests. This makes it a lot +simpler to write tests and keep them updated. + +These functions have been added: + |assert_equal()| + |assert_notequal()| + |assert_exception()| + |assert_fails()| + |assert_false()| + |assert_match()| + |assert_notmatch()| + |assert_true()| + |alloc_fail()| + |disable_char_avail_for_testing()| + + +Window IDs ~ + +Previously windows could only be accessed by their number. And every time a +window would open, close or move that number changes. Each window now has a +unique ID, so that they are easy to find. + + +Wrapping lines with indent ~ + +The 'breakindent' option has been added to be able to wrap lines without +changing the amount of indent. + + +Windows: Direct-X support ~ + +This adds the 'renderoptions' option to allow for switching on Direct-X +(DirectWrite) support on MS-Windows. + + +GTK+ 3 support ~ + +GTK+ 2 is getting old, GTK+ 3 is here. Support has been added and it already +works quite well, mostly just like GTK+ 2. + + +Vim script enhancements *new-vim-script-8* +----------------------- + +In Vim scripts the following types have been added: + + |Special| |v:false|, |v:true|, |v:none| and |v:null| + |Channel| connection to another process for asynchronous I/O + |Job| process control + +Many functions and commands have been added to support the new types. + + + +Various new items *new-items-8* +----------------- + +Normal mode commands: ~ + + +Insert mode commands: ~ + + +Options: ~ + + +Ex commands: ~ + + +Ex command modifiers: ~ + + +Ex command arguments: ~ + + +New and extended functions: ~ + + + +New Vim variables: ~ + +|v:vim_did_enter| Set when VimEnter autocommands are triggered + + +New autocommand events: ~ + + + +New highlight groups: ~ + + +New items in search patterns: ~ + + +New Syntax/Indent/FTplugin files: ~ + + +New Keymaps: ~ + + +New message translations: ~ + + +Others: ~ + + +============================================================================== +IMPROVEMENTS *improvements-8* + +The existing blowfish encryption turned out to be much weaker than it was +supposed to be. The blowfish2 method has been added to fix that. Note that +this still isn't a state-of-the-art encryption, but good enough for most +usage. See 'cryptmethod'. + +============================================================================== +COMPILE TIME CHANGES *compile-changes-8* + +Dropped the support for MS-DOS. It was too big to fit in memory. + + +============================================================================== +PATCHES *patches-8* *bug-fixes-8* + +The list of patches that got included since 7.4.0. This includes all the new +features, but does not include runtime file changes (syntax, indent, help, +etc.) + +TODO: INCLUDE PATCH LIST. + + vim:tw=78:ts=8:ft=help:norl: diff --git a/runtime/doc/vim.1 b/runtime/doc/vim.1 index e2dcd42c2fd550..e3c877354107e9 100644 --- a/runtime/doc/vim.1 +++ b/runtime/doc/vim.1 @@ -321,7 +321,7 @@ When N is omitted, open one tab page for each file. \-R Read-only mode. The 'readonly' option will be set. -You can still edit the buffer, but will be prevented from accidently +You can still edit the buffer, but will be prevented from accidentally overwriting a file. If you do want to overwrite a file, add an exclamation mark to the Ex command, as in ":w!". diff --git a/runtime/gvim.desktop b/runtime/gvim.desktop index 24d744529f5dd0..aeeddfc2517626 100644 --- a/runtime/gvim.desktop +++ b/runtime/gvim.desktop @@ -74,6 +74,7 @@ TryExec=gvim Exec=gvim -f %F Terminal=false Type=Application +Keywords=Text;editor; Icon=gvim Categories=Utility;TextEditor; StartupNotify=true diff --git a/runtime/plugin/vimballPlugin.vim b/runtime/plugin/vimballPlugin.vim index 59279774cad7e4..d7473a029665f6 100644 --- a/runtime/plugin/vimballPlugin.vim +++ b/runtime/plugin/vimballPlugin.vim @@ -1,6 +1,6 @@ " vimballPlugin : construct a file containing both paths and files -" Author: Charles E. Campbell, Jr. -" Copyright: (c) 2004-2010 by Charles E. Campbell, Jr. +" Author: Charles E. Campbell +" Copyright: (c) 2004-2014 by Charles E. Campbell " The VIM LICENSE applies to Vimball.vim, and Vimball.txt " (see |copyright|) except use "Vimball" instead of "Vim". " No warranty, express or implied. @@ -16,22 +16,25 @@ if &cp || exists("g:loaded_vimballPlugin") finish endif -let g:loaded_vimballPlugin = "v35" +let g:loaded_vimballPlugin = "v37" let s:keepcpo = &cpo set cpo&vim " ------------------------------------------------------------------------------ " Public Interface: {{{1 -com! -ra -complete=file -na=+ -bang MkVimball call vimball#MkVimball(,,0,) -com! -na=? -complete=dir UseVimball call vimball#Vimball(1,) -com! -na=0 VimballList call vimball#Vimball(0) -com! -na=* -complete=dir RmVimball call vimball#SaveSettings()|call vimball#RmVimball()|call vimball#RestoreSettings() -au BufEnter *.vba,*.vba.gz,*.vba.bz2,*.vba.zip,*.vba.xz setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|call vimball#ShowMesg(0,"Source this file to extract it! (:so %)") -au SourceCmd *.vba.gz,*.vba.bz2,*.vba.zip,*.vba.xz if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|endif|call vimball#Decompress(expand(""))|so %|if expand("%")!=expand("")|close|endif -au SourceCmd *.vba if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|call vimball#Vimball(1)|close|else|call vimball#Vimball(1)|endif -au BufEnter *.vmb,*.vmb.gz,*.vmb.bz2,*.vmb.zip,*.vmb.xz setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|call vimball#ShowMesg(0,"Source this file to extract it! (:so %)") -au SourceCmd *.vmb.gz,*.vmb.bz2,*.vmb.zip,*.vmb.xz if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|endif|call vimball#Decompress(expand(""))|so %|if expand("%")!=expand("")|close|endif -au SourceCmd *.vmb if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|call vimball#Vimball(1)|close|else|call vimball#Vimball(1)|endif +com! -range -complete=file -nargs=+ -bang MkVimball call vimball#MkVimball(,,0,) +com! -nargs=? -complete=dir UseVimball call vimball#Vimball(1,) +com! -nargs=0 VimballList call vimball#Vimball(0) +com! -nargs=* -complete=dir RmVimball call vimball#SaveSettings()|call vimball#RmVimball()|call vimball#RestoreSettings() +augroup Vimball + au! + au BufEnter *.vba,*.vba.gz,*.vba.bz2,*.vba.zip,*.vba.xz setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|if line('$') > 1|call vimball#ShowMesg(0,"Source this file to extract it! (:so %)")|endif + au SourceCmd *.vba.gz,*.vba.bz2,*.vba.zip,*.vba.xz let s:origfile=expand("%")|if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|endif|call vimball#Decompress(expand(""))|so %|if s:origfile!=expand("")|close|endif + au SourceCmd *.vba if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|call vimball#Vimball(1)|close|else|call vimball#Vimball(1)|endif + au BufEnter *.vmb,*.vmb.gz,*.vmb.bz2,*.vmb.zip,*.vmb.xz setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|if line('$') > 1|call vimball#ShowMesg(0,"Source this file to extract it! (:so %)")|endif + au SourceCmd *.vmb.gz,*.vmb.bz2,*.vmb.zip,*.vmb.xz let s:origfile=expand("%")|if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|endif|call vimball#Decompress(expand(""))|so %|if s:origfile!=expand("")|close|endif + au SourceCmd *.vmb if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|call vimball#Vimball(1)|close|else|call vimball#Vimball(1)|endif +augroup END " ===================================================================== " Restoration And Modelines: {{{1 diff --git a/runtime/syntax/c.vim b/runtime/syntax/c.vim index bd63578fb0ea43..3fe3256059b4f1 100644 --- a/runtime/syntax/c.vim +++ b/runtime/syntax/c.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: C " Maintainer: Bram Moolenaar -" Last Change: 2016 Apr 07 +" Last Change: 2016 Apr 10 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") @@ -248,8 +248,10 @@ if !exists("c_no_c99") " ISO C99 syn keyword cType _Bool bool _Complex complex _Imaginary imaginary syn keyword cType int8_t int16_t int32_t int64_t syn keyword cType uint8_t uint16_t uint32_t uint64_t - " These are BSD specific? - syn keyword cType u_int8_t u_int16_t u_int32_t u_int64_t + if !exists("c_no_bsd") + " These are BSD specific. + syn keyword cType u_int8_t u_int16_t u_int32_t u_int64_t + endif syn keyword cType int_least8_t int_least16_t int_least32_t int_least64_t syn keyword cType uint_least8_t uint_least16_t uint_least32_t uint_least64_t syn keyword cType int_fast8_t int_fast16_t int_fast32_t int_fast64_t diff --git a/runtime/syntax/mysql.vim b/runtime/syntax/mysql.vim index c01ecc192baada..d7cf74710d1952 100644 --- a/runtime/syntax/mysql.vim +++ b/runtime/syntax/mysql.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: mysql " Maintainer: Kenneth J. Pronovici -" Last Change: $LastChangedDate: 2010-04-22 09:48:02 -0500 (Thu, 22 Apr 2010) $ +" Last Change: $LastChangedDate: 2016-04-11 10:31:04 -0500 (Mon, 11 Apr 2016) $ " Filenames: *.mysql " URL: ftp://cedar-solutions.com/software/mysql.vim " Note: The definitions below are taken from the mysql user manual as of April 2002, for version 3.23 @@ -18,7 +18,7 @@ endif syn case ignore " General keywords which don't fall into other categories -syn keyword mysqlKeyword action add after aggregate all alter as asc auto_increment avg avg_row_length +syn keyword mysqlKeyword action add after aggregate all alter as asc auto_increment avg_row_length syn keyword mysqlKeyword both by syn keyword mysqlKeyword cascade change character check checksum column columns comment constraint create cross syn keyword mysqlKeyword current_date current_time current_timestamp @@ -30,7 +30,7 @@ syn keyword mysqlKeyword global grant grants group syn keyword mysqlKeyword having heap high_priority hosts hour hour_minute hour_second syn keyword mysqlKeyword identified ignore index infile inner insert insert_id into isam syn keyword mysqlKeyword join -syn keyword mysqlKeyword key keys kill last_insert_id leading left limit lines load local lock logs long +syn keyword mysqlKeyword key keys kill last_insert_id leading left limit lines load local lock logs long syn keyword mysqlKeyword low_priority syn keyword mysqlKeyword match max_rows middleint min_rows minute minute_second modify month myisam syn keyword mysqlKeyword natural no @@ -64,6 +64,9 @@ syn match mysqlNumber "\<0x[abcdefABCDEF0-9]*\>" " User variables syn match mysqlVariable "@\a*[A-Za-z0-9]*\([._]*[A-Za-z0-9]\)*" +" Escaped column names +syn match mysqlEscaped "`[^`]*`" + " Comments (c-style, mysql-style and modified sql-style) syn region mysqlComment start="/\*" end="\*/" syn match mysqlComment "#.*" @@ -84,14 +87,14 @@ syn sync ccomment mysqlComment " The second problem is that some of these keywords are included in " function names. For instance, year() is part of the name of the " dayofyear() function, and the dec keyword (no parenthesis) is part of -" the name of the decode() function. +" the name of the decode() function. -syn keyword mysqlType tinyint smallint mediumint int integer bigint -syn keyword mysqlType date datetime time bit bool +syn keyword mysqlType tinyint smallint mediumint int integer bigint +syn keyword mysqlType date datetime time bit bool syn keyword mysqlType tinytext mediumtext longtext text syn keyword mysqlType tinyblob mediumblob longblob blob -syn region mysqlType start="float\W" end="."me=s-1 -syn region mysqlType start="float$" end="."me=s-1 +syn region mysqlType start="float\W" end="."me=s-1 +syn region mysqlType start="float$" end="."me=s-1 syn region mysqlType start="float(" end=")" contains=mysqlNumber,mysqlVariable syn region mysqlType start="double\W" end="."me=s-1 syn region mysqlType start="double$" end="."me=s-1 @@ -139,12 +142,12 @@ syn region mysqlFlow start="if(" end=")" contains=ALL " " I'm leery of just defining keywords for functions, since according to the MySQL manual: " -" Function names do not clash with table or column names. For example, ABS is a -" valid column name. The only restriction is that for a function call, no spaces -" are allowed between the function name and the `(' that follows it. +" Function names do not clash with table or column names. For example, ABS is a +" valid column name. The only restriction is that for a function call, no spaces +" are allowed between the function name and the `(' that follows it. " -" This means that if I want to highlight function names properly, I have to use a -" region to define them, not just a keyword. This will probably cause the syntax file +" This means that if I want to highlight function names properly, I have to use a +" region to define them, not just a keyword. This will probably cause the syntax file " to load more slowly, but at least it will be 'correct'. syn region mysqlFunction start="abs(" end=")" contains=ALL @@ -154,6 +157,7 @@ syn region mysqlFunction start="ascii(" end=")" contains=ALL syn region mysqlFunction start="asin(" end=")" contains=ALL syn region mysqlFunction start="atan(" end=")" contains=ALL syn region mysqlFunction start="atan2(" end=")" contains=ALL +syn region mysqlFunction start="avg(" end=")" contains=ALL syn region mysqlFunction start="benchmark(" end=")" contains=ALL syn region mysqlFunction start="bin(" end=")" contains=ALL syn region mysqlFunction start="bit_and(" end=")" contains=ALL diff --git a/runtime/syntax/sh.vim b/runtime/syntax/sh.vim index 8b0a91f674f731..6ef5bf0d164ec8 100644 --- a/runtime/syntax/sh.vim +++ b/runtime/syntax/sh.vim @@ -2,8 +2,8 @@ " Language: shell (sh) Korn shell (ksh) bash (sh) " Maintainer: Charles E. Campbell " Previous Maintainer: Lennart Schultz -" Last Change: Mar 12, 2016 -" Version: 146 +" Last Change: Apr 11, 2016 +" Version: 147 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH " For options and settings, please use: :help ft-sh-syntax " This file includes many ideas from Eric Brunet (eric.brunet@ens.fr) @@ -539,13 +539,20 @@ endif " Synchronization: {{{1 " ================ -if !exists("sh_minlines") - let sh_minlines = 200 +if !exists("g:sh_minlines") + let s:sh_minlines = 200 +else + let s:sh_minlines= g:sh_minlines endif -if !exists("sh_maxlines") - let sh_maxlines = 2 * sh_minlines +if !exists("g:sh_maxlines") + let s:sh_maxlines = 2*s:sh_minlines + if s:sh_maxlines < 25 + let s:sh_maxlines= 25 + endif +else + let s:sh_maxlines= g:sh_maxlines endif -exec "syn sync minlines=" . sh_minlines . " maxlines=" . sh_maxlines +exec "syn sync minlines=" . s:sh_minlines . " maxlines=" . s:sh_maxlines syn sync match shCaseEsacSync grouphere shCaseEsac "\" syn sync match shCaseEsacSync groupthere shCaseEsac "\" syn sync match shDoSync grouphere shDo "\" diff --git a/runtime/syntax/tex.vim b/runtime/syntax/tex.vim index 5af5882a564bb7..d6d5dd81ee2c1b 100644 --- a/runtime/syntax/tex.vim +++ b/runtime/syntax/tex.vim @@ -1,8 +1,8 @@ " Vim syntax file " Language: TeX " Maintainer: Charles E. Campbell -" Last Change: Mar 07, 2016 -" Version: 93 +" Last Change: Apr 11, 2016 +" Version: 94 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX " " Notes: {{{1 @@ -83,10 +83,14 @@ else let s:tex_conceal= g:tex_conceal endif if !exists("g:tex_superscripts") - let g:tex_superscripts= "[0-9a-zA-W.,:;+-<>/()=]" + let s:tex_superscripts= "[0-9a-zA-W.,:;+-<>/()=]" +else + let s:tex_superscripts= g:tex_superscripts endif if !exists("g:tex_subscripts") - let g:tex_subscripts= "[0-9aehijklmnoprstuvx,+-/().]" + let s:tex_subscripts= "[0-9aehijklmnoprstuvx,+-/().]" +else + let s:tex_subscripts= g:tex_subscripts endif " Determine whether or not to use "*.sty" mode {{{1 @@ -1049,7 +1053,7 @@ if has("conceal") && &enc == 'utf-8' endif " s:SuperSub: fun! s:SuperSub(group,leader,pat,cchar) - if a:pat =~# '^\\' || (a:leader == '\^' && a:pat =~# g:tex_superscripts) || (a:leader == '_' && a:pat =~# g:tex_subscripts) + if a:pat =~# '^\\' || (a:leader == '\^' && a:pat =~# s:tex_superscripts) || (a:leader == '_' && a:pat =~# s:tex_subscripts) " call Decho("SuperSub: group<".a:group."> leader<".a:leader."> pat<".a:pat."> cchar<".a:cchar.">") exe 'syn match '.a:group." '".a:leader.a:pat."' contained conceal cchar=".a:cchar exe 'syn match '.a:group."s '".a:pat ."' contained conceal cchar=".a:cchar.' nextgroup='.a:group.'s' diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index c809f700a9582e..d8fed4666c8ace 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -1,8 +1,8 @@ " Vim syntax file " Language: Vim 7.4 script " Maintainer: Charles E. Campbell -" Last Change: March 29, 2016 -" Version: 7.4-45 +" Last Change: April 12, 2016 +" Version: 7.4-47 " Automatically generated keyword lists: {{{1 " Quit when a syntax file was already loaded {{{2 @@ -18,35 +18,34 @@ syn keyword vimTodo contained COMBAK FIXME TODO XXX syn cluster vimCommentGroup contains=vimTodo,@Spell " regular vim commands {{{2 -syn keyword vimCommand contained a argd argu[ment] bf[irst] brea[k] buf cabc[lear] cc cfdo changes clo[se] cnf comc[lear] cpf[ile] cstag debugg[reedy] deletel dell diffg[et] dif[fupdate] dl ds[earch] echoe[rr] em[enu] en[dif] exu[sage] fin fo[ld] fu grepa[dd] helpc[lose] his[tory] il[ist] iuna[bbrev] keepj[umps] laddb[uffer] lat lcs lf lg[etfile] lla[st] lnew[er] lNf[ile] lockv[ar] ls lvimgrepa[dd] mat[ch] mk[exrc] mo n n[ext] nore on[ly] packl perld[o] pre[serve] promptf[ind] ptl[ast] ptr[ewind] py3do qa[ll] rec[over] reg[isters] rightb[elow] ru[ntime] sba[ll] sbp[revious] sci scr[iptnames] setl[ocal] sgi sh[ell] sIe sil[ent] sir sm[ap] sno[magic] sp spellu[ndo] sre[wind] srp star[tinsert] sun[hide] sy ta tabfir[st] tabN[ext] tags th[row] tN tr[ewind] un unl verb[ose] vimgrepa[dd] w winp[os] wqa[ll] xa[ll] xnoremenu -syn keyword vimCommand contained ab argd[elete] as[cii] bl[ast] breaka[dd] bufdo cad[dbuffer] ccl[ose] cf[ile] chd[ir] cmapc[lear] cNf comp[iler] cp[revious] cuna[bbrev] del deletep delm[arks] diffo[ff] dig dli[st] dsp[lit] echom[sg] en endt[ry] f fina[lly] foldc[lose] fun gui helpf[ind] i imapc[lear] j[oin] kee[pmarks] lad[dexpr] later lcscope lfdo lgr[ep] lli[st] lne[xt] lo lol[der] lt[ag] lw[indow] menut mks[ession] mod[e] nbc[lose] nmapc[lear] nos[wapfile] o[pen] packloadall po[p] prev[ious] promptr[epl] ptn pts[elect] pydo q[uit] red res[ize] ru rv[iminfo] sbf[irst] sbr[ewind] scI scs sf[ind] sgI si sig sim[alt] sIr sme snoreme spe spellw[rong] srg st startr[eplace] sunme syn tab tabl[ast] tabo[nly] tc[l] tj[ump] tn[ext] try una[bbreviate] unlo[ckvar] ve[rsion] vi[sual] wa[ll] win[size] w[rite] x[it] xprop -syn keyword vimCommand contained abc[lear] argdo au bm[odified] breakd[el] b[uffer] cadde[xpr] cd cfir[st] che[ckpath] cn cnf[ile] con cq[uit] cw[indow] delc[ommand] deletl delp diffp[atch] dig[raphs] do e echon endf endw[hile] f[ile] fin[d] folddoc[losed] fu[nction] gvim helpg[rep] ia in ju[mps] keepp[atterns] laddf[ile] lb[uffer] ld[o] lf[ile] lgrepa[dd] lmak[e] lN[ext] loadk lop[en] lua ma menut[ranslate] mksp[ell] m[ove] nb[key] noa nu[mber] opt[ions] pc[lose] popu p[rint] ps[earch] ptN pu[t] pyf[ile] quita[ll] redi[r] ret[ab] rub[y] sal[l] sbl[ast] sb[uffer] scl scscope sfir[st] sgl sI sIg sin sl smenu snoremenu spelld[ump] sp[lit] sri sta[g] stj[ump] sunmenu sync tabc[lose] tabm[ove] tabp[revious] tcld[o] tl[ast] tN[ext] ts[elect] u[ndo] uns[ilent] vert[ical] viu[sage] wh[ile] wn[ext] ws[verb] xmapc[lear] xunme -syn keyword vimCommand contained abo[veleft] arge[dit] bad[d] bn[ext] breakl[ist] buffers caddf[ile] cdo cgetb[uffer] checkt[ime] cN cNf[ile] conf[irm] cr[ewind] d delel deletp dep diffpu[t] dir doau ea e[dit] endfo[r] ene[w] files fini[sh] foldd[oopen] g h helpt[ags] iabc[lear] intro k l lan lc[d] le[ft] lfir[st] lh[elpgrep] lmapc[lear] lnf loadkeymap lpf[ile] luado mak[e] mes mkv mz nbs[tart] noautocmd o ownsyntax pe popu[p] pro pta[g] ptn[ext] pw[d] py[thon] r red[o] retu[rn] rubyd[o] san[dbox] sbm[odified] sc scp se[t] sg sgn sic sign sIn sla[st] smile so spe[llgood] spr[evious] srI star st[op] sus[pend] syncbind tabd[o] tabN tabr[ewind] tclf[ile] tm to[pleft] tu undoj[oin] up[date] vi vmapc[lear] win wN[ext] wundo xme xunmenu -syn keyword vimCommand contained al[l] argg[lobal] ba[ll] bN[ext] br[ewind] bun[load] cal[l] ce[nter] cgete[xpr] cl cnew[er] col[der] con[tinue] cs de delep delf di diffs[plit] di[splay] dp earlier el[se] endfun ex filet fir[st] foldo[pen] go[to] ha[rdcopy] hi if is[earch] keepa la lan[guage] lch[dir] lefta[bove] lgetb[uffer] l[ist] lN lNf lo[adview] lp[revious] luafile ma[rk] messages mkvie[w] mzf[ile] ne noh[lsearch] ol[dfiles] p ped[it] pp[op] profd[el] ptf[irst] ptN[ext] py python3 re redr[aw] rew[ind] rubyf[ile] sa[rgument] sbn[ext] sce scr setf[iletype] sgc sgp sIc sil sip sl[eep] sn[ext] sor[t] spelli[nfo] sr srl start stopi[nsert] sv[iew] syntime tabe[dit] tabnew tabs te[aroff] tm[enu] tp[revious] tu[nmenu] undol[ist] v vie[w] vne[w] winc[md] wp[revious] wv[iminfo] xmenu xwininfo -syn keyword vimCommand contained ar argl[ocal] bd[elete] bo[tright] bro[wse] bw[ipeout] cat[ch] cex[pr] cg[etfile] cla[st] cn[ext] colo[rscheme] cope[n] cscope debug d[elete] delf[unction] dif difft[his] dj[ump] dr[op] ec elsei[f] endf[unction] exi[t] filetype fix[del] for gr[ep] h[elp] hid[e] ij[ump] isp[lit] keepalt lad la[st] lcl[ose] lex[pr] lgete[xpr] ll lne lnf[ile] loc[kmarks] lr[ewind] lv[imgrep] marks mk mkv[imrc] mz[scheme] new nor omapc[lear] pa[ckadd] pe[rl] pr prof[ile] ptj[ump] ptp[revious] py3 q r[ead] redraws[tatus] ri[ght] rundo sav[eas] sbN[ext] scg scripte[ncoding] setg[lobal] sge sgr sie sIl sIp sm[agic] sN[ext] so[urce] spellr[epall] src srn startg[replace] sts[elect] sw[apname] t tabf[ind] tabn[ext] ta[g] tf[irst] tn tr u unh[ide] ve vim[grep] vs[plit] windo wq x xnoreme y[ank] -syn keyword vimCommand contained arga[dd] ar[gs] bel[owright] bp[revious] bu c cb[uffer] cf c[hange] cl[ist] cN[ext] com co[py] +syn keyword vimCommand contained a arga[dd] argu[ment] bad[d] bn[ext] breakd[el] bw[ipeout] cadde[xpr] ccl[ose] cfdo chd[ir] cmapc[lear] colo[rscheme] cope[n] cscope debugg[reedy] deletl dep diffpu[t] dl ds[earch] echoe[rr] en[dif] ex filetype fo[ld] fu[nction] gvim helpt[ags] iabc[lear] intro k keepp[atterns] lad[dexpr] later lcs lex[pr] lgetb[uffer] ll lne[xt] loadkeymap lp[revious] lua lw[indow] mat[ch] mks[ession] mz[scheme] nbs[tart] noh[lsearch] o[pen] ownsyntax pc[lose] popu[p] prof[ile] ptN[ext] ptn[ext] pw[d] pyf[ile] r[ead] redraws[tatus] rew[ind] rubyd[o] sIc sIp san[dbox] sbf[irst] sbr[ewind] sci scs setl[ocal] sgc sgp sie sin sm[agic] sn[ext] sor[t] spellr[epall] srI srl star[tinsert] sts[elect] sv[iew] syncbind tab tabf[ind] tabnew tags tf[irst] tn[ext] ts[elect] undol[ist] up[date] vi[sual] vmapc[lear] wa[ll] winp[os] ws[verb] xmapc[lear] xprop +syn keyword vimCommand contained ab argd[elete] as[cii] bd[elete] bo[tright] breakl[ist] cN[ext] caddf[ile] cd cfir[st] che[ckpath] cn[ext] com cp[revious] cstag delc[ommand] deletp di[splay] diffs[plit] dli[st] dsp[lit] echom[sg] endf[unction] exi[t] fin[d] foldc[lose] g h[elp] hi if is[earch] kee[pmarks] lN[ext] laddb[uffer] lb[uffer] lcscope lf[ile] lgete[xpr] lla[st] lnew[er] loc[kmarks] lpf[ile] luado m[ove] menut[ranslate] mksp[ell] mzf[ile] new nor ol[dfiles] p[rint] pe[rl] pp[op] profd[el] pta[g] ptp[revious] py3 python3 rec[over] reg[isters] ri[ght] rubyf[ile] sIe sIr sav[eas] sbl[ast] sc scl scscope sf[ind] sge sgr sig sip sm[ap] sno[magic] sp[lit] spellu[ndo] src srn startg[replace] sun[hide] sw[apname] syntime tabN[ext] tabfir[st] tabo[nly] tc[l] th[row] to[pleft] tu[nmenu] unh[ide] v vie[w] vne[w] wh[ile] wn[ext] wundo xme xunme +syn keyword vimCommand contained abc[lear] argdo au bel[owright] bp[revious] bro[wse] cNf[ile] cal[l] cdo cg[etfile] checkt[ime] cnew[er] comc[lear] cpf[ile] cuna[bbrev] delel delf[unction] dif[fupdate] difft[his] do e[dit] echon endfo[r] exu[sage] fina[lly] foldd[oopen] go[to] ha[rdcopy] hid[e] ij[ump] isp[lit] keepa lNf[ile] laddf[ile] lc[d] ld[o] lfdo lgr[ep] lli[st] lnf[ile] lockv[ar] lr[ewind] luafile ma[rk] mes mkv[imrc] n[ext] nmapc[lear] nore omapc[lear] pa[ckadd] ped[it] pre[serve] promptf[ind] ptf[irst] ptr[ewind] py3do q[uit] red[o] res[ize] rightb[elow] rundo sIg sN[ext] sbN[ext] sbm[odified] scI scp se[t] sfir[st] sgi sh[ell] sign sir sme snoreme spe[llgood] spellw[rong] sre[wind] srp startr[eplace] sunme sy t tabc[lose] tabl[ast] tabp[revious] tcld[o] tj[ump] tp[revious] u[ndo] unl ve[rsion] vim[grep] vs[plit] win[size] wp[revious] wv[iminfo] xmenu xunmenu +syn keyword vimCommand contained abo[veleft] arge[dit] bN[ext] bf[irst] br[ewind] bufdo c[hange] cat[ch] ce[nter] cgetb[uffer] cl[ist] cnf[ile] comp[iler] cq[uit] cw[indow] delep dell diffg[et] dig[raphs] doau ea el[se] endt[ry] f[ile] fini[sh] folddoc[losed] gr[ep] helpc[lose] his[tory] il[ist] iuna[bbrev] keepalt l[ist] lan[guage] lch[dir] le[ft] lfir[st] lgrepa[dd] lmak[e] lo[adview] lol[der] ls lv[imgrep] mak[e] messages mkvie[w] nb[key] noa nos[wapfile] on[ly] packl perld[o] prev[ious] promptr[epl] ptj[ump] pts[elect] py[thon] qa[ll] redi[r] ret[ab] ru[ntime] rv[iminfo] sIl sa[rgument] sb[uffer] sbn[ext] sce scr[iptnames] setf[iletype] sg sgl si sil[ent] sl[eep] smenu snoremenu spelld[ump] spr[evious] srg st[op] stj[ump] sunmenu syn tN[ext] tabd[o] tabm[ove] tabr[ewind] tclf[ile] tl[ast] tr[ewind] una[bbreviate] unlo[ckvar] verb[ose] vimgrepa[dd] wN[ext] winc[md] wq x[it] xnoreme xwininfo +syn keyword vimCommand contained al[l] argg[lobal] b[uffer] bl[ast] brea[k] buffers cabc[lear] cb[uffer] cex[pr] cgete[xpr] cla[st] co[py] con[tinue] cr[ewind] d[elete] deletel delm[arks] diffo[ff] dir dp earlier elsei[f] endw[hile] files fir[st] foldo[pen] grepa[dd] helpf[ind] i imapc[lear] j[oin] keepj[umps] la[st] lat lcl[ose] lefta[bove] lg[etfile] lh[elpgrep] lmapc[lear] loadk lop[en] lt[ag] lvimgrepa[dd] marks mk[exrc] mod[e] nbc[lose] noautocmd nu[mber] opt[ions] packloadall po[p] pro ps[earch] ptl[ast] pu[t] pydo quita[ll] redr[aw] retu[rn] rub[y] sI sIn sal[l] sba[ll] sbp[revious] scg scripte[ncoding] setg[lobal] sgI sgn sic sim[alt] sla[st] smile so[urce] spelli[nfo] sr sri sta[g] stopi[nsert] sus[pend] sync ta[g] tabe[dit] tabn[ext] tabs te[aroff] tm[enu] try undoj[oin] uns[ilent] vert[ical] viu[sage] w[rite] windo wqa[ll] xa[ll] xnoremenu y[ank] +syn keyword vimCommand contained ar[gs] argl[ocal] ba[ll] bm[odified] breaka[dd] bun[load] cad[dbuffer] cc cf[ile] changes clo[se] col[der] conf[irm] cs debug deletep delp diffp[atch] dj[ump] dr[op] ec em[enu] ene[w] filet fix[del] for gui helpg[rep] ia in ju[mps] syn match vimCommand contained "\" syn keyword vimStdPlugin contained DiffOrig Man N[ext] P[rint] S TOhtml XMLent XMLns " vimOptions are caught only when contained in a vimSet {{{2 -syn keyword vimOption contained acd ambw arshape background ballooneval bg bl brk buftype cf cinkeys cmdwinheight com conceallevel cpoptions cscopetag csto debug dict dir eb emo equalalways eventignore fde fdt fic fillchars fmr foldlevel foldtext fsync gfs gtl guioptions hf hk hlsearch imactivatekey imi include inex isi js kp lcs listchars lsp makeef maxmapdepth mfd mmd modified mousemodel msm numberwidth operatorfunc paste perldll pm previewwindow printmbfont pythondll redrawtime revins ro ruler scb scs sessionoptions shellquote shiftround showfulltag sidescrolloff smarttab sp spf srr startofline suffixes switchbuf ta taglength tbidi termbidi tgst titleold top ttimeoutlen ttyscroll ul ur verbosefile visualbell wcm wi wildmenu winfixwidth wm wrapscan -syn keyword vimOption contained ai anti autochdir backspace balloonexpr bh bo browsedir casemap cfu cino cmp comments confirm cpt cscopetagorder csverb deco dictionary directory ed emoji equalprg ex fdi fen fileencoding fixendofline fo foldlevelstart formatexpr ft gfw gtt guipty hh hkmap ic imaf iminsert includeexpr inf isident key langmap linebreak lm luadll makeprg maxmem mh mmp more mouses mzq nuw opfunc pastetoggle pex pmbcs printdevice printoptions pythonthreedll regexpengine ri rop rulerformat scr sect sft shellredir shiftwidth showmatch siso smc spc spl ss statusline suffixesadd sws tabline tagrelative tbis termencoding thesaurus titlestring tpm ttm ttytype undodir ut vfile vop wd wic wildmode winheight wmh write -syn keyword vimOption contained akm antialias autoindent backup bdir bin bomb bs cb ch cinoptions cms commentstring consk crb cscopeverbose cuc def diff display edcompatible enc errorbells expandtab fdl fenc fileencodings fixeol foldclose foldmarker formatlistpat gcr ghr guicursor guitablabel hi hkmapp icon imak ims incsearch infercase isk keymap langmenu lines lmap lw mat maxmempattern mis mmt mouse mouseshape mzquantum odev osfiletype patchexpr pexpr pmbfn printencoding prompt qe relativenumber rightleft rs runtimepath scroll sections sh shellslash shm showmode sj smd spell splitbelow ssl stl sw sxe tabpagemax tags tbs terse tildeop tl tr tty tw undofile vb vi wa weirdinvert wig wildoptions winminheight wmnu writeany -syn keyword vimOption contained al ar autoread backupcopy bdlay binary breakat bsdir cc charconvert cinw co compatible conskey cryptmethod cspc cul define diffexpr dy ef encoding errorfile exrc fdls fencs fileformat fk foldcolumn foldmethod formatoptions gd go guifont guitabtooltip hid hkp iconstring imc imsearch inde insertmode iskeyword keymodel langnoremap linespace lnr lz matchpairs maxmemtot mkspellmem mod mousef mouset nf oft pa patchmode pfn popt printexpr pt quoteescape remap rightleftcmd rtp sb scrollbind secure shcf shelltemp shortmess showtabline slm sn spellcapcheck splitright ssop stmp swapfile sxq tabstop tagstack tc textauto timeout tm ts ttybuiltin tx undolevels vbs viewdir wak wfh wildchar wim winminwidth wmw writebackup -syn keyword vimOption contained aleph arab autowrite backupdir belloff biosk breakindent bsk ccv ci cinwords cocu complete copyindent cscopepathcomp csprg cursorbind delcombine diffopt ea efm endofline errorformat fcl fdm fex fileformats fkmap foldenable foldminlines formatprg gdefault gp guifontset helpfile hidden hl ignorecase imcmdline imsf indentexpr is isp keywordprg laststatus lisp loadplugins ma matchtime mco ml modeline mousefocus mousetime nrformats ofu packpath path ph pp printfont pumheight rdt renderoptions rl ru sbo scrolljump sel shell shelltype shortname shq sm so spellfile spr st sts swapsync syn tag tal tcldll textmode timeoutlen to tsl ttyfast uc undoreload vdir viewoptions warn wfw wildcharm winaltkeys winwidth wop writedelay -syn keyword vimOption contained allowrevins arabic autowriteall backupext beval bioskey breakindentopt bt cd cin clipboard cole completefunc cot cscopeprg csqf cursorcolumn dex digraph ead ei eol esckeys fcs fdn ff fileignorecase flp foldexpr foldnestmax fp gfm grepformat guifontwide helpheight highlight hlg im imd imstatusfunc indentkeys isf isprint km lazyredraw lispwords lpl macatsui maxcombine mef mls modelines mousehide mp nu omnifunc para pdev pheader preserveindent printheader pvh re report rlc rubydll sbr scrolloff selection shellcmdflag shellxescape showbreak si smartcase softtabstop spelllang sps sta su swb synmaxcol tagbsearch tb tenc textwidth title toolbar tsr ttym udf updatecount ve viminfo wb wh wildignore window wiv wrap ws -syn keyword vimOption contained altkeymap arabicshape aw backupskip bex bk bri bufhidden cdpath cindent cm colorcolumn completeopt cp cscopequickfix csre cursorline dg dip eadirection ek ep et fdc fdo ffs filetype fml foldignore foldopen fs gfn grepprg guiheadroom helplang history hls imactivatefunc imdisable inc indk isfname joinspaces kmp lbr list ls magic maxfuncdepth menuitems mm modifiable mousem mps number opendevice paragraphs penc pi previewheight printmbcharset pvw readonly restorescreen rnu ruf sc scrollopt selectmode shellpipe shellxquote showcmd sidescroll smartindent sol spellsuggest sr stal sua swf syntax tagcase tbi term tf titlelen toolbariconsize ttimeout ttymouse udir updatetime verbose virtualedit wc whichwrap wildignorecase winfixheight wiw wrapmargin ww -syn keyword vimOption contained ambiwidth ari awa balloondelay bexpr bkc briopt buflisted cedit cink cmdheight columns concealcursor cpo cscoperelative cst cwh +syn keyword vimOption contained acd ambw arshape background ballooneval bg bomb bs cb ch cinoptions cms commentstring copyindent cryptmethod cscopeverbose csverb debug dict dir eb emo equalalways eventignore fde fdt fic fillchars fmr foldlevel foldtext fsync gfs gtl guioptions hf hk hlsearch imactivatekey imi include inex isi js kp lcs listchars lsp makeef maxmapdepth mfd mmd modified mousemodel msm numberwidth operatorfunc paste perldll pm previewwindow printmbfont pythondll redrawtime revins ro ruler scb scs sessionoptions shellquote shiftround showfulltag sidescrolloff smarttab sp spf srr startofline suffixes switchbuf ta taglength tbidi termbidi tgst titleold top ttimeoutlen ttyscroll ul ur verbosefile visualbell wcm wi wildmenu winfixwidth wm wrapscan +syn keyword vimOption contained ai anti autochdir backspace balloonexpr bh breakat bsdir cc charconvert cinw co compatible cot cscopepathcomp cspc cuc deco dictionary directory ed emoji equalprg ex fdi fen fileencoding fixendofline fo foldlevelstart formatexpr ft gfw gtt guipty hh hkmap ic imaf iminsert includeexpr inf isident key langmap linebreak lm luadll makeprg maxmem mh mmp more mouses mzq nuw opfunc pastetoggle pex pmbcs printdevice printoptions pythonthreedll regexpengine ri rop rulerformat scr sect sft shellredir shiftwidth showmatch siso smc spc spl ss statusline suffixesadd sws tabline tagrelative tbis termencoding thesaurus titlestring tpm ttm ttytype undodir ut vfile vop wd wic wildmode winheight wmh write +syn keyword vimOption contained akm antialias autoindent backup bdir bin breakindent bsk ccv ci cinwords cocu complete cp cscopeprg csprg cul def diff display edcompatible enc errorbells expandtab fdl fenc fileencodings fixeol foldclose foldmarker formatlistpat gcr ghr guicursor guitablabel hi hkmapp icon imak ims incsearch infercase isk keymap langmenu lines lmap lw mat maxmempattern mis mmt mouse mouseshape mzquantum odev osfiletype patchexpr pexpr pmbfn printencoding prompt qe relativenumber rightleft rs runtimepath scroll sections sh shellslash shm showmode sj smd spell splitbelow ssl stl sw sxe tabpagemax tags tbs terse tildeop tl tr tty tw undofile vb vi wa weirdinvert wig wildoptions winminheight wmnu writeany +syn keyword vimOption contained al ar autoread backupcopy bdlay binary breakindentopt bt cd cin clipboard cole completefunc cpo cscopequickfix csqf cursorbind define diffexpr dy ef encoding errorfile exrc fdls fencs fileformat fk foldcolumn foldmethod formatoptions gd go guifont guitabtooltip hid hkp iconstring imc imsearch inde insertmode iskeyword keymodel langnoremap linespace lnr lz matchpairs maxmemtot mkspellmem mod mousef mouset nf oft pa patchmode pfn popt printexpr pt quoteescape remap rightleftcmd rtp sb scrollbind secure shcf shelltemp shortmess showtabline slm sn spellcapcheck splitright ssop stmp swapfile sxq tabstop tagstack tc textauto timeout tm ts ttybuiltin tx undolevels vbs viewdir wak wfh wildchar wim winminwidth wmw writebackup +syn keyword vimOption contained aleph arab autowrite backupdir belloff bk bri bufhidden cdpath cindent cm colorcolumn completeopt cpoptions cscoperelative csre cursorcolumn delcombine diffopt ea efm endofline errorformat fcl fdm fex fileformats fkmap foldenable foldminlines formatprg gdefault gp guifontset helpfile hidden hl ignorecase imcmdline imsf indentexpr is isp keywordprg laststatus lisp loadplugins ma matchtime mco ml modeline mousefocus mousetime nrformats ofu packpath path ph pp printfont pumheight rdt renderoptions rl ru sbo scrolljump sel shell shelltype shortname shq sm so spellfile spr st sts swapsync syn tag tal tcldll textmode timeoutlen to tsl ttyfast uc undoreload vdir viewoptions warn wfw wildcharm winaltkeys winwidth wop writedelay +syn keyword vimOption contained allowrevins arabic autowriteall backupext beval bkc briopt buflisted cedit cink cmdheight columns concealcursor cpt cscopetag cst cursorline dex digraph ead ei eol esckeys fcs fdn ff fileignorecase flp foldexpr foldnestmax fp gfm grepformat guifontwide helpheight highlight hlg im imd imstatusfunc indentkeys isf isprint km lazyredraw lispwords lpl macatsui maxcombine mef mls modelines mousehide mp nu omnifunc para pdev pheader preserveindent printheader pvh re report rlc rubydll sbr scrolloff selection shellcmdflag shellxescape showbreak si smartcase softtabstop spelllang sps sta su swb synmaxcol tagbsearch tb tenc textwidth title toolbar tsr ttym udf updatecount ve viminfo wb wh wildignore window wiv wrap ws +syn keyword vimOption contained altkeymap arabicshape aw backupskip bex bl brk buftype cf cinkeys cmdwinheight com conceallevel crb cscopetagorder csto cwh dg dip eadirection ek ep et fdc fdo ffs filetype fml foldignore foldopen fs gfn grepprg guiheadroom helplang history hls imactivatefunc imdisable inc indk isfname joinspaces kmp lbr list ls magic maxfuncdepth menuitems mm modifiable mousem mps number opendevice paragraphs penc pi previewheight printmbcharset pvw readonly restorescreen rnu ruf sc scrollopt selectmode shellpipe shellxquote showcmd sidescroll smartindent sol spellsuggest sr stal sua swf syntax tagcase tbi term tf titlelen toolbariconsize ttimeout ttymouse udir updatetime verbose virtualedit wc whichwrap wildignorecase winfixheight wiw wrapmargin ww +syn keyword vimOption contained ambiwidth ari awa balloondelay bexpr bo browsedir casemap cfu cino cmp comments confirm " vimOptions: These are the turn-off setting variants {{{2 -syn keyword vimOption contained noacd noallowrevins noantialias noarabic noarshape noautoread noaw noballooneval nobinary nobk nobreakindent nocf nocindent noconsk nocp nocscopetag nocst nocul nocursorline nodg noea noedcompatible noeol noesckeys noexpandtab nofic nofixeol nofoldenable nogd nohid nohkmap nohls noicon noimc noimdisable noinfercase nojoinspaces nolangnoremap nolbr nolisp nolnr nolpl noma nomagic noml nomodeline nomodified nomousef nomousehide nonumber noopendevice nopi nopreviewwindow nopvw norelativenumber norestorescreen nori norl noro noru nosb noscb noscs nosft noshelltemp noshortname noshowfulltag noshowmode nosm nosmartindent nosmd nosol nosplitbelow nospr nossl nostartofline noswapfile nota notagrelative notbi notbs noterse notextmode notgst notimeout noto notr nottybuiltin notx noundofile novisualbell nowarn noweirdinvert nowfw nowildignorecase nowinfixheight nowiv nowrap nowrite nowritebackup -syn keyword vimOption contained noai noaltkeymap noar noarabicshape noautochdir noautowrite noawa nobeval nobiosk nobl nobri noci nocompatible noconskey nocrb nocscopeverbose nocsverb nocursorbind nodeco nodiff noeb noek noequalalways noet noexrc nofileignorecase nofk nofs nogdefault nohidden nohkmapp nohlsearch noignorecase noimcmdline noincsearch noinsertmode nojs nolazyredraw nolinebreak nolist noloadplugins nolz nomacatsui nomh nomod nomodifiable nomore nomousefocus nonu noodev nopaste nopreserveindent noprompt noreadonly noremap norevins norightleft nornu nors noruler nosc noscrollbind nosecure noshellslash noshiftround noshowcmd noshowmatch nosi nosmartcase nosmarttab nosn nospell nosplitright nosr nosta nostmp noswf notagbsearch notagstack notbidi notermbidi notextauto notf notildeop notitle notop nottimeout nottyfast noudf novb nowa nowb nowfh nowic nowildmenu nowinfixwidth nowmnu nowrapscan nowriteany nows -syn keyword vimOption contained noakm noanti noarab noari noautoindent noautowriteall nobackup nobin nobioskey nobomb nobuflisted nocin noconfirm nocopyindent nocscoperelative nocsre nocuc nocursorcolumn nodelcombine nodigraph noed noendofline noerrorbells noex nofen nofixendofline nofkmap nofsync noguipty nohk nohkp noic noim noimd noinf nois +syn keyword vimOption contained noacd noallowrevins noantialias noarabic noarshape noautoread noaw noballooneval nobinary nobomb nobuflisted nocin noconfirm nocrb nocscopeverbose nocsverb nocursorbind nodeco nodiff noeb noek noequalalways noet noexrc nofileignorecase nofk nofs nogdefault nohidden nohkmapp nohlsearch noignorecase noimcmdline noimdisable noinf noinsertmode nojoinspaces nolangnoremap nolbr nolisp nolnr nolpl noma nomagic noml nomodeline nomodified nomousef nomousehide nonumber noopendevice nopi nopreviewwindow nopvw norelativenumber norestorescreen nori norl noro noru nosb noscb noscs nosft noshelltemp noshortname noshowfulltag noshowmode nosm nosmartindent nosmd nosol nosplitbelow nospr nossl nostartofline noswapfile nota notagrelative notbi notbs noterse notextmode notgst notimeout noto notr nottybuiltin notx noundofile novisualbell nowarn noweirdinvert nowfw nowildignorecase nowinfixheight nowiv nowrap nowrite nowritebackup +syn keyword vimOption contained noai noaltkeymap noar noarabicshape noautochdir noautowrite noawa nobeval nobk nobreakindent nocf nocindent nocopyindent nocscoperelative nocsre nocuc nocursorcolumn nodelcombine nodigraph noed noendofline noerrorbells noex nofen nofixendofline nofkmap nofsync noguipty nohk nohkp noic noim noimd noincsearch noinfercase nois nojs nolazyredraw nolinebreak nolist noloadplugins nolz nomacatsui nomh nomod nomodifiable nomore nomousefocus nonu noodev nopaste nopreserveindent noprompt noreadonly noremap norevins norightleft nornu nors noruler nosc noscrollbind nosecure noshellslash noshiftround noshowcmd noshowmatch nosi nosmartcase nosmarttab nosn nospell nosplitright nosr nosta nostmp noswf notagbsearch notagstack notbidi notermbidi notextauto notf notildeop notitle notop nottimeout nottyfast noudf novb nowa nowb nowfh nowic nowildmenu nowinfixwidth nowmnu nowrapscan nowriteany nows +syn keyword vimOption contained noakm noanti noarab noari noautoindent noautowriteall nobackup nobin nobl nobri noci nocompatible nocp nocscopetag nocst nocul nocursorline nodg noea noedcompatible noeol noesckeys noexpandtab nofic nofixeol nofoldenable nogd nohid nohkmap nohls noicon noimc " vimOptions: These are the invertible variants {{{2 -syn keyword vimOption contained invacd invallowrevins invantialias invarabic invarshape invautoread invaw invballooneval invbinary invbk invbreakindent invcf invcindent invconsk invcp invcscopetag invcst invcul invcursorline invdg invea invedcompatible inveol invesckeys invexpandtab invfic invfixeol invfoldenable invgd invhid invhkmap invhls invicon invimc invimdisable invinfercase invjoinspaces invlangnoremap invlbr invlisp invlnr invlpl invma invmagic invml invmodeline invmodified invmousef invmousehide invnumber invopendevice invpi invpreviewwindow invpvw invrelativenumber invrestorescreen invri invrl invro invru invsb invscb invscs invsft invshelltemp invshortname invshowfulltag invshowmode invsm invsmartindent invsmd invsol invsplitbelow invspr invssl invstartofline invswapfile invta invtagrelative invtbi invtbs invterse invtextmode invtgst invtimeout invto invtr invttybuiltin invtx invundofile invvisualbell invwarn invweirdinvert invwfw invwildignorecase invwinfixheight invwiv invwrap invwrite invwritebackup -syn keyword vimOption contained invai invaltkeymap invar invarabicshape invautochdir invautowrite invawa invbeval invbiosk invbl invbri invci invcompatible invconskey invcrb invcscopeverbose invcsverb invcursorbind invdeco invdiff inveb invek invequalalways invet invexrc invfileignorecase invfk invfs invgdefault invhidden invhkmapp invhlsearch invignorecase invimcmdline invincsearch invinsertmode invjs invlazyredraw invlinebreak invlist invloadplugins invlz invmacatsui invmh invmod invmodifiable invmore invmousefocus invnu invodev invpaste invpreserveindent invprompt invreadonly invremap invrevins invrightleft invrnu invrs invruler invsc invscrollbind invsecure invshellslash invshiftround invshowcmd invshowmatch invsi invsmartcase invsmarttab invsn invspell invsplitright invsr invsta invstmp invswf invtagbsearch invtagstack invtbidi invtermbidi invtextauto invtf invtildeop invtitle invtop invttimeout invttyfast invudf invvb invwa invwb invwfh invwic invwildmenu invwinfixwidth invwmnu invwrapscan invwriteany invws -syn keyword vimOption contained invakm invanti invarab invari invautoindent invautowriteall invbackup invbin invbioskey invbomb invbuflisted invcin invconfirm invcopyindent invcscoperelative invcsre invcuc invcursorcolumn invdelcombine invdigraph inved invendofline inverrorbells invex invfen invfixendofline invfkmap invfsync invguipty invhk invhkp invic invim invimd invinf invis +syn keyword vimOption contained invacd invallowrevins invantialias invarabic invarshape invautoread invaw invballooneval invbinary invbomb invbuflisted invcin invconfirm invcrb invcscopeverbose invcsverb invcursorbind invdeco invdiff inveb invek invequalalways invet invexrc invfileignorecase invfk invfs invgdefault invhidden invhkmapp invhlsearch invignorecase invimcmdline invimdisable invinf invinsertmode invjoinspaces invlangnoremap invlbr invlisp invlnr invlpl invma invmagic invml invmodeline invmodified invmousef invmousehide invnumber invopendevice invpi invpreviewwindow invpvw invrelativenumber invrestorescreen invri invrl invro invru invsb invscb invscs invsft invshelltemp invshortname invshowfulltag invshowmode invsm invsmartindent invsmd invsol invsplitbelow invspr invssl invstartofline invswapfile invta invtagrelative invtbi invtbs invterse invtextmode invtgst invtimeout invto invtr invttybuiltin invtx invundofile invvisualbell invwarn invweirdinvert invwfw invwildignorecase invwinfixheight invwiv invwrap invwrite invwritebackup +syn keyword vimOption contained invai invaltkeymap invar invarabicshape invautochdir invautowrite invawa invbeval invbk invbreakindent invcf invcindent invcopyindent invcscoperelative invcsre invcuc invcursorcolumn invdelcombine invdigraph inved invendofline inverrorbells invex invfen invfixendofline invfkmap invfsync invguipty invhk invhkp invic invim invimd invincsearch invinfercase invis invjs invlazyredraw invlinebreak invlist invloadplugins invlz invmacatsui invmh invmod invmodifiable invmore invmousefocus invnu invodev invpaste invpreserveindent invprompt invreadonly invremap invrevins invrightleft invrnu invrs invruler invsc invscrollbind invsecure invshellslash invshiftround invshowcmd invshowmatch invsi invsmartcase invsmarttab invsn invspell invsplitright invsr invsta invstmp invswf invtagbsearch invtagstack invtbidi invtermbidi invtextauto invtf invtildeop invtitle invtop invttimeout invttyfast invudf invvb invwa invwb invwfh invwic invwildmenu invwinfixwidth invwmnu invwrapscan invwriteany invws +syn keyword vimOption contained invakm invanti invarab invari invautoindent invautowriteall invbackup invbin invbl invbri invci invcompatible invcp invcscopetag invcst invcul invcursorline invdg invea invedcompatible inveol invesckeys invexpandtab invfic invfixeol invfoldenable invgd invhid invhkmap invhls invicon invimc " termcap codes (which can also be set) {{{2 syn keyword vimOption contained t_AB t_al t_bc t_ce t_cl t_Co t_Cs t_CV t_db t_DL t_EI t_F1 t_F2 t_F3 t_F4 t_F5 t_F6 t_F7 t_F8 t_F9 t_fs t_IE t_IS t_k1 t_K1 t_k2 t_k3 t_K3 t_k4 t_K4 t_k5 t_K5 t_k6 t_K6 t_k7 t_K7 t_k8 t_K8 t_k9 t_K9 t_KA t_kb t_kB t_KB t_KC t_kd t_kD t_KD t_ke t_KE t_KF t_KG t_kh t_KH t_kI t_KI t_KJ t_KK t_kl t_KL t_kN t_kP t_kr t_ks t_ku t_le t_mb t_md t_me t_mr t_ms t_nd t_op t_RB t_RI t_RV t_Sb t_se t_Sf t_SI t_so t_sr t_SR t_te t_ti t_ts t_u7 t_ue t_us t_ut t_vb t_ve t_vi t_vs t_WP t_WS t_xn t_xs t_ZH t_ZR @@ -60,12 +59,13 @@ syn match vimOption contained "t_&8" syn match vimOption contained "t_%i" syn match vimOption contained "t_k;" -" unsupported settings: these are supported by vi but don't do anything in vim {{{2 -syn keyword vimErrSetting contained hardtabs ht w1200 w300 w9600 +" unsupported settings: some were supported by vi but don't do anything in vim {{{2 +" others have been dropped along with msdos support +syn keyword vimErrSetting contained bioskey biosk conskey consk autoprint beautify flash graphic hardtabs mesg novice open op optimize redraw slow slowopen sourceany w300 w1200 w9600 hardtabs ht nobioskey nobiosk noconskey noconsk noautoprint nobeautify noflash nographic nohardtabs nomesg nonovice noopen noop nooptimize noredraw noslow noslowopen nosourceany now300 now1200 now9600 w1200 w300 w9600 " 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 CmdUndefined CmdwinEnter CmdwinLeave ColorScheme CompleteDone 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 OptionSet QuickFixCmdPost QuickFixCmdPre QuitPre RemoteReply SessionLoadPost ShellCmdPost ShellFilterPost SourceCmd SourcePre SpellFileMissing StdinReadPost StdinReadPre SwapExists Syntax TabEnter TabLeave TermChanged TermResponse TextChanged TextChangedI 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 CmdUndefined CmdwinEnter CmdwinLeave ColorScheme CompleteDone 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 OptionSet QuickFixCmdPost QuickFixCmdPre QuitPre RemoteReply SessionLoadPost ShellCmdPost ShellFilterPost SourceCmd SourcePre SpellFileMissing StdinReadPost StdinReadPre SwapExists Syntax TabEnter TabLeave TermChanged TermResponse TextChanged TextChangedI User 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 @@ -76,10 +76,10 @@ syn match vimHLGroup contained "Conceal" syn case match " Function Names {{{2 -syn keyword vimFuncName contained abs and arglistid assert_exception assert_true browsedir bufname byteidx changenr ch_evalraw ch_log ch_readraw ch_status complete copy cscope_connection did_filetype empty executable exp extend filewritable findfile fmod foldclosed foldtext function getbufline getcharmod getcmdpos getcurpos getfperm getftype getmatches getqflist gettabvar getwinposy glob2regpat has_key histadd histnr hostname index inputlist inputsecret isdirectory items job_setoptions job_stop js_encode keys libcallnr lispindent log10 maparg matchadd matchdelete matchstr min mzeval or pow pumvisible range reltimestr remote_peek remove resolve screenattr screenrow searchpair server2client setcharsearch setline setpos settabvar sha256 simplify sort spellsuggest str2float strdisplaywidth string strridx submatch synID synstack tabpagebuflist tagfiles tanh timer_stop tr undofile values wildmenumode win_findbuf winheight winline winrestview wordcount -syn keyword vimFuncName contained acos append argv assert_fails atan bufexists bufnr byteidxcomp char2nr ch_getbufnr ch_logfile ch_sendexpr cindent complete_add cos cursor diff_filler escape exepath expand feedkeys filter float2nr fnameescape foldclosedend foldtextresult garbagecollect getbufvar getcharsearch getcmdtype getcwd getfsize getline getpid getreg gettabwinvar getwinvar globpath haslocaldir histdel hlexists iconv input inputrestore insert islocked job_getchannel job_start join json_decode len line localtime luaeval mapcheck matchaddpos matchend matchstrpos mkdir nextnonblank pathshorten prevnonblank py3eval readfile remote_expr remote_read rename reverse screenchar search searchpairpos serverlist setcmdpos setloclist setqflist settabwinvar shellescape sin soundfold split str2nr strftime strlen strtrans substitute synIDattr system tabpagenr taglist tempname tolower trunc undotree virtcol winbufnr win_getid win_id2tabwin winnr winsaveview writefile -syn keyword vimFuncName contained add argc asin assert_false atan2 buflisted bufwinnr call ch_close ch_getjob ch_open ch_sendraw clearmatches complete_check cosh deepcopy diff_hlID eval exists expr8 filereadable finddir floor fnamemodify foldlevel foreground get getchar getcmdline getcmdwintype getfontname getftime getloclist getpos getregtype getwinposx glob has hasmapto histget hlID indent inputdialog inputsave invert isnan job_info job_status js_decode json_encode libcall line2byte log map match matcharg matchlist max mode nr2char perleval printf pyeval reltime remote_foreground remote_send repeat round screencol searchdecl searchpos setbufvar setfperm setmatches setreg setwinvar shiftwidth sinh spellbadword sqrt strchars stridx strpart strwidth synconcealed synIDtrans systemlist tabpagewinnr tan timer_start toupper type uniq visualmode wincol win_gotoid win_id2win winrestcmd winwidth xor -syn keyword vimFuncName contained alloc_fail argidx assert_equal assert_match browse bufloaded byte2line ceil ch_evalexpr ch_info ch_read ch_setoptions col confirm count delete disable_char_avail_for_testing eventhandler +syn keyword vimFuncName contained abs and arglistid assert_exception assert_notequal atan2 buflisted bufwinnr call ch_close ch_getjob ch_open ch_sendraw clearmatches complete_check cosh deepcopy diff_hlID eval exists extend filewritable findfile fmod foldclosed foldtext function getbufline getcharmod getcmdpos getcurpos getfperm getftype getmatches getqflist gettabvar getwinposy glob2regpat has_key histadd histnr hostname index inputlist inputsecret isdirectory items job_setoptions job_stop js_encode keys libcallnr lispindent log10 maparg matchadd matchdelete matchstr min mzeval or pow pumvisible range reltimestr remote_peek remove resolve screenattr screenrow searchpair server2client setcharsearch setline setpos settabvar sha256 simplify sort spellsuggest str2float strdisplaywidth string strridx submatch synID synstack tabpagebuflist tagfiles tanh timer_stop tr undofile values wildmenumode win_findbuf winheight winline winrestview wordcount +syn keyword vimFuncName contained acos append argv assert_fails assert_notmatch browse bufloaded byte2line ceil ch_evalexpr ch_info ch_read ch_setoptions col confirm count delete disable_char_avail_for_testing eventhandler exp feedkeys filter float2nr fnameescape foldclosedend foldtextresult garbagecollect getbufvar getcharsearch getcmdtype getcwd getfsize getline getpid getreg gettabwinvar getwinvar globpath haslocaldir histdel hlexists iconv input inputrestore insert islocked job_getchannel job_start join json_decode len line localtime luaeval mapcheck matchaddpos matchend matchstrpos mkdir nextnonblank pathshorten prevnonblank py3eval readfile remote_expr remote_read rename reverse screenchar search searchpairpos serverlist setcmdpos setloclist setqflist settabwinvar shellescape sin soundfold split str2nr strftime strlen strtrans substitute synIDattr system tabpagenr taglist tempname tolower trunc undotree virtcol winbufnr win_getid win_id2tabwin winnr winsaveview writefile +syn keyword vimFuncName contained add argc asin assert_false assert_true browsedir bufname byteidx changenr ch_evalraw ch_log ch_readraw ch_status complete copy cscope_connection did_filetype empty executable expand filereadable finddir floor fnamemodify foldlevel foreground get getchar getcmdline getcmdwintype getfontname getftime getloclist getpos getregtype getwinposx glob has hasmapto histget hlID indent inputdialog inputsave invert isnan job_info job_status js_decode json_encode libcall line2byte log map match matcharg matchlist max mode nr2char perleval printf pyeval reltime remote_foreground remote_send repeat round screencol searchdecl searchpos setbufvar setfperm setmatches setreg setwinvar shiftwidth sinh spellbadword sqrt strchars stridx strpart strwidth synconcealed synIDtrans systemlist tabpagewinnr tan timer_start toupper type uniq visualmode wincol win_gotoid win_id2win winrestcmd winwidth xor +syn keyword vimFuncName contained alloc_fail argidx assert_equal assert_match atan bufexists bufnr byteidxcomp char2nr ch_getbufnr ch_logfile ch_sendexpr cindent complete_add cos cursor diff_filler escape exepath "--- syntax here and above generated by mkvimvim --- " Special Vim Highlighting (not automatic) {{{1 @@ -151,6 +151,13 @@ if exists("g:vimsyntax_noerror") let g:vimsyn_noerror= g:vimsyntax_noerror endif +" Variable options {{{2 +if exists("g:vim_maxlines") + let s:vimsyn_maxlines= g:vim_maxlines +else + let s:vimsyn_maxlines= 60 +endif + " Numbers {{{2 " ======= syn match vimNumber "\<\d\+\%(\.\d\+\%([eE][+-]\=\d\+\)\=\)\=" skipwhite nextgroup=vimGlobal,vimSubst,vimCommand @@ -759,9 +766,10 @@ if !filereadable(s:mzschemepath) endif if (g:vimsyn_embed =~# 'm' && has("mzscheme")) && filereadable(s:mzschemepath) unlet! b:current_syntax - let iskKeep= &isk + let s:iskKeep= &isk exe "syn include @vimMzSchemeScript ".s:mzschemepath - let &isk= iskKeep + let &isk= s:iskKeep + unlet s:iskKeep VimFoldm syn region vimMzSchemeRegion matchgroup=vimScriptDelim start=+mz\%[scheme]\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimMzSchemeScript VimFoldm syn region vimMzSchemeRegion matchgroup=vimScriptDelim start=+mz\%[scheme]\s*<<\s*$+ end=+\.$+ contains=@vimMzSchemeScript syn cluster vimFuncBodyList add=vimMzSchemeRegion @@ -776,11 +784,7 @@ unlet s:mzschemepath if exists("g:vimsyn_minlines") exe "syn sync minlines=".g:vimsyn_minlines endif -if exists("g:vimsyn_maxlines") - exe "syn sync maxlines=".g:vimsyn_maxlines -else - syn sync maxlines=60 -endif +exe "syn sync maxlines=".s:vimsyn_maxlines syn sync linecont "^\s\+\\" syn sync match vimAugroupSyncA groupthere NONE "\\s\+[eE][nN][dD]" diff --git a/runtime/vim.desktop b/runtime/vim.desktop index b6caf7b578e775..d4ab844e767926 100644 --- a/runtime/vim.desktop +++ b/runtime/vim.desktop @@ -74,6 +74,7 @@ TryExec=vim Exec=vim %F Terminal=true Type=Application +Keywords=Text;editor; Icon=gvim Categories=Utility;TextEditor; StartupNotify=false From 3780bb923a688e0051a9a23474eeb38a8acb695a Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 12 Apr 2016 22:18:53 +0200 Subject: [PATCH 05/29] patch 7.4.1725 Problem: Compiler errors for non-ANSI compilers. Solution: Remove // comment. Remove comma at end of enum. (Michael Jarvis) --- src/eval.c | 4 ++-- src/version.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/eval.c b/src/eval.c index 0c270b928d4c68..a14a721a0e0276 100644 --- a/src/eval.c +++ b/src/eval.c @@ -7005,7 +7005,7 @@ garbage_collect(void) #endif #ifdef FEAT_JOB_CHANNEL -// abort = abort || set_ref_in_channel(copyID); + abort = abort || set_ref_in_channel(copyID); #endif if (!abort) @@ -9472,7 +9472,7 @@ typedef enum ASSERT_NOTEQUAL, ASSERT_MATCH, ASSERT_NOTMATCH, - ASSERT_OTHER, + ASSERT_OTHER } assert_type_T; static void prepare_assert_error(garray_T*gap); diff --git a/src/version.c b/src/version.c index e422527ef2a506..5ca02192fc9bee 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1725, /**/ 1724, /**/ From 700eefe5a4385fd128f5496e3ca384869752376a Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 13 Apr 2016 21:14:37 +0200 Subject: [PATCH 06/29] patch 7.4.1726 Problem: ANSI compiler complains about string length. Solution: Split long string in two parts. (Michael Jarvis) --- src/ex_cmds.c | 25 +++++++++++++++---------- src/version.c | 2 ++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/ex_cmds.c b/src/ex_cmds.c index b6029793224f25..daac3ae8d635f2 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -7805,21 +7805,26 @@ set_context_in_sign_cmd(expand_T *xp, char_u *arg) void ex_smile(exarg_T *eap UNUSED) { - static char *code = "\34 \4o\14$\4ox\30 \2o\30$\1ox\25 \2o\36$\1o\11 \1o\1$\3 \2$\1 \1o\1$x\5 \1o\1 \1$\1 \2o\10 \1o\44$\1o\7 \2$\1 \2$\1 \2$\1o\1$x\2 \2o\1 \1$\1 \1$\1 \1\"\1$\6 \1o\11$\4 \15$\4 \11$\1o\7 \3$\1o\2$\1o\1$x\2 \1\"\6$\1o\1$\5 \1o\11$\6 \13$\6 \12$\1o\4 \10$x\4 \7$\4 \13$\6 \13$\6 \27$x\4 \27$\4 \15$\4 \16$\2 \3\"\3$x\5 \1\"\3$\4\"\61$\5 \1\"\3$x\6 \3$\3 \1o\62$\5 \1\"\3$\1ox\5 \1o\2$\1\"\3 \63$\7 \3$\1ox\5 \3$\4 \55$\1\"\1 \1\"\6$\5o\4$\1ox\4 \1o\3$\4o\5$\2 \45$\3 \1o\21$x\4 \10$\1\"\4$\3 \42$\5 \4$\10\"x\3 \4\"\7 \4$\4 \1\"\34$\1\"\6 \1o\3$x\16 \1\"\3$\1o\5 \3\"\22$\1\"\2$\1\"\11 \3$x\20 \3$\1o\12 \1\"\2$\2\"\6$\4\"\13 \1o\3$x\21 \4$\1o\40 \1o\3$\1\"x\22 \1\"\4$\1o\6 \1o\6$\1o\1\"\4$\1o\10 \1o\4$x\24 \1\"\5$\2o\5 \2\"\4$\1o\5$\1o\3 \1o\4$\2\"x\27 \2\"\5$\4o\2 \1\"\3$\1o\11$\3\"x\32 \2\"\7$\2o\1 \12$x\42 \4\"\13$x\46 \14$x\47 \12$\1\"x\50 \1\"\3$\4\"x"; + static char *code[] = { + "\34 \4o\14$\4ox\30 \2o\30$\1ox\25 \2o\36$\1o\11 \1o\1$\3 \2$\1 \1o\1$x\5 \1o\1 \1$\1 \2o\10 \1o\44$\1o\7 \2$\1 \2$\1 \2$\1o\1$x\2 \2o\1 \1$\1 \1$\1 \1\"\1$\6 \1o\11$\4 \15$\4 \11$\1o\7 \3$\1o\2$\1o\1$x\2 \1\"\6$\1o\1$\5 \1o\11$\6 \13$\6 \12$\1o\4 \10$x\4 \7$\4 \13$\6 \13$\6 \27$x\4 \27$\4 \15$\4 \16$\2 \3\"\3$x\5 \1\"\3$\4\"\61$\5 \1\"\3$x\6 \3$\3 \1o\62$\5 \1\"\3$\1ox\5 \1o\2$\1\"\3 \63$\7 \3$\1ox\5 \3$\4 \55$\1\"\1 \1\"\6$", + "\5o\4$\1ox\4 \1o\3$\4o\5$\2 \45$\3 \1o\21$x\4 \10$\1\"\4$\3 \42$\5 \4$\10\"x\3 \4\"\7 \4$\4 \1\"\34$\1\"\6 \1o\3$x\16 \1\"\3$\1o\5 \3\"\22$\1\"\2$\1\"\11 \3$x\20 \3$\1o\12 \1\"\2$\2\"\6$\4\"\13 \1o\3$x\21 \4$\1o\40 \1o\3$\1\"x\22 \1\"\4$\1o\6 \1o\6$\1o\1\"\4$\1o\10 \1o\4$x\24 \1\"\5$\2o\5 \2\"\4$\1o\5$\1o\3 \1o\4$\2\"x\27 \2\"\5$\4o\2 \1\"\3$\1o\11$\3\"x\32 \2\"\7$\2o\1 \12$x\42 \4\"\13$x\46 \14$x\47 \12$\1\"x\50 \1\"\3$\4\"x" + }; char *p; int n; + int i; msg_start(); msg_putchar('\n'); - for (p = code; *p != NUL; ++p) - if (*p == 'x') - msg_putchar('\n'); - else - for (n = *p++; n > 0; --n) - if (*p == 'o' || *p == '$') - msg_putchar_attr(*p, hl_attr(HLF_L)); - else - msg_putchar(*p); + for (i = 0; i < 2; ++i) + for (p = code[i]; *p != NUL; ++p) + if (*p == 'x') + msg_putchar('\n'); + else + for (n = *p++; n > 0; --n) + if (*p == 'o' || *p == '$') + msg_putchar_attr(*p, hl_attr(HLF_L)); + else + msg_putchar(*p); msg_clr_eos(); } diff --git a/src/version.c b/src/version.c index 5ca02192fc9bee..cf7d48cb68a79d 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1726, /**/ 1725, /**/ From ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 14 Apr 2016 12:46:51 +0200 Subject: [PATCH 07/29] patch 7.4.1727 Problem: Cannot detect a crash in tests when caused by garbagecollect(). Solution: Add garbagecollect_for_testing(). Do not free a job if is still useful. --- runtime/doc/eval.txt | 32 +++++++++++++------- src/channel.c | 26 +++++++++++----- src/eval.c | 58 +++++++++++++++++++++++++++++++----- src/getchar.c | 4 +-- src/main.c | 2 +- src/proto/eval.pro | 4 +-- src/testdir/runtest.vim | 3 ++ src/testdir/test_channel.vim | 12 ++++++-- src/version.c | 2 ++ src/vim.h | 3 +- 10 files changed, 112 insertions(+), 34 deletions(-) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 1b4b3b7b978d04..93bf3f1ac4ace9 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.4. Last change: 2016 Apr 12 +*eval.txt* For Vim version 7.4. Last change: 2016 Apr 14 VIM REFERENCE MANUAL by Bram Moolenaar @@ -61,9 +61,9 @@ Funcref A reference to a function |Funcref|. Special |v:false|, |v:true|, |v:none| and |v:null|. *Special* -Job Used for a job, see |job_start()|. *Job* +Job Used for a job, see |job_start()|. *Job* *Jobs* -Channel Used for a channel, see |ch_open()|. *Channel* +Channel Used for a channel, see |ch_open()|. *Channel* *Channels* The Number and String types are converted automatically, depending on how they are used. @@ -1723,6 +1723,9 @@ v:termresponse The escape sequence returned by the terminal for the |t_RV| always 95 or bigger). Pc is always zero. {only when compiled with |+termresponse| feature} + *v:testing* *testing-variable* +v:testing Must be set before using `garbagecollect_for_testing()`. + *v:this_session* *this_session-variable* v:this_session Full filename of the last loaded or saved session file. See |:mksession|. It is allowed to set this variable. When no @@ -1905,9 +1908,10 @@ foldlevel( {lnum}) Number fold level at {lnum} foldtext() String line displayed for closed fold foldtextresult( {lnum}) String text for closed fold at {lnum} foreground() Number bring the Vim window to the foreground -function({name} [, {arglist}] [, {dict}]) +function( {name} [, {arglist}] [, {dict}]) Funcref reference to function {name} garbagecollect( [{atexit}]) none free memory, breaking cyclic references +garbagecollect_for_testing() none free memory right now get( {list}, {idx} [, {def}]) any get item {idx} from {list} or {def} get( {dict}, {key} [, {def}]) any get item {key} from {dict} or {def} getbufline( {expr}, {lnum} [, {end}]) @@ -3674,19 +3678,27 @@ function({name} [, {arglist}] [, {dict}]) garbagecollect([{atexit}]) *garbagecollect()* - Cleanup unused |Lists| and |Dictionaries| that have circular - references. There is hardly ever a need to invoke this - function, as it is automatically done when Vim runs out of - memory or is waiting for the user to press a key after - 'updatetime'. Items without circular references are always - freed when they become unused. + Cleanup unused |Lists|, |Dictionaries|, |Channels| and |Jobs| + that have circular references. + + There is hardly ever a need to invoke this function, as it is + automatically done when Vim runs out of memory or is waiting + for the user to press a key after 'updatetime'. Items without + circular references are always freed when they become unused. This is useful if you have deleted a very big |List| and/or |Dictionary| with circular references in a script that runs for a long time. + When the optional {atexit} argument is one, garbage collection will also be done when exiting Vim, if it wasn't done before. This is useful when checking for memory leaks. +garbagecollect_for_testing() *garbagecollect_for_testing()* + Like garbagecollect(), but executed right away. This must + only be called directly to avoid any structure to exist + internally, and |v:testing| must have been set before calling + any function. + get({list}, {idx} [, {default}]) *get()* Get item {idx} from |List| {list}. When this item is not available return {default}. Return zero when {default} is diff --git a/src/channel.c b/src/channel.c index 83d057dbb089fd..72484ecb0483d7 100644 --- a/src/channel.c +++ b/src/channel.c @@ -458,8 +458,7 @@ free_unused_channels(int copyID, int mask) ch_next = ch->ch_next; if ((ch->ch_copyID & mask) != (copyID & mask)) { - /* Free the channel and ordinary items it contains, but don't - * recurse into Lists, Dictionaries etc. */ + /* Free the channel struct itself. */ channel_free_channel(ch); } } @@ -4006,6 +4005,17 @@ job_free(job_T *job) } } +/* + * Return TRUE if the job should not be freed yet. Do not free the job when + * it has not ended yet and there is a "stoponexit" flag or an exit callback. + */ + static int +job_still_useful(job_T *job) +{ + return job->jv_status == JOB_STARTED + && (job->jv_stoponexit != NULL || job->jv_exit_cb != NULL); +} + void job_unref(job_T *job) { @@ -4013,8 +4023,7 @@ job_unref(job_T *job) { /* Do not free the job when it has not ended yet and there is a * "stoponexit" flag or an exit callback. */ - if (job->jv_status != JOB_STARTED - || (job->jv_stoponexit == NULL && job->jv_exit_cb == NULL)) + if (!job_still_useful(job)) { job_free(job); } @@ -4036,7 +4045,8 @@ free_unused_jobs_contents(int copyID, int mask) job_T *job; for (job = first_job; job != NULL; job = job->jv_next) - if ((job->jv_copyID & mask) != (copyID & mask)) + if ((job->jv_copyID & mask) != (copyID & mask) + && !job_still_useful(job)) { /* Free the channel and ordinary items it contains, but don't * recurse into Lists, Dictionaries etc. */ @@ -4055,10 +4065,10 @@ free_unused_jobs(int copyID, int mask) for (job = first_job; job != NULL; job = job_next) { job_next = job->jv_next; - if ((job->jv_copyID & mask) != (copyID & mask)) + if ((job->jv_copyID & mask) != (copyID & mask) + && !job_still_useful(job)) { - /* Free the channel and ordinary items it contains, but don't - * recurse into Lists, Dictionaries etc. */ + /* Free the job struct itself. */ job_free_job(job); } } diff --git a/src/eval.c b/src/eval.c index a14a721a0e0276..86580450fca5fe 100644 --- a/src/eval.c +++ b/src/eval.c @@ -373,6 +373,7 @@ static struct vimvar {VV_NAME("null", VAR_SPECIAL), VV_RO}, {VV_NAME("none", VAR_SPECIAL), VV_RO}, {VV_NAME("vim_did_enter", VAR_NUMBER), VV_RO}, + {VV_NAME("testing", VAR_NUMBER), 0}, }; /* shorthand */ @@ -580,6 +581,7 @@ static void f_foldtextresult(typval_T *argvars, typval_T *rettv); static void f_foreground(typval_T *argvars, typval_T *rettv); static void f_function(typval_T *argvars, typval_T *rettv); static void f_garbagecollect(typval_T *argvars, typval_T *rettv); +static void f_garbagecollect_for_testing(typval_T *argvars, typval_T *rettv); static void f_get(typval_T *argvars, typval_T *rettv); static void f_getbufline(typval_T *argvars, typval_T *rettv); static void f_getbufvar(typval_T *argvars, typval_T *rettv); @@ -1029,7 +1031,7 @@ eval_clear(void) ga_clear(&ga_scripts); /* unreferenced lists and dicts */ - (void)garbage_collect(); + (void)garbage_collect(FALSE); /* functions */ free_all_functions(); @@ -6889,6 +6891,9 @@ get_copyID(void) return current_copyID; } +/* Used by get_func_tv() */ +static garray_T funcargs = GA_EMPTY; + /* * Garbage collection for lists and dictionaries. * @@ -6911,10 +6916,11 @@ get_copyID(void) /* * Do garbage collection for lists and dicts. + * When "testing" is TRUE this is called from garbagecollect_for_testing(). * Return TRUE if some memory was freed. */ int -garbage_collect(void) +garbage_collect(int testing) { int copyID; int abort = FALSE; @@ -6928,10 +6934,13 @@ garbage_collect(void) tabpage_T *tp; #endif - /* Only do this once. */ - want_garbage_collect = FALSE; - may_garbage_collect = FALSE; - garbage_collect_at_exit = FALSE; + if (!testing) + { + /* Only do this once. */ + want_garbage_collect = FALSE; + may_garbage_collect = FALSE; + garbage_collect_at_exit = FALSE; + } /* We advance by two because we add one for items referenced through * previous_funccal. */ @@ -6989,6 +6998,11 @@ garbage_collect(void) abort = abort || set_ref_in_ht(&fc->l_avars.dv_hashtab, copyID, NULL); } + /* function call arguments, if v:testing is set. */ + for (i = 0; i < funcargs.ga_len; ++i) + abort = abort || set_ref_in_item(((typval_T **)funcargs.ga_data)[i], + copyID, NULL, NULL); + /* v: vars */ abort = abort || set_ref_in_ht(&vimvarht, copyID, NULL); @@ -7034,7 +7048,7 @@ garbage_collect(void) if (did_free_funccal) /* When a funccal was freed some more items might be garbage * collected, so run again. */ - (void)garbage_collect(); + (void)garbage_collect(testing); } else if (p_verbose > 0) { @@ -8424,6 +8438,7 @@ static struct fst {"foreground", 0, 0, f_foreground}, {"function", 1, 3, f_function}, {"garbagecollect", 0, 1, f_garbagecollect}, + {"garbagecollect_for_testing", 0, 0, f_garbagecollect_for_testing}, {"get", 2, 3, f_get}, {"getbufline", 2, 3, f_getbufline}, {"getbufvar", 2, 3, f_getbufvar}, @@ -8896,8 +8911,26 @@ get_func_tv( ret = FAIL; if (ret == OK) + { + int i = 0; + + if (get_vim_var_nr(VV_TESTING)) + { + /* Prepare for calling garbagecollect_for_testing(), need to know + * what variables are used on the call stack. */ + if (funcargs.ga_itemsize == 0) + ga_init2(&funcargs, (int)sizeof(typval_T *), 50); + for (i = 0; i < argcount; ++i) + if (ga_grow(&funcargs, 1) == OK) + ((typval_T **)funcargs.ga_data)[funcargs.ga_len++] = + &argvars[i]; + } + ret = call_func(name, len, rettv, argcount, argvars, firstline, lastline, doesrange, evaluate, partial, selfdict); + + funcargs.ga_len -= i; + } else if (!aborting()) { if (argcount == MAX_FUNC_ARGS) @@ -12317,6 +12350,17 @@ f_garbagecollect(typval_T *argvars, typval_T *rettv UNUSED) garbage_collect_at_exit = TRUE; } +/* + * "garbagecollect_for_testing()" function + */ + static void +f_garbagecollect_for_testing(typval_T *argvars UNUSED, typval_T *rettv UNUSED) +{ + /* This is dangerous, any Lists and Dicts used internally may be freed + * while still in use. */ + garbage_collect(TRUE); +} + /* * "get()" function */ diff --git a/src/getchar.c b/src/getchar.c index 4a225e1b640405..c771117add2cac 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -1523,7 +1523,7 @@ before_blocking(void) updatescript(0); #ifdef FEAT_EVAL if (may_garbage_collect) - garbage_collect(); + garbage_collect(FALSE); #endif } @@ -1571,7 +1571,7 @@ vgetc(void) /* Do garbage collection when garbagecollect() was called previously and * we are now at the toplevel. */ if (may_garbage_collect && want_garbage_collect) - garbage_collect(); + garbage_collect(FALSE); #endif /* diff --git a/src/main.c b/src/main.c index dc7b702bd9c97f..ee375000327c37 100644 --- a/src/main.c +++ b/src/main.c @@ -1531,7 +1531,7 @@ getout(int exitval) #endif #ifdef FEAT_EVAL if (garbage_collect_at_exit) - garbage_collect(); + garbage_collect(FALSE); #endif #if defined(WIN32) && defined(FEAT_MBYTE) free_cmd_argsW(); diff --git a/src/proto/eval.pro b/src/proto/eval.pro index 38392b9bd2d48f..9fda13c9c5facc 100644 --- a/src/proto/eval.pro +++ b/src/proto/eval.pro @@ -49,7 +49,6 @@ void partial_unref(partial_T *pt); list_T *list_alloc(void); int rettv_list_alloc(typval_T *rettv); void list_unref(list_T *l); -void list_free_internal(list_T *l); void list_free(list_T *l); listitem_T *listitem_alloc(void); void listitem_free(listitem_T *item); @@ -66,14 +65,13 @@ int list_insert_tv(list_T *l, typval_T *tv, listitem_T *item); void list_insert(list_T *l, listitem_T *ni, listitem_T *item); void vimlist_remove(list_T *l, listitem_T *item, listitem_T *item2); int get_copyID(void); -int garbage_collect(void); +int garbage_collect(int testing); int set_ref_in_ht(hashtab_T *ht, int copyID, list_stack_T **list_stack); int set_ref_in_list(list_T *l, int copyID, ht_stack_T **ht_stack); int set_ref_in_item(typval_T *tv, int copyID, ht_stack_T **ht_stack, list_stack_T **list_stack); dict_T *dict_alloc(void); int rettv_dict_alloc(typval_T *rettv); void dict_unref(dict_T *d); -void dict_free_internal(dict_T *d); void dict_free(dict_T *d); dictitem_T *dictitem_alloc(char_u *key); void dictitem_free(dictitem_T *item); diff --git a/src/testdir/runtest.vim b/src/testdir/runtest.vim index 4d75af3ee9b3f4..2b38981bb134d1 100644 --- a/src/testdir/runtest.vim +++ b/src/testdir/runtest.vim @@ -60,6 +60,9 @@ let $HOME = '/does/not/exist' let s:srcdir = expand('%:p:h:h') +" Prepare for calling garbagecollect_for_testing(). +let v:testing = 1 + " Support function: get the alloc ID by name. function GetAllocId(name) exe 'split ' . s:srcdir . '/alloc.h' diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index e1345279fd7f46..05df50af433598 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -183,7 +183,7 @@ func s:communicate(port) call assert_equal('got it', s:responseMsg) " Collect garbage, tests that our handle isn't collected. - call garbagecollect() + call garbagecollect_for_testing() " check setting options (without testing the effect) call ch_setoptions(handle, {'callback': 's:NotUsed'}) @@ -1231,7 +1231,7 @@ func Test_job_start_invalid() call assert_fails('call job_start("")', 'E474:') endfunc -" This leaking memory. +" This was leaking memory. func Test_partial_in_channel_cycle() let d = {} let d.a = function('string', [d]) @@ -1243,5 +1243,13 @@ func Test_partial_in_channel_cycle() unlet d endfunc +func Test_using_freed_memory() + let g:a = job_start(['ls']) + sleep 10m + call garbagecollect_for_testing() +endfunc + + + " Uncomment this to see what happens, output is in src/testdir/channellog. " call ch_logfile('channellog', 'w') diff --git a/src/version.c b/src/version.c index cf7d48cb68a79d..6c94bc64b23f77 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1727, /**/ 1726, /**/ diff --git a/src/vim.h b/src/vim.h index 36cc19a27a06d7..9e2ab2161a53bd 100644 --- a/src/vim.h +++ b/src/vim.h @@ -1868,7 +1868,8 @@ typedef int sock_T; #define VV_NULL 65 #define VV_NONE 66 #define VV_VIM_DID_ENTER 67 -#define VV_LEN 68 /* number of v: vars */ +#define VV_TESTING 68 +#define VV_LEN 69 /* number of v: vars */ /* used for v_number in VAR_SPECIAL */ #define VVAL_FALSE 0L From 81edd171a9465cf99cede4fa4a7b7bca3d538b0f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 14 Apr 2016 13:51:37 +0200 Subject: [PATCH 08/29] patch 7.4.1728 Problem: The help for functions require a space after the "(". Solution: Make CTRL-] on a function name ignore the arguments. (Hirohito Higashi) --- runtime/doc/eval.txt | 594 +++++++++++++++--------------- src/ex_cmds.c | 7 + src/testdir/test_help_tagjump.vim | 10 + src/version.c | 2 + 4 files changed, 319 insertions(+), 294 deletions(-) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 93bf3f1ac4ace9..2d7beb7c260839 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1791,134 +1791,137 @@ See |function-list| for a list grouped by what the function is used for. USAGE RESULT DESCRIPTION ~ -abs( {expr}) Float or Number absolute value of {expr} -acos( {expr}) Float arc cosine of {expr} -add( {list}, {item}) List append {item} to |List| {list} -alloc_fail( {id}, {countdown}, {repeat}) +abs({expr}) Float or Number absolute value of {expr} +acos({expr}) Float arc cosine of {expr} +add({list}, {item}) List append {item} to |List| {list} +alloc_fail({id}, {countdown}, {repeat}) none make memory allocation fail -and( {expr}, {expr}) Number bitwise AND -append( {lnum}, {string}) Number append {string} below line {lnum} -append( {lnum}, {list}) Number append lines {list} below line {lnum} +and({expr}, {expr}) Number bitwise AND +append({lnum}, {string}) Number append {string} below line {lnum} +append({lnum}, {list}) Number append lines {list} below line {lnum} argc() Number number of files in the argument list argidx() Number current index in the argument list -arglistid( [{winnr} [, {tabnr}]]) - Number argument list id -argv( {nr}) String {nr} entry of the argument list +arglistid([{winnr} [, {tabnr}]]) Number argument list id +argv({nr}) String {nr} entry of the argument list argv() List the argument list -assert_equal( {exp}, {act} [, {msg}]) none assert {exp} is equal to {act} -assert_exception( {error} [, {msg}]) none assert {error} is in v:exception -assert_fails( {cmd} [, {error}]) none assert {cmd} fails -assert_false( {actual} [, {msg}]) none assert {actual} is false -assert_match( {pat}, {text} [, {msg}]) none assert {pat} matches {text} -assert_notequal( {exp}, {act} [, {msg}]) none assert {exp} is not equal {act} -assert_notmatch( {pat}, {text} [, {msg}]) none assert {pat} not matches {text} -assert_true( {actual} [, {msg}]) none assert {actual} is true -asin( {expr}) Float arc sine of {expr} -atan( {expr}) Float arc tangent of {expr} -atan2( {expr}, {expr}) Float arc tangent of {expr1} / {expr2} -browse( {save}, {title}, {initdir}, {default}) +assert_equal({exp}, {act} [, {msg}]) none assert {exp} is equal to {act} +assert_exception({error} [, {msg}]) none assert {error} is in v:exception +assert_fails({cmd} [, {error}]) none assert {cmd} fails +assert_false({actual} [, {msg}]) none assert {actual} is false +assert_match({pat}, {text} [, {msg}]) none assert {pat} matches {text} +assert_notequal({exp}, {act} [, {msg}]) none assert {exp} is not equal {act} +assert_notmatch({pat}, {text} [, {msg}]) none assert {pat} not matches {text} +assert_true({actual} [, {msg}]) none assert {actual} is true +asin({expr}) Float arc sine of {expr} +atan({expr}) Float arc tangent of {expr} +atan2({expr}, {expr}) Float arc tangent of {expr1} / {expr2} +browse({save}, {title}, {initdir}, {default}) String put up a file requester -browsedir( {title}, {initdir}) String put up a directory requester -bufexists( {expr}) Number TRUE if buffer {expr} exists -buflisted( {expr}) Number TRUE if buffer {expr} is listed -bufloaded( {expr}) Number TRUE if buffer {expr} is loaded -bufname( {expr}) String Name of the buffer {expr} -bufnr( {expr} [, {create}]) Number Number of the buffer {expr} -bufwinnr( {expr}) Number window number of buffer {expr} -byte2line( {byte}) Number line number at byte count {byte} -byteidx( {expr}, {nr}) Number byte index of {nr}'th char in {expr} -byteidxcomp( {expr}, {nr}) Number byte index of {nr}'th char in {expr} -call( {func}, {arglist} [, {dict}]) +browsedir({title}, {initdir}) String put up a directory requester +bufexists({expr}) Number TRUE if buffer {expr} exists +buflisted({expr}) Number TRUE if buffer {expr} is listed +bufloaded({expr}) Number TRUE if buffer {expr} is loaded +bufname({expr}) String Name of the buffer {expr} +bufnr({expr} [, {create}]) Number Number of the buffer {expr} +bufwinnr({expr}) Number window number of buffer {expr} +byte2line({byte}) Number line number at byte count {byte} +byteidx({expr}, {nr}) Number byte index of {nr}'th char in {expr} +byteidxcomp({expr}, {nr}) Number byte index of {nr}'th char in {expr} +call({func}, {arglist} [, {dict}]) any call {func} with arguments {arglist} -ceil( {expr}) Float round {expr} up -ch_close( {handle}) none close {handle} -ch_evalexpr( {handle}, {expr} [, {options}]) +ceil({expr}) Float round {expr} up +ch_close({handle}) none close {handle} +ch_evalexpr({handle}, {expr} [, {options}]) any evaluate {expr} on JSON {handle} -ch_evalraw( {handle}, {string} [, {options}]) +ch_evalraw({handle}, {string} [, {options}]) any evaluate {string} on raw {handle} -ch_getbufnr( {handle}, {what}) Number get buffer number for {handle}/{what} -ch_getjob( {channel}) Job get the Job of {channel} -ch_info( {handle}) String info about channel {handle} -ch_log( {msg} [, {handle}]) none write {msg} in the channel log file -ch_logfile( {fname} [, {mode}]) none start logging channel activity -ch_open( {address} [, {options}]) Channel open a channel to {address} -ch_read( {handle} [, {options}]) String read from {handle} -ch_readraw( {handle} [, {options}]) String read raw from {handle} -ch_sendexpr( {handle}, {expr} [, {options}]) +ch_getbufnr({handle}, {what}) Number get buffer number for {handle}/{what} +ch_getjob({channel}) Job get the Job of {channel} +ch_info({handle}) String info about channel {handle} +ch_log({msg} [, {handle}]) none write {msg} in the channel log file +ch_logfile({fname} [, {mode}]) none start logging channel activity +ch_open({address} [, {options}]) + Channel open a channel to {address} +ch_read({handle} [, {options}]) String read from {handle} +ch_readraw({handle} [, {options}]) + String read raw from {handle} +ch_sendexpr({handle}, {expr} [, {options}]) any send {expr} over JSON {handle} -ch_sendraw( {handle}, {string} [, {options}]) +ch_sendraw({handle}, {string} [, {options}]) any send {string} over raw {handle} -ch_setoptions( {handle}, {options}) none set options for {handle} -ch_status( {handle}) String status of channel {handle} +ch_setoptions({handle}, {options}) + none set options for {handle} +ch_status({handle}) String status of channel {handle} changenr() Number current change number -char2nr( {expr}[, {utf8}]) Number ASCII/UTF8 value of first char in {expr} -cindent( {lnum}) Number C indent for line {lnum} +char2nr({expr}[, {utf8}]) Number ASCII/UTF8 value of first char in {expr} +cindent({lnum}) Number C indent for line {lnum} clearmatches() none clear all matches -col( {expr}) Number column nr of cursor or mark -complete( {startcol}, {matches}) none set Insert mode completion -complete_add( {expr}) Number add completion match +col({expr}) Number column nr of cursor or mark +complete({startcol}, {matches}) none set Insert mode completion +complete_add({expr}) Number add completion match complete_check() Number check for key typed during completion -confirm( {msg} [, {choices} [, {default} [, {type}]]]) +confirm({msg} [, {choices} [, {default} [, {type}]]]) Number number of choice picked by user -copy( {expr}) any make a shallow copy of {expr} -cos( {expr}) Float cosine of {expr} -cosh( {expr}) Float hyperbolic cosine of {expr} -count( {list}, {expr} [, {ic} [, {start}]]) +copy({expr}) any make a shallow copy of {expr} +cos({expr}) Float cosine of {expr} +cosh({expr}) Float hyperbolic cosine of {expr} +count({list}, {expr} [, {ic} [, {start}]]) Number count how many {expr} are in {list} -cscope_connection( [{num} , {dbpath} [, {prepend}]]) +cscope_connection([{num} , {dbpath} [, {prepend}]]) Number checks existence of cscope connection -cursor( {lnum}, {col} [, {off}]) +cursor({lnum}, {col} [, {off}]) Number move cursor to {lnum}, {col}, {off} -cursor( {list}) Number move cursor to position in {list} -deepcopy( {expr} [, {noref}]) any make a full copy of {expr} -delete( {fname} [, {flags}]) Number delete the file or directory {fname} +cursor({list}) Number move cursor to position in {list} +deepcopy({expr} [, {noref}]) any make a full copy of {expr} +delete({fname} [, {flags}]) Number delete the file or directory {fname} did_filetype() Number TRUE if FileType autocommand event used -diff_filler( {lnum}) Number diff filler lines about {lnum} -diff_hlID( {lnum}, {col}) Number diff highlighting at {lnum}/{col} -disable_char_avail_for_testing( {expr}) none test without typeahead -empty( {expr}) Number TRUE if {expr} is empty -escape( {string}, {chars}) String escape {chars} in {string} with '\' -eval( {string}) any evaluate {string} into its value +diff_filler({lnum}) Number diff filler lines about {lnum} +diff_hlID({lnum}, {col}) Number diff highlighting at {lnum}/{col} +disable_char_avail_for_testing({expr}) + none test without typeahead +empty({expr}) Number TRUE if {expr} is empty +escape({string}, {chars}) String escape {chars} in {string} with '\' +eval({string}) any evaluate {string} into its value eventhandler() Number TRUE if inside an event handler -executable( {expr}) Number 1 if executable {expr} exists -exepath( {expr}) String full path of the command {expr} -exists( {expr}) Number TRUE if {expr} exists -extend( {expr1}, {expr2} [, {expr3}]) +executable({expr}) Number 1 if executable {expr} exists +exepath({expr}) String full path of the command {expr} +exists({expr}) Number TRUE if {expr} exists +extend({expr1}, {expr2} [, {expr3}]) List/Dict insert items of {expr2} into {expr1} -exp( {expr}) Float exponential of {expr} -expand( {expr} [, {nosuf} [, {list}]]) +exp({expr}) Float exponential of {expr} +expand({expr} [, {nosuf} [, {list}]]) any expand special keywords in {expr} -feedkeys( {string} [, {mode}]) Number add key sequence to typeahead buffer -filereadable( {file}) Number TRUE if {file} is a readable file -filewritable( {file}) Number TRUE if {file} is a writable file -filter( {expr}, {string}) List/Dict remove items from {expr} where +feedkeys({string} [, {mode}]) Number add key sequence to typeahead buffer +filereadable({file}) Number TRUE if {file} is a readable file +filewritable({file}) Number TRUE if {file} is a writable file +filter({expr}, {string}) List/Dict remove items from {expr} where {string} is 0 -finddir( {name}[, {path}[, {count}]]) +finddir({name}[, {path}[, {count}]]) String find directory {name} in {path} -findfile( {name}[, {path}[, {count}]]) +findfile({name}[, {path}[, {count}]]) String find file {name} in {path} -float2nr( {expr}) Number convert Float {expr} to a Number -floor( {expr}) Float round {expr} down -fmod( {expr1}, {expr2}) Float remainder of {expr1} / {expr2} -fnameescape( {fname}) String escape special characters in {fname} -fnamemodify( {fname}, {mods}) String modify file name -foldclosed( {lnum}) Number first line of fold at {lnum} if closed -foldclosedend( {lnum}) Number last line of fold at {lnum} if closed -foldlevel( {lnum}) Number fold level at {lnum} +float2nr({expr}) Number convert Float {expr} to a Number +floor({expr}) Float round {expr} down +fmod({expr1}, {expr2}) Float remainder of {expr1} / {expr2} +fnameescape({fname}) String escape special characters in {fname} +fnamemodify({fname}, {mods}) String modify file name +foldclosed({lnum}) Number first line of fold at {lnum} if closed +foldclosedend({lnum}) Number last line of fold at {lnum} if closed +foldlevel({lnum}) Number fold level at {lnum} foldtext() String line displayed for closed fold -foldtextresult( {lnum}) String text for closed fold at {lnum} +foldtextresult({lnum}) String text for closed fold at {lnum} foreground() Number bring the Vim window to the foreground -function( {name} [, {arglist}] [, {dict}]) +function({name} [, {arglist}] [, {dict}]) Funcref reference to function {name} -garbagecollect( [{atexit}]) none free memory, breaking cyclic references +garbagecollect([{atexit}]) none free memory, breaking cyclic references garbagecollect_for_testing() none free memory right now -get( {list}, {idx} [, {def}]) any get item {idx} from {list} or {def} -get( {dict}, {key} [, {def}]) any get item {key} from {dict} or {def} -getbufline( {expr}, {lnum} [, {end}]) +get({list}, {idx} [, {def}]) any get item {idx} from {list} or {def} +get({dict}, {key} [, {def}]) any get item {key} from {dict} or {def} +getbufline({expr}, {lnum} [, {end}]) List lines {lnum} to {end} of buffer {expr} -getbufvar( {expr}, {varname} [, {def}]) +getbufvar({expr}, {varname} [, {def}]) any variable {varname} in buffer {expr} -getchar( [expr]) Number get one character from the user +getchar([expr]) Number get one character from the user getcharmod() Number modifiers for the last typed character getcharsearch() Dict last character search getcmdline() String return the current command-line @@ -1926,268 +1929,271 @@ getcmdpos() Number return cursor position in command-line getcmdtype() String return current command-line type getcmdwintype() String return current command-line window type getcurpos() List position of the cursor -getcwd( [{winnr} [, {tabnr}]]) String get the current working directory -getfontname( [{name}]) String name of font being used -getfperm( {fname}) String file permissions of file {fname} -getfsize( {fname}) Number size in bytes of file {fname} -getftime( {fname}) Number last modification time of file -getftype( {fname}) String description of type of file {fname} -getline( {lnum}) String line {lnum} of current buffer -getline( {lnum}, {end}) List lines {lnum} to {end} of current buffer -getloclist( {nr}) List list of location list items +getcwd([{winnr} [, {tabnr}]]) String get the current working directory +getfontname([{name}]) String name of font being used +getfperm({fname}) String file permissions of file {fname} +getfsize({fname}) Number size in bytes of file {fname} +getftime({fname}) Number last modification time of file +getftype({fname}) String description of type of file {fname} +getline({lnum}) String line {lnum} of current buffer +getline({lnum}, {end}) List lines {lnum} to {end} of current buffer +getloclist({nr}) List list of location list items getmatches() List list of current matches getpid() Number process ID of Vim -getpos( {expr}) List position of cursor, mark, etc. +getpos({expr}) List position of cursor, mark, etc. getqflist() List list of quickfix items -getreg( [{regname} [, 1 [, {list}]]]) +getreg([{regname} [, 1 [, {list}]]]) String or List contents of register -getregtype( [{regname}]) String type of register -gettabvar( {nr}, {varname} [, {def}]) +getregtype([{regname}]) String type of register +gettabvar({nr}, {varname} [, {def}]) any variable {varname} in tab {nr} or {def} -gettabwinvar( {tabnr}, {winnr}, {name} [, {def}]) +gettabwinvar({tabnr}, {winnr}, {name} [, {def}]) any {name} in {winnr} in tab page {tabnr} getwinposx() Number X coord in pixels of GUI Vim window getwinposy() Number Y coord in pixels of GUI Vim window -getwinvar( {nr}, {varname} [, {def}]) +getwinvar({nr}, {varname} [, {def}]) any variable {varname} in window {nr} -glob( {expr} [, {nosuf} [, {list} [, {alllinks}]]]) +glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) any expand file wildcards in {expr} -glob2regpat( {expr}) String convert a glob pat into a search pat -globpath( {path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]]) +glob2regpat({expr}) String convert a glob pat into a search pat +globpath({path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]]) String do glob({expr}) for all dirs in {path} -has( {feature}) Number TRUE if feature {feature} supported -has_key( {dict}, {key}) Number TRUE if {dict} has entry {key} -haslocaldir( [{winnr} [, {tabnr}]]) +has({feature}) Number TRUE if feature {feature} supported +has_key({dict}, {key}) Number TRUE if {dict} has entry {key} +haslocaldir([{winnr} [, {tabnr}]]) Number TRUE if the window executed |:lcd| -hasmapto( {what} [, {mode} [, {abbr}]]) +hasmapto({what} [, {mode} [, {abbr}]]) Number TRUE if mapping to {what} exists -histadd( {history}, {item}) String add an item to a history -histdel( {history} [, {item}]) String remove an item from a history -histget( {history} [, {index}]) String get the item {index} from a history -histnr( {history}) Number highest index of a history -hlexists( {name}) Number TRUE if highlight group {name} exists -hlID( {name}) Number syntax ID of highlight group {name} +histadd({history}, {item}) String add an item to a history +histdel({history} [, {item}]) String remove an item from a history +histget({history} [, {index}]) String get the item {index} from a history +histnr({history}) Number highest index of a history +hlexists({name}) Number TRUE if highlight group {name} exists +hlID({name}) Number syntax ID of highlight group {name} hostname() String name of the machine Vim is running on -iconv( {expr}, {from}, {to}) String convert encoding of {expr} -indent( {lnum}) Number indent of line {lnum} -index( {list}, {expr} [, {start} [, {ic}]]) +iconv({expr}, {from}, {to}) String convert encoding of {expr} +indent({lnum}) Number indent of line {lnum} +index({list}, {expr} [, {start} [, {ic}]]) Number index in {list} where {expr} appears -input( {prompt} [, {text} [, {completion}]]) +input({prompt} [, {text} [, {completion}]]) String get input from the user -inputdialog( {p} [, {t} [, {c}]]) String like input() but in a GUI dialog -inputlist( {textlist}) Number let the user pick from a choice list +inputdialog({prompt} [, {text} [, {completion}]]]) + String like input() but in a GUI dialog +inputlist({textlist}) Number let the user pick from a choice list inputrestore() Number restore typeahead inputsave() Number save and clear typeahead -inputsecret( {prompt} [, {text}]) String like input() but hiding the text -insert( {list}, {item} [, {idx}]) List insert {item} in {list} [before {idx}] -invert( {expr}) Number bitwise invert -isdirectory( {directory}) Number TRUE if {directory} is a directory -islocked( {expr}) Number TRUE if {expr} is locked -isnan( {expr}) Number TRUE if {expr} is NaN -items( {dict}) List key-value pairs in {dict} -job_getchannel( {job}) Channel get the channel handle for {job} -job_info( {job}) Dict get information about {job} -job_setoptions( {job}, {options}) none set options for {job} -job_start( {command} [, {options}]) Job start a job -job_status( {job}) String get the status of {job} -job_stop( {job} [, {how}]) Number stop {job} -join( {list} [, {sep}]) String join {list} items into one String -js_decode( {string}) any decode JS style JSON -js_encode( {expr}) String encode JS style JSON -json_decode( {string}) any decode JSON -json_encode( {expr}) String encode JSON -keys( {dict}) List keys in {dict} -len( {expr}) Number the length of {expr} -libcall( {lib}, {func}, {arg}) String call {func} in library {lib} with {arg} -libcallnr( {lib}, {func}, {arg}) Number idem, but return a Number -line( {expr}) Number line nr of cursor, last line or mark -line2byte( {lnum}) Number byte count of line {lnum} -lispindent( {lnum}) Number Lisp indent for line {lnum} +inputsecret({prompt} [, {text}]) String like input() but hiding the text +insert({list}, {item} [, {idx}]) List insert {item} in {list} [before {idx}] +invert({expr}) Number bitwise invert +isdirectory({directory}) Number TRUE if {directory} is a directory +islocked({expr}) Number TRUE if {expr} is locked +isnan({expr}) Number TRUE if {expr} is NaN +items({dict}) List key-value pairs in {dict} +job_getchannel({job}) Channel get the channel handle for {job} +job_info({job}) Dict get information about {job} +job_setoptions({job}, {options}) none set options for {job} +job_start({command} [, {options}]) + Job start a job +job_status({job}) String get the status of {job} +job_stop({job} [, {how}]) Number stop {job} +join({list} [, {sep}]) String join {list} items into one String +js_decode({string}) any decode JS style JSON +js_encode({expr}) String encode JS style JSON +json_decode({string}) any decode JSON +json_encode({expr}) String encode JSON +keys({dict}) List keys in {dict} +len({expr}) Number the length of {expr} +libcall({lib}, {func}, {arg}) String call {func} in library {lib} with {arg} +libcallnr({lib}, {func}, {arg}) Number idem, but return a Number +line({expr}) Number line nr of cursor, last line or mark +line2byte({lnum}) Number byte count of line {lnum} +lispindent({lnum}) Number Lisp indent for line {lnum} localtime() Number current time -log( {expr}) Float natural logarithm (base e) of {expr} -log10( {expr}) Float logarithm of Float {expr} to base 10 -luaeval( {expr}[, {expr}]) any evaluate |Lua| expression -map( {expr}, {string}) List/Dict change each item in {expr} to {expr} -maparg( {name}[, {mode} [, {abbr} [, {dict}]]]) +log({expr}) Float natural logarithm (base e) of {expr} +log10({expr}) Float logarithm of Float {expr} to base 10 +luaeval({expr}[, {expr}]) any evaluate |Lua| expression +map({expr}, {string}) List/Dict change each item in {expr} to {expr} +maparg({name}[, {mode} [, {abbr} [, {dict}]]]) String or Dict rhs of mapping {name} in mode {mode} -mapcheck( {name}[, {mode} [, {abbr}]]) +mapcheck({name}[, {mode} [, {abbr}]]) String check for mappings matching {name} -match( {expr}, {pat}[, {start}[, {count}]]) +match({expr}, {pat}[, {start}[, {count}]]) Number position where {pat} matches in {expr} -matchadd( {group}, {pattern}[, {priority}[, {id} [, {dict}]]]) +matchadd({group}, {pattern}[, {priority}[, {id} [, {dict}]]]) Number highlight {pattern} with {group} -matchaddpos( {group}, {pos}[, {priority}[, {id}[, {dict}]]]) +matchaddpos({group}, {pos}[, {priority}[, {id}[, {dict}]]]) Number highlight positions with {group} -matcharg( {nr}) List arguments of |:match| -matchdelete( {id}) Number delete match identified by {id} -matchend( {expr}, {pat}[, {start}[, {count}]]) +matcharg({nr}) List arguments of |:match| +matchdelete({id}) Number delete match identified by {id} +matchend({expr}, {pat}[, {start}[, {count}]]) Number position where {pat} ends in {expr} -matchlist( {expr}, {pat}[, {start}[, {count}]]) +matchlist({expr}, {pat}[, {start}[, {count}]]) List match and submatches of {pat} in {expr} -matchstr( {expr}, {pat}[, {start}[, {count}]]) +matchstr({expr}, {pat}[, {start}[, {count}]]) String {count}'th match of {pat} in {expr} -matchstrpos( {expr}, {pat}[, {start}[, {count}]]) +matchstrpos({expr}, {pat}[, {start}[, {count}]]) List {count}'th match of {pat} in {expr} -max( {list}) Number maximum value of items in {list} -min( {list}) Number minimum value of items in {list} -mkdir( {name} [, {path} [, {prot}]]) +max({list}) Number maximum value of items in {list} +min({list}) Number minimum value of items in {list} +mkdir({name} [, {path} [, {prot}]]) Number create directory {name} -mode( [expr]) String current editing mode -mzeval( {expr}) any evaluate |MzScheme| expression -nextnonblank( {lnum}) Number line nr of non-blank line >= {lnum} -nr2char( {expr}[, {utf8}]) String single char with ASCII/UTF8 value {expr} -or( {expr}, {expr}) Number bitwise OR -pathshorten( {expr}) String shorten directory names in a path -perleval( {expr}) any evaluate |Perl| expression -pow( {x}, {y}) Float {x} to the power of {y} -prevnonblank( {lnum}) Number line nr of non-blank line <= {lnum} -printf( {fmt}, {expr1}...) String format text +mode([expr]) String current editing mode +mzeval({expr}) any evaluate |MzScheme| expression +nextnonblank({lnum}) Number line nr of non-blank line >= {lnum} +nr2char({expr}[, {utf8}]) String single char with ASCII/UTF8 value {expr} +or({expr}, {expr}) Number bitwise OR +pathshorten({expr}) String shorten directory names in a path +perleval({expr}) any evaluate |Perl| expression +pow({x}, {y}) Float {x} to the power of {y} +prevnonblank({lnum}) Number line nr of non-blank line <= {lnum} +printf({fmt}, {expr1}...) String format text pumvisible() Number whether popup menu is visible -pyeval( {expr}) any evaluate |Python| expression -py3eval( {expr}) any evaluate |python3| expression -range( {expr} [, {max} [, {stride}]]) +pyeval({expr}) any evaluate |Python| expression +py3eval({expr}) any evaluate |python3| expression +range({expr} [, {max} [, {stride}]]) List items from {expr} to {max} -readfile( {fname} [, {binary} [, {max}]]) +readfile({fname} [, {binary} [, {max}]]) List get list of lines from file {fname} -reltime( [{start} [, {end}]]) List get time value -reltimefloat( {time}) Float turn the time value into a Float -reltimestr( {time}) String turn time value into a String -remote_expr( {server}, {string} [, {idvar}]) +reltime([{start} [, {end}]]) List get time value +reltimefloat({time}) Float turn the time value into a Float +reltimestr({time}) String turn time value into a String +remote_expr({server}, {string} [, {idvar}]) String send expression -remote_foreground( {server}) Number bring Vim server to the foreground -remote_peek( {serverid} [, {retvar}]) +remote_foreground({server}) Number bring Vim server to the foreground +remote_peek({serverid} [, {retvar}]) Number check for reply string -remote_read( {serverid}) String read reply string -remote_send( {server}, {string} [, {idvar}]) +remote_read({serverid}) String read reply string +remote_send({server}, {string} [, {idvar}]) String send key sequence -remove( {list}, {idx} [, {end}]) any remove items {idx}-{end} from {list} -remove( {dict}, {key}) any remove entry {key} from {dict} -rename( {from}, {to}) Number rename (move) file from {from} to {to} -repeat( {expr}, {count}) String repeat {expr} {count} times -resolve( {filename}) String get filename a shortcut points to -reverse( {list}) List reverse {list} in-place -round( {expr}) Float round off {expr} -screenattr( {row}, {col}) Number attribute at screen position -screenchar( {row}, {col}) Number character at screen position +remove({list}, {idx} [, {end}]) any remove items {idx}-{end} from {list} +remove({dict}, {key}) any remove entry {key} from {dict} +rename({from}, {to}) Number rename (move) file from {from} to {to} +repeat({expr}, {count}) String repeat {expr} {count} times +resolve({filename}) String get filename a shortcut points to +reverse({list}) List reverse {list} in-place +round({expr}) Float round off {expr} +screenattr({row}, {col}) Number attribute at screen position +screenchar({row}, {col}) Number character at screen position screencol() Number current cursor column screenrow() Number current cursor row -search( {pattern} [, {flags} [, {stopline} [, {timeout}]]]) +search({pattern} [, {flags} [, {stopline} [, {timeout}]]]) Number search for {pattern} -searchdecl( {name} [, {global} [, {thisblock}]]) +searchdecl({name} [, {global} [, {thisblock}]]) Number search for variable declaration -searchpair( {start}, {middle}, {end} [, {flags} [, {skip} [...]]]) +searchpair({start}, {middle}, {end} [, {flags} [, {skip} [...]]]) Number search for other end of start/end pair -searchpairpos( {start}, {middle}, {end} [, {flags} [, {skip} [...]]]) +searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [...]]]) List search for other end of start/end pair -searchpos( {pattern} [, {flags} [, {stopline} [, {timeout}]]]) +searchpos({pattern} [, {flags} [, {stopline} [, {timeout}]]]) List search for {pattern} -server2client( {clientid}, {string}) +server2client({clientid}, {string}) Number send reply string serverlist() String get a list of available servers -setbufvar( {expr}, {varname}, {val}) set {varname} in buffer {expr} to {val} -setcharsearch( {dict}) Dict set character search from {dict} -setcmdpos( {pos}) Number set cursor position in command-line -setfperm( {fname}, {mode}) Number set {fname} file permissions to {mode} -setline( {lnum}, {line}) Number set line {lnum} to {line} -setloclist( {nr}, {list}[, {action}]) +setbufvar({expr}, {varname}, {val}) + none set {varname} in buffer {expr} to {val} +setcharsearch({dict}) Dict set character search from {dict} +setcmdpos({pos}) Number set cursor position in command-line +setfperm({fname}, {mode}) Number set {fname} file permissions to {mode} +setline({lnum}, {line}) Number set line {lnum} to {line} +setloclist({nr}, {list}[, {action}]) Number modify location list using {list} -setmatches( {list}) Number restore a list of matches -setpos( {expr}, {list}) Number set the {expr} position to {list} -setqflist( {list}[, {action}]) Number modify quickfix list using {list} -setreg( {n}, {v}[, {opt}]) Number set register to value and type -settabvar( {nr}, {varname}, {val}) set {varname} in tab page {nr} to {val} -settabwinvar( {tabnr}, {winnr}, {varname}, {val}) set {varname} in window - {winnr} in tab page {tabnr} to {val} -setwinvar( {nr}, {varname}, {val}) set {varname} in window {nr} to {val} -sha256( {string}) String SHA256 checksum of {string} -shellescape( {string} [, {special}]) +setmatches({list}) Number restore a list of matches +setpos({expr}, {list}) Number set the {expr} position to {list} +setqflist({list}[, {action}]) Number modify quickfix list using {list} +setreg({n}, {v}[, {opt}]) Number set register to value and type +settabvar({nr}, {varname}, {val}) none set {varname} in tab page {nr} to {val} +settabwinvar({tabnr}, {winnr}, {varname}, {val}) + none set {varname} in window {winnr} in tab + page {tabnr} to {val} +setwinvar({nr}, {varname}, {val}) none set {varname} in window {nr} to {val} +sha256({string}) String SHA256 checksum of {string} +shellescape({string} [, {special}]) String escape {string} for use as shell command argument shiftwidth() Number effective value of 'shiftwidth' -simplify( {filename}) String simplify filename as much as possible -sin( {expr}) Float sine of {expr} -sinh( {expr}) Float hyperbolic sine of {expr} -sort( {list} [, {func} [, {dict}]]) +simplify({filename}) String simplify filename as much as possible +sin({expr}) Float sine of {expr} +sinh({expr}) Float hyperbolic sine of {expr} +sort({list} [, {func} [, {dict}]]) List sort {list}, using {func} to compare -soundfold( {word}) String sound-fold {word} +soundfold({word}) String sound-fold {word} spellbadword() String badly spelled word at cursor -spellsuggest( {word} [, {max} [, {capital}]]) +spellsuggest({word} [, {max} [, {capital}]]) List spelling suggestions -split( {expr} [, {pat} [, {keepempty}]]) +split({expr} [, {pat} [, {keepempty}]]) List make |List| from {pat} separated {expr} -sqrt( {expr}) Float square root of {expr} -str2float( {expr}) Float convert String to Float -str2nr( {expr} [, {base}]) Number convert String to Number -strchars( {expr} [, {skipcc}]) Number character length of the String {expr} -strdisplaywidth( {expr} [, {col}]) Number display length of the String {expr} -strftime( {format}[, {time}]) String time in specified format -stridx( {haystack}, {needle}[, {start}]) +sqrt({expr}) Float square root of {expr} +str2float({expr}) Float convert String to Float +str2nr({expr} [, {base}]) Number convert String to Number +strchars({expr} [, {skipcc}]) Number character length of the String {expr} +strdisplaywidth({expr} [, {col}]) Number display length of the String {expr} +strftime({format}[, {time}]) String time in specified format +stridx({haystack}, {needle}[, {start}]) Number index of {needle} in {haystack} -string( {expr}) String String representation of {expr} value -strlen( {expr}) Number length of the String {expr} -strpart( {src}, {start}[, {len}]) +string({expr}) String String representation of {expr} value +strlen({expr}) Number length of the String {expr} +strpart({src}, {start}[, {len}]) String {len} characters of {src} at {start} -strridx( {haystack}, {needle} [, {start}]) +strridx({haystack}, {needle} [, {start}]) Number last index of {needle} in {haystack} -strtrans( {expr}) String translate string to make it printable -strwidth( {expr}) Number display cell length of the String {expr} -submatch( {nr}[, {list}]) String or List +strtrans({expr}) String translate string to make it printable +strwidth({expr}) Number display cell length of the String {expr} +submatch({nr}[, {list}]) String or List specific match in ":s" or substitute() -substitute( {expr}, {pat}, {sub}, {flags}) +substitute({expr}, {pat}, {sub}, {flags}) String all {pat} in {expr} replaced with {sub} -synID( {lnum}, {col}, {trans}) Number syntax ID at {lnum} and {col} -synIDattr( {synID}, {what} [, {mode}]) +synID({lnum}, {col}, {trans}) Number syntax ID at {lnum} and {col} +synIDattr({synID}, {what} [, {mode}]) String attribute {what} of syntax ID {synID} -synIDtrans( {synID}) Number translated syntax ID of {synID} -synconcealed( {lnum}, {col}) List info about concealing -synstack( {lnum}, {col}) List stack of syntax IDs at {lnum} and {col} -system( {expr} [, {input}]) String output of shell command/filter {expr} -systemlist( {expr} [, {input}]) List output of shell command/filter {expr} -tabpagebuflist( [{arg}]) List list of buffer numbers in tab page -tabpagenr( [{arg}]) Number number of current or last tab page -tabpagewinnr( {tabarg}[, {arg}]) - Number number of current window in tab page -taglist( {expr}) List list of tags matching {expr} +synIDtrans({synID}) Number translated syntax ID of {synID} +synconcealed({lnum}, {col}) List info about concealing +synstack({lnum}, {col}) List stack of syntax IDs at {lnum} and {col} +system({expr} [, {input}]) String output of shell command/filter {expr} +systemlist({expr} [, {input}]) List output of shell command/filter {expr} +tabpagebuflist([{arg}]) List list of buffer numbers in tab page +tabpagenr([{arg}]) Number number of current or last tab page +tabpagewinnr({tabarg}[, {arg}]) Number number of current window in tab page +taglist({expr}) List list of tags matching {expr} tagfiles() List tags files used -tan( {expr}) Float tangent of {expr} -tanh( {expr}) Float hyperbolic tangent of {expr} +tan({expr}) Float tangent of {expr} +tanh({expr}) Float hyperbolic tangent of {expr} tempname() String name for a temporary file -timer_start( {time}, {callback} [, {options}]) +timer_start({time}, {callback} [, {options}]) Number create a timer -timer_stop( {timer}) none stop a timer -tolower( {expr}) String the String {expr} switched to lowercase -toupper( {expr}) String the String {expr} switched to uppercase -tr( {src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr} +timer_stop({timer}) none stop a timer +tolower({expr}) String the String {expr} switched to lowercase +toupper({expr}) String the String {expr} switched to uppercase +tr({src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr} to chars in {tostr} -trunc( {expr}) Float truncate Float {expr} -type( {name}) Number type of variable {name} -undofile( {name}) String undo file name for {name} +trunc({expr}) Float truncate Float {expr} +type({name}) Number type of variable {name} +undofile({name}) String undo file name for {name} undotree() List undo file tree -uniq( {list} [, {func} [, {dict}]]) +uniq({list} [, {func} [, {dict}]]) List remove adjacent duplicates from a list -values( {dict}) List values in {dict} -virtcol( {expr}) Number screen column of cursor or mark -visualmode( [expr]) String last visual mode used +values({dict}) List values in {dict} +virtcol({expr}) Number screen column of cursor or mark +visualmode([expr]) String last visual mode used wildmenumode() Number whether 'wildmenu' mode is active -win_findbuf( {bufnr}) List find windows containing {bufnr} -win_getid( [{win} [, {tab}]]) Number get window ID for {win} in {tab} -win_gotoid( {expr}) Number go to window with ID {expr} -win_id2tabwin( {expr}) List get tab and window nr from window ID -win_id2win( {expr}) Number get window nr from window ID -winbufnr( {nr}) Number buffer number of window {nr} +win_findbuf({bufnr}) List find windows containing {bufnr} +win_getid([{win} [, {tab}]]) Number get window ID for {win} in {tab} +win_gotoid({expr}) Number go to window with ID {expr} +win_id2tabwin({expr}) List get tab and window nr from window ID +win_id2win({expr}) Number get window nr from window ID +winbufnr({nr}) Number buffer number of window {nr} wincol() Number window column of the cursor -winheight( {nr}) Number height of window {nr} +winheight({nr}) Number height of window {nr} winline() Number window line of the cursor -winnr( [{expr}]) Number number of current window +winnr([{expr}]) Number number of current window winrestcmd() String returns command to restore window sizes -winrestview( {dict}) none restore view of current window +winrestview({dict}) none restore view of current window winsaveview() Dict save view of current window -winwidth( {nr}) Number width of window {nr} +winwidth({nr}) Number width of window {nr} wordcount() Dict get byte/char/word statistics -writefile( {list}, {fname} [, {flags}]) +writefile({list}, {fname} [, {flags}]) Number write list of lines to file {fname} -xor( {expr}, {expr}) Number bitwise XOR +xor({expr}, {expr}) Number bitwise XOR abs({expr}) *abs()* @@ -4754,9 +4760,9 @@ json_encode({expr}) *json_encode()* String in double quotes (possibly null) Funcref not possible, error List as an array (possibly null); when - used recursively: [] + used recursively: [] Dict as an object (possibly null); when - used recursively: {} + used recursively: {} v:false "false" v:true "true" v:none "null" @@ -6098,7 +6104,7 @@ searchpos({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *searchpos()* < In this example "submatch" is 2 when a lowercase letter is found |/\l|, 3 when an uppercase letter is found |/\u|. -server2client( {clientid}, {string}) *server2client()* +server2client({clientid}, {string}) *server2client()* Send a reply string to {clientid}. The most recent {clientid} that sent a string can be retrieved with expand(""). {only available when compiled with the |+clientserver| feature} @@ -6611,7 +6617,7 @@ sqrt({expr}) *sqrt()* {only available when compiled with the |+float| feature} -str2float( {expr}) *str2float()* +str2float({expr}) *str2float()* Convert String {expr} to a Float. This mostly works the same as when using a floating point number in an expression, see |floating-point-format|. But it's a bit more permissive. @@ -6626,7 +6632,7 @@ str2float( {expr}) *str2float()* < {only available when compiled with the |+float| feature} -str2nr( {expr} [, {base}]) *str2nr()* +str2nr({expr} [, {base}]) *str2nr()* Convert string {expr} to a number. {base} is the conversion base, it can be 2, 8, 10 or 16. When {base} is omitted base 10 is used. This also means that @@ -7136,7 +7142,7 @@ timer_start({time}, {callback} [, {options}]) {options} is a dictionary. Supported entries: "repeat" Number of times to repeat calling the - callback. -1 means forever. + callback. -1 means forever. Example: > func MyHandler(timer) diff --git a/src/ex_cmds.c b/src/ex_cmds.c index daac3ae8d635f2..d83dc405c7a8e9 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -6203,6 +6203,13 @@ find_help_tags( *d++ = *s; + /* + * If tag contains "({" or "([", tag terminates at the "(". + * This is for help on functions, e.g.: abs({expr}). + */ + if (*s == '(' && (s[1] == '{' || s[1] =='[')) + break; + /* * If tag starts with ', toss everything after a second '. Fixes * CTRL-] on 'option'. (would include the trailing '.'). diff --git a/src/testdir/test_help_tagjump.vim b/src/testdir/test_help_tagjump.vim index d1e9ad422b22d4..f486583bc8c938 100644 --- a/src/testdir/test_help_tagjump.vim +++ b/src/testdir/test_help_tagjump.vim @@ -15,4 +15,14 @@ func Test_help_tagjump() call assert_equal("help", &filetype) call assert_true(getline('.') =~ "\\*'buflisted'\\*") helpclose + + exec "help! abs({expr})" + call assert_equal("help", &filetype) + call assert_true(getline('.') =~ '\*abs()\*') + helpclose + + exec "help! arglistid([{winnr}" + call assert_equal("help", &filetype) + call assert_true(getline('.') =~ '\*arglistid()\*') + helpclose endfunc diff --git a/src/version.c b/src/version.c index 6c94bc64b23f77..a8556a838c2e3c 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1728, /**/ 1727, /**/ From 6244a0fc29163ba1c734f92b55a89e01e6cf2a67 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 14 Apr 2016 14:09:25 +0200 Subject: [PATCH 09/29] patch 7.4.1729 Problem: The Perl interface cannot use 'print' operator for writing directly in standard IO. Solution: Add a minimal implementation of PerlIO Layer feature and try to use it for STDOUT/STDERR. (Damien) --- src/if_perl.xs | 98 ++++++++++++++++++++++++++++++++++++++- src/testdir/test_perl.vim | 11 +++++ src/version.c | 2 + 3 files changed, 110 insertions(+), 1 deletion(-) diff --git a/src/if_perl.xs b/src/if_perl.xs index 4fbc13e3a5cd34..b091bf7cab7977 100644 --- a/src/if_perl.xs +++ b/src/if_perl.xs @@ -57,7 +57,9 @@ #include #include #include - +#if defined(PERLIO_LAYERS) && !defined(USE_SFIO) +# include +#endif /* * Work around clashes between Perl and Vim namespace. proto.h doesn't @@ -293,6 +295,10 @@ typedef int perl_key; # define Perl_av_fetch dll_Perl_av_fetch # define Perl_av_len dll_Perl_av_len # define Perl_sv_2nv_flags dll_Perl_sv_2nv_flags +# if defined(PERLIO_LAYERS) && !defined(USE_SFIO) +# define PerlIOBase_pushed dll_PerlIOBase_pushed +# define PerlIO_define_layer dll_PerlIO_define_layer +# endif /* * Declare HANDLE for perl.dll and function pointers. @@ -445,6 +451,10 @@ static SV * (*Perl_hv_iterval)(pTHX_ HV *, HE *); static SV** (*Perl_av_fetch)(pTHX_ AV *, SSize_t, I32); static SSize_t (*Perl_av_len)(pTHX_ AV *); static NV (*Perl_sv_2nv_flags)(pTHX_ SV *const, const I32); +#if defined(PERLIO_LAYERS) && !defined(USE_SFIO) +static IV (*PerlIOBase_pushed)(pTHX_ PerlIO *, const char *, SV *, PerlIO_funcs *); +static void (*PerlIO_define_layer)(pTHX_ PerlIO_funcs *); +#endif /* * Table of name to function pointer of perl. @@ -584,6 +594,10 @@ static struct { {"Perl_av_fetch", (PERL_PROC*)&Perl_av_fetch}, {"Perl_av_len", (PERL_PROC*)&Perl_av_len}, {"Perl_sv_2nv_flags", (PERL_PROC*)&Perl_sv_2nv_flags}, +#if defined(PERLIO_LAYERS) && !defined(USE_SFIO) + {"PerlIOBase_pushed", (PERL_PROC*)&PerlIOBase_pushed}, + {"PerlIO_define_layer", (PERL_PROC*)&PerlIO_define_layer}, +#endif {"", NULL}, }; @@ -646,6 +660,10 @@ perl_enabled(int verbose) } #endif /* DYNAMIC_PERL */ +#if defined(PERLIO_LAYERS) && !defined(USE_SFIO) +static void vim_IOLayer_init(void); +#endif + /* * perl_init(): initialize perl interpreter * We have to call perl_parse to initialize some structures, @@ -671,6 +689,8 @@ perl_init(void) sfdisc(PerlIO_stderr(), sfdcnewvim()); sfsetbuf(PerlIO_stdout(), NULL, 0); sfsetbuf(PerlIO_stderr(), NULL, 0); +#elif defined(PERLIO_LAYERS) + vim_IOLayer_init(); #endif } @@ -1307,6 +1327,82 @@ err: } } +#if defined(PERLIO_LAYERS) && !defined(USE_SFIO) +typedef struct { + struct _PerlIO base; + int attr; +} PerlIOVim; + + static IV +PerlIOVim_pushed(pTHX_ PerlIO *f, const char *mode, + SV *arg, PerlIO_funcs *tab) +{ + PerlIOVim *s = PerlIOSelf(f, PerlIOVim); + s->attr = 0; + if (arg && SvPOK(arg)) { + int id = syn_name2id((char_u *)SvPV_nolen(arg)); + if (id != 0) + s->attr = syn_id2attr(id); + } + return PerlIOBase_pushed(aTHX_ f, mode, (SV *)NULL, tab); +} + + static SSize_t +PerlIOVim_write(pTHX_ PerlIO *f, const void *vbuf, Size_t count) +{ + char_u *str; + PerlIOVim * s = PerlIOSelf(f, PerlIOVim); + + str = vim_strnsave((char_u *)vbuf, count); + if (str == NULL) + return 0; + msg_split((char_u *)str, s->attr); + vim_free(str); + + return count; +} + +static PERLIO_FUNCS_DECL(PerlIO_Vim) = { + sizeof(PerlIO_funcs), + "Vim", + sizeof(PerlIOVim), + PERLIO_K_DUMMY, /* flags */ + PerlIOVim_pushed, + NULL, /* popped */ + NULL, /* open */ + NULL, /* binmode */ + NULL, /* arg */ + NULL, /* fileno */ + NULL, /* dup */ + NULL, /* read */ + NULL, /* unread */ + PerlIOVim_write, + NULL, /* seek */ + NULL, /* tell */ + NULL, /* close */ + NULL, /* flush */ + NULL, /* fill */ + NULL, /* eof */ + NULL, /* error */ + NULL, /* clearerr */ + NULL, /* setlinebuf */ + NULL, /* get_base */ + NULL, /* get_bufsiz */ + NULL, /* get_ptr */ + NULL, /* get_cnt */ + NULL /* set_ptrcnt */ +}; + +/* Use Vim routine for print operator */ + static void +vim_IOLayer_init(void) +{ + PerlIO_define_layer(aTHX_ PERLIO_FUNCS_CAST(&PerlIO_Vim)); + (void)eval_pv( "binmode(STDOUT, ':Vim')" + " && binmode(STDERR, ':Vim(ErrorMsg)');", 0); +} +#endif /* PERLIO_LAYERS && !USE_SFIO */ + #ifndef FEAT_WINDOWS int win_valid(win_T *w) diff --git a/src/testdir/test_perl.vim b/src/testdir/test_perl.vim index 79e24f4ac8f53b..b523805a8998d6 100644 --- a/src/testdir/test_perl.vim +++ b/src/testdir/test_perl.vim @@ -92,3 +92,14 @@ function Test_VIM_package() perl VIM::SetOption('et') call assert_true(&et) endf + +function Test_stdio() + redir =>l:out + perl < Date: Thu, 14 Apr 2016 15:13:46 +0200 Subject: [PATCH 10/29] patch 7.4.1730 Problem: It is not easy to get a character out of a string. Solution: Add strgetchar() and strcharpart(). --- src/eval.c | 109 ++++++++++++++++++++++++++++++++++++++ src/testdir/test_expr.vim | 47 ++++++++++++++++ src/version.c | 2 + 3 files changed, 158 insertions(+) diff --git a/src/eval.c b/src/eval.c index 86580450fca5fe..9dd4d84d3979c0 100644 --- a/src/eval.c +++ b/src/eval.c @@ -779,9 +779,11 @@ static void f_strchars(typval_T *argvars, typval_T *rettv); #ifdef HAVE_STRFTIME static void f_strftime(typval_T *argvars, typval_T *rettv); #endif +static void f_strgetchar(typval_T *argvars, typval_T *rettv); static void f_stridx(typval_T *argvars, typval_T *rettv); static void f_string(typval_T *argvars, typval_T *rettv); static void f_strlen(typval_T *argvars, typval_T *rettv); +static void f_strcharpart(typval_T *argvars, typval_T *rettv); static void f_strpart(typval_T *argvars, typval_T *rettv); static void f_strridx(typval_T *argvars, typval_T *rettv); static void f_strtrans(typval_T *argvars, typval_T *rettv); @@ -8635,11 +8637,13 @@ static struct fst {"str2float", 1, 1, f_str2float}, #endif {"str2nr", 1, 2, f_str2nr}, + {"strcharpart", 2, 3, f_strcharpart}, {"strchars", 1, 2, f_strchars}, {"strdisplaywidth", 1, 2, f_strdisplaywidth}, #ifdef HAVE_STRFTIME {"strftime", 1, 2, f_strftime}, #endif + {"strgetchar", 2, 2, f_strgetchar}, {"stridx", 2, 3, f_stridx}, {"string", 1, 1, f_string}, {"strlen", 1, 1, f_strlen}, @@ -19550,6 +19554,46 @@ f_strftime(typval_T *argvars, typval_T *rettv) } #endif +/* + * "strgetchar()" function + */ + static void +f_strgetchar(typval_T *argvars, typval_T *rettv) +{ + char_u *str; + int len; + int error = FALSE; + int charidx; + + rettv->vval.v_number = -1; + str = get_tv_string_chk(&argvars[0]); + if (str == NULL) + return; + len = (int)STRLEN(str); + charidx = get_tv_number_chk(&argvars[1], &error); + if (error) + return; +#ifdef FEAT_MBYTE + { + int byteidx = 0; + + while (charidx >= 0 && byteidx < len) + { + if (charidx == 0) + { + rettv->vval.v_number = mb_ptr2char(str + byteidx); + break; + } + --charidx; + byteidx += mb_char2len(str[byteidx]); + } + } +#else + if (charidx < len) + rettv->vval.v_number = str[charidx]; +#endif +} + /* * "stridx()" function */ @@ -19677,6 +19721,71 @@ f_strwidth(typval_T *argvars, typval_T *rettv) ); } +/* + * "strcharpart()" function + */ + static void +f_strcharpart(typval_T *argvars, typval_T *rettv) +{ +#ifdef FEAT_MBYTE + char_u *p; + int nchar; + int nbyte = 0; + int charlen; + int len = 0; + int slen; + int error = FALSE; + + p = get_tv_string(&argvars[0]); + slen = (int)STRLEN(p); + + nchar = get_tv_number_chk(&argvars[1], &error); + if (!error) + { + if (nchar > 0) + while (nchar > 0 && nbyte < slen) + { + nbyte += mb_char2len(p[nbyte]); + --nchar; + } + else + nbyte = nchar; + if (argvars[2].v_type != VAR_UNKNOWN) + { + charlen = get_tv_number(&argvars[2]); + while (charlen > 0 && nbyte + len < slen) + { + len += mb_char2len(p[nbyte + len]); + --charlen; + } + } + else + len = slen - nbyte; /* default: all bytes that are available. */ + } + + /* + * Only return the overlap between the specified part and the actual + * string. + */ + if (nbyte < 0) + { + len += nbyte; + nbyte = 0; + } + else if (nbyte > slen) + nbyte = slen; + if (len < 0) + len = 0; + else if (nbyte + len > slen) + len = slen - nbyte; + + rettv->v_type = VAR_STRING; + rettv->vval.v_string = vim_strnsave(p + nbyte, len); +#else + f_strpart(argvars, rettv); +#endif +} + /* * "strpart()" function */ diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim index 33115c7f1fe223..cdaf45ee734422 100644 --- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -50,3 +50,50 @@ func Test_dict() call assert_equal('none', d['']) call assert_equal('aaa', d['a']) endfunc + +func Test_strgetchar() + call assert_equal(char2nr('a'), strgetchar('axb', 0)) + call assert_equal(char2nr('x'), strgetchar('axb', 1)) + call assert_equal(char2nr('b'), strgetchar('axb', 2)) + + call assert_equal(-1, strgetchar('axb', -1)) + call assert_equal(-1, strgetchar('axb', 3)) + call assert_equal(-1, strgetchar('', 0)) + + if !has('multi_byte') + return + endif + + call assert_equal(char2nr('á'), strgetchar('áxb', 0)) + call assert_equal(char2nr('x'), strgetchar('áxb', 1)) + + call assert_equal(char2nr('a'), strgetchar('àxb', 0)) + call assert_equal(char2nr('̀'), strgetchar('àxb', 1)) + call assert_equal(char2nr('x'), strgetchar('àxb', 2)) +endfunc + +func Test_strcharpart() + call assert_equal('a', strcharpart('axb', 0, 1)) + call assert_equal('x', strcharpart('axb', 1, 1)) + call assert_equal('b', strcharpart('axb', 2, 1)) + call assert_equal('xb', strcharpart('axb', 1)) + + call assert_equal('', strcharpart('axb', 1, 0)) + call assert_equal('', strcharpart('axb', 1, -1)) + call assert_equal('', strcharpart('axb', -1, 1)) + call assert_equal('', strcharpart('axb', -2, 2)) + + call assert_equal('a', strcharpart('axb', -1, 2)) + + if !has('multi_byte') + return + endif + + call assert_equal('áxb', strcharpart('áxb', 0)) + call assert_equal('á', strcharpart('áxb', 0, 1)) + call assert_equal('x', strcharpart('áxb', 1, 1)) + + call assert_equal('a', strcharpart('àxb', 0, 1)) + call assert_equal('̀', strcharpart('àxb', 1, 1)) + call assert_equal('x', strcharpart('àxb', 2, 1)) +endfunc diff --git a/src/version.c b/src/version.c index 26831238bf901f..7132e0b07200d4 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1730, /**/ 1729, /**/ From 8110a091bc749d8748a20807a724a3af3ca6d509 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 14 Apr 2016 15:56:09 +0200 Subject: [PATCH 11/29] patch 7.4.1731 Problem: Python: turns partial into simple funcref. Solution: Use partials like partials. (Nikolai Pavlov, closes #734) --- runtime/doc/if_pyth.txt | 28 +++- src/eval.c | 3 +- src/if_py_both.h | 294 ++++++++++++++++++++++++++++++++++++---- src/if_python.c | 10 +- src/if_python3.c | 10 +- src/proto/eval.pro | 1 + src/testdir/test86.in | 203 ++++++++++++++++++++++++++- src/testdir/test86.ok | 114 +++++++++++++++- src/testdir/test87.in | 206 ++++++++++++++++++++++++++-- src/testdir/test87.ok | 114 +++++++++++++++- src/version.c | 2 + 11 files changed, 923 insertions(+), 62 deletions(-) diff --git a/runtime/doc/if_pyth.txt b/runtime/doc/if_pyth.txt index 4f79c575b30bd3..3d91814b4f84ee 100644 --- a/runtime/doc/if_pyth.txt +++ b/runtime/doc/if_pyth.txt @@ -653,10 +653,25 @@ vim.List object *python-List* class List(vim.List): # Subclassing vim.Function object *python-Function* - Function-like object, acting like vim |Funcref| object. Supports `.name` - attribute and is callable. Accepts special keyword argument `self`, see - |Dictionary-function|. You can also use `vim.Function(name)` constructor, - it is the same as `vim.bindeval('function(%s)'%json.dumps(name))`. + Function-like object, acting like vim |Funcref| object. Accepts special + keyword argument `self`, see |Dictionary-function|. You can also use + `vim.Function(name)` constructor, it is the same as + `vim.bindeval('function(%s)'%json.dumps(name))`. + + Attributes (read-only): + Attribute Description ~ + name Function name. + args `None` or a |python-List| object with arguments. Note that + this is a copy of the arguments list, constructed each time + you request this attribute. Modifications made to the list + will be ignored (but not to the containers inside argument + list: this is like |copy()| and not |deepcopy()|). + self `None` or a |python-Dictionary| object with self + dictionary. Note that explicit `self` keyword used when + calling resulting object overrides this attribute. + + Constructor additionally accepts `args` and `self` keywords. If any of + them is given then it constructs a partial, see |function()|. Examples: > f = vim.Function('tr') # Constructor @@ -670,6 +685,11 @@ vim.Function object *python-Function* print f(self={}) # Like call('DictFun', [], {}) print isinstance(f, vim.Function) # True + p = vim.Function('DictFun', self={}) + print f() + p = vim.Function('tr', args=['abc', 'a']) + print f('b') + ============================================================================== 8. pyeval() and py3eval() Vim functions *python-pyeval* diff --git a/src/eval.c b/src/eval.c index 9dd4d84d3979c0..5ced88ef06fc6e 100644 --- a/src/eval.c +++ b/src/eval.c @@ -453,7 +453,6 @@ static long dict_len(dict_T *d); static char_u *dict2string(typval_T *tv, int copyID); static int get_dict_tv(char_u **arg, typval_T *rettv, int evaluate); static char_u *echo_string(typval_T *tv, char_u **tofree, char_u *numbuf, int copyID); -static char_u *tv2string(typval_T *tv, char_u **tofree, char_u *numbuf, int copyID); static char_u *string_quote(char_u *str, int function); static int get_env_tv(char_u **arg, typval_T *rettv, int evaluate); static int find_internal_func(char_u *name); @@ -8153,7 +8152,7 @@ echo_string( * Puts quotes around strings, so that they can be parsed back by eval(). * May return NULL. */ - static char_u * + char_u * tv2string( typval_T *tv, char_u **tofree, diff --git a/src/if_py_both.h b/src/if_py_both.h index ee882600fc64d2..d6ae8806665f18 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -72,6 +72,7 @@ typedef void (*runner)(const char *, void * static int ConvertFromPyObject(PyObject *, typval_T *); static int _ConvertFromPyObject(PyObject *, typval_T *, PyObject *); static int ConvertFromPyMapping(PyObject *, typval_T *); +static int ConvertFromPySequence(PyObject *, typval_T *); static PyObject *WindowNew(win_T *, tabpage_T *); static PyObject *BufferNew (buf_T *); static PyObject *LineToString(const char *); @@ -1433,6 +1434,7 @@ typedef struct pylinkedlist_S { static pylinkedlist_T *lastdict = NULL; static pylinkedlist_T *lastlist = NULL; +static pylinkedlist_T *lastfunc = NULL; static void pyll_remove(pylinkedlist_T *ref, pylinkedlist_T **last) @@ -2828,14 +2830,20 @@ typedef struct { PyObject_HEAD char_u *name; + int argc; + typval_T *argv; + dict_T *self; + pylinkedlist_T ref; } FunctionObject; static PyTypeObject FunctionType; -#define NEW_FUNCTION(name) FunctionNew(&FunctionType, name) +#define NEW_FUNCTION(name, argc, argv, self) \ + FunctionNew(&FunctionType, name, argc, argv, self) static PyObject * -FunctionNew(PyTypeObject *subtype, char_u *name) +FunctionNew(PyTypeObject *subtype, char_u *name, int argc, typval_T *argv, + dict_T *selfdict) { FunctionObject *self; @@ -2865,6 +2873,13 @@ FunctionNew(PyTypeObject *subtype, char_u *name) return NULL; } + self->argc = argc; + self->argv = argv; + self->self = selfdict; + + if (self->argv || self->self) + pyll_add((PyObject *)(self), &self->ref, &lastfunc); + return (PyObject *)(self); } @@ -2872,19 +2887,59 @@ FunctionNew(PyTypeObject *subtype, char_u *name) FunctionConstructor(PyTypeObject *subtype, PyObject *args, PyObject *kwargs) { PyObject *self; + PyObject *selfdictObject; + PyObject *argsObject = NULL; char_u *name; + typval_T selfdicttv; + typval_T argstv; + list_T *argslist = NULL; + dict_T *selfdict = NULL; + int argc = 0; + typval_T *argv = NULL; + typval_T *curtv; + listitem_T *li; - if (kwargs) + if (kwargs != NULL) { - PyErr_SET_STRING(PyExc_TypeError, - N_("function constructor does not accept keyword arguments")); - return NULL; + selfdictObject = PyDict_GetItemString(kwargs, "self"); + if (selfdictObject != NULL) + { + if (ConvertFromPyMapping(selfdictObject, &selfdicttv) == -1) + return NULL; + selfdict = selfdicttv.vval.v_dict; + } + argsObject = PyDict_GetItemString(kwargs, "args"); + if (argsObject != NULL) + { + if (ConvertFromPySequence(argsObject, &argstv) == -1) + { + dict_unref(selfdict); + return NULL; + } + argslist = argstv.vval.v_list; + + argc = argslist->lv_len; + if (argc != 0) + { + argv = PyMem_New(typval_T, (size_t) argc); + curtv = argv; + for (li = argslist->lv_first; li != NULL; li = li->li_next) + copy_tv(&li->li_tv, curtv++); + } + list_unref(argslist); + } } if (!PyArg_ParseTuple(args, "et", "ascii", &name)) + { + dict_unref(selfdict); + while (argc--) + clear_tv(&argv[argc]); + PyMem_Free(argv); return NULL; + } - self = FunctionNew(subtype, name); + self = FunctionNew(subtype, name, argc, argv, selfdict); PyMem_Free(name); @@ -2894,14 +2949,21 @@ FunctionConstructor(PyTypeObject *subtype, PyObject *args, PyObject *kwargs) static void FunctionDestructor(FunctionObject *self) { + int i; func_unref(self->name); vim_free(self->name); + for (i = 0; i < self->argc; ++i) + clear_tv(&self->argv[i]); + PyMem_Free(self->argv); + dict_unref(self->self); + if (self->argv || self->self) + pyll_remove(&self->ref, &lastfunc); DESTRUCTOR_FINISH(self); } static char *FunctionAttrs[] = { - "softspace", + "softspace", "args", "self", NULL }; @@ -2911,6 +2973,69 @@ FunctionDir(PyObject *self) return ObjectDir(self, FunctionAttrs); } + static PyObject * +FunctionAttr(FunctionObject *self, char *name) +{ + list_T *list; + int i; + if (strcmp(name, "name") == 0) + return PyString_FromString((char *)(self->name)); + else if (strcmp(name, "args") == 0) + { + if (self->argv == NULL) + return AlwaysNone(NULL); + list = list_alloc(); + for (i = 0; i < self->argc; ++i) + list_append_tv(list, &self->argv[i]); + return NEW_LIST(list); + } + else if (strcmp(name, "self") == 0) + return self->self == NULL + ? AlwaysNone(NULL) + : NEW_DICTIONARY(self->self); + else if (strcmp(name, "__members__") == 0) + return ObjectDir(NULL, FunctionAttrs); + return NULL; +} + +/* Populate partial_T given function object. + * + * "exported" should be set to true when it is needed to construct a partial + * that may be stored in a variable (i.e. may be freed by Vim). + */ + static void +set_partial(FunctionObject *self, partial_T *pt, int exported) +{ + typval_T *curtv; + int i; + + pt->pt_name = self->name; + if (self->argv) + { + pt->pt_argc = self->argc; + if (exported) + { + pt->pt_argv = (typval_T *)alloc_clear( + sizeof(typval_T) * self->argc); + for (i = 0; i < pt->pt_argc; ++i) + copy_tv(&self->argv[i], &pt->pt_argv[i]); + } + else + pt->pt_argv = self->argv; + } + else + { + pt->pt_argc = 0; + pt->pt_argv = NULL; + } + pt->pt_dict = self->self; + if (exported && self->self) + ++pt->pt_dict->dv_refcount; + if (exported) + pt->pt_name = vim_strsave(pt->pt_name); + pt->pt_refcount = 1; +} + static PyObject * FunctionCall(FunctionObject *self, PyObject *argsObject, PyObject *kwargs) { @@ -2922,8 +3047,10 @@ FunctionCall(FunctionObject *self, PyObject *argsObject, PyObject *kwargs) PyObject *selfdictObject; PyObject *ret; int error; + partial_T pt; + partial_T *pt_ptr = NULL; - if (ConvertFromPyObject(argsObject, &args) == -1) + if (ConvertFromPySequence(argsObject, &args) == -1) return NULL; if (kwargs != NULL) @@ -2940,11 +3067,17 @@ FunctionCall(FunctionObject *self, PyObject *argsObject, PyObject *kwargs) } } + if (self->argv || self->self) + { + set_partial(self, &pt, FALSE); + pt_ptr = &pt; + } + Py_BEGIN_ALLOW_THREADS Python_Lock_Vim(); VimTryStart(); - error = func_call(name, &args, NULL, selfdict, &rettv); + error = func_call(name, &args, pt_ptr, selfdict, &rettv); Python_Release_Vim(); Py_END_ALLOW_THREADS @@ -2970,14 +3103,49 @@ FunctionCall(FunctionObject *self, PyObject *argsObject, PyObject *kwargs) static PyObject * FunctionRepr(FunctionObject *self) { -#ifdef Py_TRACE_REFS - /* For unknown reason self->name may be NULL after calling - * Finalize */ - return PyString_FromFormat("", - (self->name == NULL ? "" : (char *)self->name)); -#else - return PyString_FromFormat("", (char *)self->name); -#endif + PyObject *ret; + garray_T repr_ga; + int i; + char_u *tofree = NULL; + typval_T tv; + char_u numbuf[NUMBUFLEN]; + + ga_init2(&repr_ga, (int)sizeof(char), 70); + ga_concat(&repr_ga, (char_u *)"name) + ga_concat(&repr_ga, self->name); + else + ga_concat(&repr_ga, (char_u *)""); + ga_append(&repr_ga, '\''); + if (self->argv) + { + ga_concat(&repr_ga, (char_u *)", args=["); + ++emsg_silent; + for (i = 0; i < self->argc; i++) + { + if (i != 0) + ga_concat(&repr_ga, (char_u *)", "); + ga_concat(&repr_ga, tv2string(&self->argv[i], &tofree, numbuf, + get_copyID())); + vim_free(tofree); + } + --emsg_silent; + ga_append(&repr_ga, ']'); + } + if (self->self) + { + ga_concat(&repr_ga, (char_u *)", self="); + tv.v_type = VAR_DICT; + tv.vval.v_dict = self->self; + ++emsg_silent; + ga_concat(&repr_ga, tv2string(&tv, &tofree, numbuf, get_copyID())); + --emsg_silent; + vim_free(tofree); + } + ga_append(&repr_ga, '>'); + ret = PyString_FromString((char *)repr_ga.ga_data); + ga_clear(&repr_ga); + return ret; } static struct PyMethodDef FunctionMethods[] = { @@ -5551,11 +5719,13 @@ set_ref_in_py(const int copyID) pylinkedlist_T *cur; dict_T *dd; list_T *ll; + int i; int abort = FALSE; + FunctionObject *func; if (lastdict != NULL) { - for(cur = lastdict ; !abort && cur != NULL ; cur = cur->pll_prev) + for (cur = lastdict ; !abort && cur != NULL ; cur = cur->pll_prev) { dd = ((DictionaryObject *) (cur->pll_obj))->dict; if (dd->dv_copyID != copyID) @@ -5568,7 +5738,7 @@ set_ref_in_py(const int copyID) if (lastlist != NULL) { - for(cur = lastlist ; !abort && cur != NULL ; cur = cur->pll_prev) + for (cur = lastlist ; !abort && cur != NULL ; cur = cur->pll_prev) { ll = ((ListObject *) (cur->pll_obj))->list; if (ll->lv_copyID != copyID) @@ -5579,6 +5749,24 @@ set_ref_in_py(const int copyID) } } + if (lastfunc != NULL) + { + for (cur = lastfunc ; !abort && cur != NULL ; cur = cur->pll_prev) + { + func = (FunctionObject *) cur->pll_obj; + if (func->self != NULL && func->self->dv_copyID != copyID) + { + func->self->dv_copyID = copyID; + abort = abort || set_ref_in_ht( + &func->self->dv_hashtab, copyID, NULL); + } + if (func->argc) + for (i = 0; !abort && i < func->argc; ++i) + abort = abort + || set_ref_in_item(&func->argv[i], copyID, NULL, NULL); + } + } + return abort; } @@ -5879,6 +6067,34 @@ ConvertFromPyMapping(PyObject *obj, typval_T *tv) return ret; } + static int +ConvertFromPySequence(PyObject *obj, typval_T *tv) +{ + PyObject *lookup_dict; + int ret; + + if (!(lookup_dict = PyDict_New())) + return -1; + + if (PyType_IsSubtype(obj->ob_type, &ListType)) + { + tv->v_type = VAR_LIST; + tv->vval.v_list = (((ListObject *)(obj))->list); + ++tv->vval.v_list->lv_refcount; + } + else if (PyIter_Check(obj) || PySequence_Check(obj)) + return convert_dl(obj, tv, pyseq_to_tv, lookup_dict); + else + { + PyErr_FORMAT(PyExc_TypeError, + N_("unable to convert %s to vim list"), + Py_TYPE_NAME(obj)); + ret = -1; + } + Py_DECREF(lookup_dict); + return ret; +} + static int ConvertFromPyObject(PyObject *obj, typval_T *tv) { @@ -5909,11 +6125,22 @@ _ConvertFromPyObject(PyObject *obj, typval_T *tv, PyObject *lookup_dict) } else if (PyType_IsSubtype(obj->ob_type, &FunctionType)) { - if (set_string_copy(((FunctionObject *) (obj))->name, tv) == -1) - return -1; + FunctionObject *func = (FunctionObject *) obj; + if (func->self != NULL || func->argv != NULL) + { + partial_T *pt = (partial_T *)alloc_clear(sizeof(partial_T)); + set_partial(func, pt, TRUE); + tv->vval.v_partial = pt; + tv->v_type = VAR_PARTIAL; + } + else + { + if (set_string_copy(func->name, tv) == -1) + return -1; - tv->v_type = VAR_FUNC; - func_ref(tv->vval.v_string); + tv->v_type = VAR_FUNC; + } + func_ref(func->name); } else if (PyBytes_Check(obj)) { @@ -6009,6 +6236,8 @@ _ConvertFromPyObject(PyObject *obj, typval_T *tv, PyObject *lookup_dict) static PyObject * ConvertToPyObject(typval_T *tv) { + typval_T *argv; + int i; if (tv == NULL) { PyErr_SET_VIM(N_("internal error: NULL reference passed")); @@ -6031,10 +6260,23 @@ ConvertToPyObject(typval_T *tv) return NEW_DICTIONARY(tv->vval.v_dict); case VAR_FUNC: return NEW_FUNCTION(tv->vval.v_string == NULL - ? (char_u *)"" : tv->vval.v_string); + ? (char_u *)"" : tv->vval.v_string, + 0, NULL, NULL); case VAR_PARTIAL: + if (tv->vval.v_partial->pt_argc) + { + argv = PyMem_New(typval_T, (size_t)tv->vval.v_partial->pt_argc); + for (i = 0; i < tv->vval.v_partial->pt_argc; i++) + copy_tv(&tv->vval.v_partial->pt_argv[i], &argv[i]); + } + else + argv = NULL; + if (tv->vval.v_partial->pt_dict != NULL) + tv->vval.v_partial->pt_dict->dv_refcount++; return NEW_FUNCTION(tv->vval.v_partial == NULL - ? (char_u *)"" : tv->vval.v_partial->pt_name); + ? (char_u *)"" : tv->vval.v_partial->pt_name, + tv->vval.v_partial->pt_argc, argv, + tv->vval.v_partial->pt_dict); case VAR_UNKNOWN: case VAR_CHANNEL: case VAR_JOB: diff --git a/src/if_python.c b/src/if_python.c index fa3fc88a866044..a54a0e217dcf40 100644 --- a/src/if_python.c +++ b/src/if_python.c @@ -1539,12 +1539,12 @@ ListGetattr(PyObject *self, char *name) static PyObject * FunctionGetattr(PyObject *self, char *name) { - FunctionObject *this = (FunctionObject *)(self); + PyObject *r; - if (strcmp(name, "name") == 0) - return PyString_FromString((char *)(this->name)); - else if (strcmp(name, "__members__") == 0) - return ObjectDir(NULL, FunctionAttrs); + r = FunctionAttr((FunctionObject *)(self), name); + + if (r || PyErr_Occurred()) + return r; else return Py_FindMethod(FunctionMethods, self, name); } diff --git a/src/if_python3.c b/src/if_python3.c index 5cf508fc71247c..d2f6066cb8655c 100644 --- a/src/if_python3.c +++ b/src/if_python3.c @@ -1528,14 +1528,16 @@ ListSetattro(PyObject *self, PyObject *nameobj, PyObject *val) static PyObject * FunctionGetattro(PyObject *self, PyObject *nameobj) { + PyObject *r; FunctionObject *this = (FunctionObject *)(self); GET_ATTR_STRING(name, nameobj); - if (strcmp(name, "name") == 0) - return PyUnicode_FromString((char *)(this->name)); - - return PyObject_GenericGetAttr(self, nameobj); + r = FunctionAttr(this, name); + if (r || PyErr_Occurred()) + return r; + else + return PyObject_GenericGetAttr(self, nameobj); } /* External interface diff --git a/src/proto/eval.pro b/src/proto/eval.pro index 9fda13c9c5facc..60fad80634f7e6 100644 --- a/src/proto/eval.pro +++ b/src/proto/eval.pro @@ -150,4 +150,5 @@ void ex_oldfiles(exarg_T *eap); void reset_v_option_vars(void); int modify_fname(char_u *src, int *usedlen, char_u **fnamep, char_u **bufp, int *fnamelen); char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags); +char_u *tv2string(typval_T *tv, char_u **tofree, char_u *numbuf, int copyID); /* vim: set ft=c : */ diff --git a/src/testdir/test86.in b/src/testdir/test86.in index cc76cff8d40379..6f47ff6813acaf 100644 --- a/src/testdir/test86.in +++ b/src/testdir/test86.in @@ -13,6 +13,7 @@ STARTTEST :lang C :fun Test() :py import vim +:py cb = vim.current.buffer :let l = [] :py l=vim.bindeval('l') :py f=vim.bindeval('function("strlen")') @@ -207,7 +208,15 @@ EOF :let l = [0, 1, 2, 3] :py l=vim.bindeval('l') :lockvar! l -:py l[2]='i' +py << EOF +def emsg(ei): + return ei[0].__name__ + ':' + repr(ei[1].args) + +try: + l[2]='i' +except vim.error: + cb.append('l[2] threw vim.error: ' + emsg(sys.exc_info())) +EOF :$put =string(l) :unlockvar! l :" @@ -219,7 +228,7 @@ def ee(expr, g=globals(), l=locals()): exec(expr, g, l) except: ei = sys.exc_info() - msg = sys.exc_info()[0].__name__ + ':' + repr(sys.exc_info()[1].args) + msg = emsg(ei) msg = msg.replace('TypeError:(\'argument 1 ', 'TypeError:(\'') if expr.find('None') > -1: msg = msg.replace('TypeError:(\'iteration over non-sequence\',)', @@ -611,7 +620,6 @@ EOF : autocmd BufFilePre * python cb.append(vim.eval('expand("")') + ':BufFilePre:' + vim.eval('bufnr("%")')) :augroup END py << EOF -cb = vim.current.buffer # Tests BufferAppend and BufferItem cb.append(b[0]) # Tests BufferSlice and BufferAssSlice @@ -865,6 +873,175 @@ EOF :$put =string(pyeval('vim.List()')) :$put =string(pyeval('vim.List(iter(''abc7''))')) :$put =string(pyeval('vim.Function(''tr'')')) +:$put =string(pyeval('vim.Function(''tr'', args=[123, 3, 4])')) +:$put =string(pyeval('vim.Function(''tr'', args=[])')) +:$put =string(pyeval('vim.Function(''tr'', self={})')) +:$put =string(pyeval('vim.Function(''tr'', args=[123, 3, 4], self={})')) +:" +:" Test vim.Function +:function Args(...) +: return a:000 +:endfunction +:function SelfArgs(...) dict +: return [a:000, self] +:endfunction +:" The following four lines should not crash +:let Pt = function('tr', [[]], {'l': []}) +:py Pt = vim.bindeval('Pt') +:unlet Pt +:py del Pt +py << EOF +def ecall(out_prefix, func, *args, **kwargs): + line = out_prefix + ': ' + try: + ret = func(*args, **kwargs) + except Exception: + line += '!exception: ' + emsg(sys.exc_info()) + else: + line += '!result: ' + vim.Function('string')(ret) + cb.append(line) +a = vim.Function('Args') +pa1 = vim.Function('Args', args=['abcArgsPA1']) +pa2 = vim.Function('Args', args=[]) +pa3 = vim.Function('Args', args=['abcArgsPA3'], self={'abcSelfPA3': 'abcSelfPA3Val'}) +pa4 = vim.Function('Args', self={'abcSelfPA4': 'abcSelfPA4Val'}) +cb.append('a: ' + repr(a)) +cb.append('pa1: ' + repr(pa1)) +cb.append('pa2: ' + repr(pa2)) +cb.append('pa3: ' + repr(pa3)) +cb.append('pa4: ' + repr(pa4)) +sa = vim.Function('SelfArgs') +psa1 = vim.Function('SelfArgs', args=['abcArgsPSA1']) +psa2 = vim.Function('SelfArgs', args=[]) +psa3 = vim.Function('SelfArgs', args=['abcArgsPSA3'], self={'abcSelfPSA3': 'abcSelfPSA3Val'}) +psa4 = vim.Function('SelfArgs', self={'abcSelfPSA4': 'abcSelfPSA4Val'}) +cb.append('sa: ' + repr(sa)) +cb.append('psa1: ' + repr(psa1)) +cb.append('psa2: ' + repr(psa2)) +cb.append('psa3: ' + repr(psa3)) +cb.append('psa4: ' + repr(psa4)) + +psar = vim.Function('SelfArgs', args=[{'abcArgsPSAr': 'abcArgsPSArVal'}], self={'abcSelfPSAr': 'abcSelfPSArVal'}) +psar.args[0]['abcArgsPSAr2'] = [psar.self, psar.args[0]] +psar.self['rec'] = psar +psar.self['self'] = psar.self +psar.self['args'] = psar.args + +try: + cb.append('psar: ' + repr(psar)) +except Exception: + cb.append('!!!!!!!! Caught exception: ' + emsg(sys.exc_info())) +EOF +:$put ='s(a): '.string(pyeval('a')) +:$put ='s(pa1): '.string(pyeval('pa1')) +:$put ='s(pa2): '.string(pyeval('pa2')) +:$put ='s(pa3): '.string(pyeval('pa3')) +:$put ='s(pa4): '.string(pyeval('pa4')) +:$put ='s(sa): '.string(pyeval('sa')) +:$put ='s(psa1): '.string(pyeval('psa1')) +:$put ='s(psa2): '.string(pyeval('psa2')) +:$put ='s(psa3): '.string(pyeval('psa3')) +:$put ='s(psa4): '.string(pyeval('psa4')) +: +:py ecall('a()', a, ) +:py ecall('pa1()', pa1, ) +:py ecall('pa2()', pa2, ) +:py ecall('pa3()', pa3, ) +:py ecall('pa4()', pa4, ) +:py ecall('sa()', sa, ) +:py ecall('psa1()', psa1, ) +:py ecall('psa2()', psa2, ) +:py ecall('psa3()', psa3, ) +:py ecall('psa4()', psa4, ) +: +:py ecall('a(42, 43)', a, 42, 43) +:py ecall('pa1(42, 43)', pa1, 42, 43) +:py ecall('pa2(42, 43)', pa2, 42, 43) +:py ecall('pa3(42, 43)', pa3, 42, 43) +:py ecall('pa4(42, 43)', pa4, 42, 43) +:py ecall('sa(42, 43)', sa, 42, 43) +:py ecall('psa1(42, 43)', psa1, 42, 43) +:py ecall('psa2(42, 43)', psa2, 42, 43) +:py ecall('psa3(42, 43)', psa3, 42, 43) +:py ecall('psa4(42, 43)', psa4, 42, 43) +: +:py ecall('a(42, self={"20": 1})', a, 42, self={'20': 1}) +:py ecall('pa1(42, self={"20": 1})', pa1, 42, self={'20': 1}) +:py ecall('pa2(42, self={"20": 1})', pa2, 42, self={'20': 1}) +:py ecall('pa3(42, self={"20": 1})', pa3, 42, self={'20': 1}) +:py ecall('pa4(42, self={"20": 1})', pa4, 42, self={'20': 1}) +:py ecall('sa(42, self={"20": 1})', sa, 42, self={'20': 1}) +:py ecall('psa1(42, self={"20": 1})', psa1, 42, self={'20': 1}) +:py ecall('psa2(42, self={"20": 1})', psa2, 42, self={'20': 1}) +:py ecall('psa3(42, self={"20": 1})', psa3, 42, self={'20': 1}) +:py ecall('psa4(42, self={"20": 1})', psa4, 42, self={'20': 1}) +: +:py ecall('a(self={"20": 1})', a, self={'20': 1}) +:py ecall('pa1(self={"20": 1})', pa1, self={'20': 1}) +:py ecall('pa2(self={"20": 1})', pa2, self={'20': 1}) +:py ecall('pa3(self={"20": 1})', pa3, self={'20': 1}) +:py ecall('pa4(self={"20": 1})', pa4, self={'20': 1}) +:py ecall('sa(self={"20": 1})', sa, self={'20': 1}) +:py ecall('psa1(self={"20": 1})', psa1, self={'20': 1}) +:py ecall('psa2(self={"20": 1})', psa2, self={'20': 1}) +:py ecall('psa3(self={"20": 1})', psa3, self={'20': 1}) +:py ecall('psa4(self={"20": 1})', psa4, self={'20': 1}) +py << EOF +def s(v): + if v is None: + return repr(v) + else: + return vim.Function('string')(v) + +cb.append('a.args: ' + s(a.args)) +cb.append('pa1.args: ' + s(pa1.args)) +cb.append('pa2.args: ' + s(pa2.args)) +cb.append('pa3.args: ' + s(pa3.args)) +cb.append('pa4.args: ' + s(pa4.args)) +cb.append('sa.args: ' + s(sa.args)) +cb.append('psa1.args: ' + s(psa1.args)) +cb.append('psa2.args: ' + s(psa2.args)) +cb.append('psa3.args: ' + s(psa3.args)) +cb.append('psa4.args: ' + s(psa4.args)) + +cb.append('a.self: ' + s(a.self)) +cb.append('pa1.self: ' + s(pa1.self)) +cb.append('pa2.self: ' + s(pa2.self)) +cb.append('pa3.self: ' + s(pa3.self)) +cb.append('pa4.self: ' + s(pa4.self)) +cb.append('sa.self: ' + s(sa.self)) +cb.append('psa1.self: ' + s(psa1.self)) +cb.append('psa2.self: ' + s(psa2.self)) +cb.append('psa3.self: ' + s(psa3.self)) +cb.append('psa4.self: ' + s(psa4.self)) + +cb.append('a.name: ' + s(a.name)) +cb.append('pa1.name: ' + s(pa1.name)) +cb.append('pa2.name: ' + s(pa2.name)) +cb.append('pa3.name: ' + s(pa3.name)) +cb.append('pa4.name: ' + s(pa4.name)) +cb.append('sa.name: ' + s(sa.name)) +cb.append('psa1.name: ' + s(psa1.name)) +cb.append('psa2.name: ' + s(psa2.name)) +cb.append('psa3.name: ' + s(psa3.name)) +cb.append('psa4.name: ' + s(psa4.name)) + +del s + +del a +del pa1 +del pa2 +del pa3 +del pa4 +del sa +del psa1 +del psa2 +del psa3 +del psa4 +del psar + +del ecall +EOF :" :" Test stdout/stderr :redir => messages @@ -1140,7 +1317,7 @@ ee('vim.foreach_rtp(FailingCall())') ee('vim.foreach_rtp(int, 2)') cb.append('> import') old_rtp = vim.options['rtp'] -vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\') +vim.options['rtp'] = os.getcwd().replace('\\', '\\\\').replace(',', '\\,') ee('import xxx_no_such_module_xxx') ee('import failing_import') ee('import failing') @@ -1224,9 +1401,20 @@ ee('l.locked = FailingTrue()') ee('l.xxx = True') cb.append("> Function") cb.append(">> FunctionConstructor") +cb.append(">>> FunctionConstructor") ee('vim.Function("123")') ee('vim.Function("xxx_non_existent_function_xxx")') ee('vim.Function("xxx#non#existent#function#xxx")') +ee('vim.Function("xxx_non_existent_function_xxx2", args=[])') +ee('vim.Function("xxx_non_existent_function_xxx3", self={})') +ee('vim.Function("xxx_non_existent_function_xxx4", args=[], self={})') +cb.append(">>> FunctionNew") +ee('vim.Function("tr", self="abcFuncSelf")') +ee('vim.Function("tr", args=427423)') +ee('vim.Function("tr", self="abcFuncSelf2", args="abcFuncArgs2")') +ee('vim.Function(self="abcFuncSelf2", args="abcFuncArgs2")') +ee('vim.Function("tr", "", self="abcFuncSelf2", args="abcFuncArgs2")') +ee('vim.Function("tr", "")') cb.append(">> FunctionCall") convertfrompyobject_test('f(%s)') convertfrompymapping_test('fd(self=%s)') @@ -1381,7 +1569,7 @@ def test_keyboard_interrupt(): except KeyboardInterrupt: cb.append('Caught KeyboardInterrupt') except Exception: - cb.append('!!!!!!!! Caught exception: ' + repr(sys.exc_info)) + cb.append('!!!!!!!! Caught exception: ' + emsg(sys.exc_info())) else: cb.append('!!!!!!!! No exception') try: @@ -1389,7 +1577,7 @@ def test_keyboard_interrupt(): except KeyboardInterrupt: cb.append('!!!!!!!! Caught KeyboardInterrupt') except Exception: - cb.append('!!!!!!!! Caught exception: ' + repr(sys.exc_info)) + cb.append('!!!!!!!! Caught exception: ' + emsg(sys.exc_info())) else: cb.append('No exception') EOF @@ -1409,6 +1597,7 @@ EOF py << EOF del cb del ee +del emsg del sys del os del vim @@ -1441,7 +1630,7 @@ EOF :" :/^start:/,$wq! test.out :" vim: et ts=4 isk-=\: -:call getchar() +:while getchar(0) isnot 0|endwhile ENDTEST start: diff --git a/src/testdir/test86.ok b/src/testdir/test86.ok index d103909ca15d39..fe27c05a7b619a 100644 --- a/src/testdir/test86.ok +++ b/src/testdir/test86.ok @@ -57,6 +57,7 @@ None [0, 1, 2, 3, 4, 5, 6, 7] [0, 1, 2, 3, 4, 5, 6, 7] [0, 1, 2, 3, 4, 5, 6, 7] +l[2] threw vim.error: error:('list is locked',) [0, 1, 2, 3] [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd'] [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd', 'DictNewStart', 1, 2, 3, 'DictNewEnd', {'a': 'b'}] @@ -447,7 +448,7 @@ tabpage:__dir__,__members__,number,valid,vars,window,windows range:__dir__,__members__,append,end,start dictionary:__dir__,__members__,get,has_key,items,keys,locked,pop,popitem,scope,update,values list:__dir__,__members__,extend,locked -function:__dir__,__members__,softspace +function:__dir__,__members__,args,self,softspace output:__dir__,__members__,close,flush,isatty,readable,seekable,softspace,writable,write,writelines {} {'a': 1} @@ -455,12 +456,108 @@ output:__dir__,__members__,close,flush,isatty,readable,seekable,softspace,writab [] ['a', 'b', 'c', '7'] function('tr') +function('tr', [123, 3, 4]) +function('tr') +function('tr', {}) +function('tr', [123, 3, 4], {}) +a: +pa1: +pa2: +pa3: +pa4: +sa: +psa1: +psa2: +psa3: +psa4: +psar: +s(a): function('Args') +s(pa1): function('Args', ['abcArgsPA1']) +s(pa2): function('Args') +s(pa3): function('Args', ['abcArgsPA3'], {'abcSelfPA3': 'abcSelfPA3Val'}) +s(pa4): function('Args', {'abcSelfPA4': 'abcSelfPA4Val'}) +s(sa): function('SelfArgs') +s(psa1): function('SelfArgs', ['abcArgsPSA1']) +s(psa2): function('SelfArgs') +s(psa3): function('SelfArgs', ['abcArgsPSA3'], {'abcSelfPSA3': 'abcSelfPSA3Val'}) +s(psa4): function('SelfArgs', {'abcSelfPSA4': 'abcSelfPSA4Val'}) +a(): !result: [] +pa1(): !result: ['abcArgsPA1'] +pa2(): !result: [] +pa3(): !result: ['abcArgsPA3'] +pa4(): !result: [] +sa(): !exception: error:('Vim:E725: Calling dict function without Dictionary: SelfArgs',) +psa1(): !exception: error:('Vim:E725: Calling dict function without Dictionary: SelfArgs',) +psa2(): !exception: error:('Vim:E725: Calling dict function without Dictionary: SelfArgs',) +psa3(): !result: [['abcArgsPSA3'], {'abcSelfPSA3': 'abcSelfPSA3Val'}] +psa4(): !result: [[], {'abcSelfPSA4': 'abcSelfPSA4Val'}] +a(42, 43): !result: [42, 43] +pa1(42, 43): !result: ['abcArgsPA1', 42, 43] +pa2(42, 43): !result: [42, 43] +pa3(42, 43): !result: ['abcArgsPA3', 42, 43] +pa4(42, 43): !result: [42, 43] +sa(42, 43): !exception: error:('Vim:E725: Calling dict function without Dictionary: SelfArgs',) +psa1(42, 43): !exception: error:('Vim:E725: Calling dict function without Dictionary: SelfArgs',) +psa2(42, 43): !exception: error:('Vim:E725: Calling dict function without Dictionary: SelfArgs',) +psa3(42, 43): !result: [['abcArgsPSA3', 42, 43], {'abcSelfPSA3': 'abcSelfPSA3Val'}] +psa4(42, 43): !result: [[42, 43], {'abcSelfPSA4': 'abcSelfPSA4Val'}] +a(42, self={"20": 1}): !result: [42] +pa1(42, self={"20": 1}): !result: ['abcArgsPA1', 42] +pa2(42, self={"20": 1}): !result: [42] +pa3(42, self={"20": 1}): !result: ['abcArgsPA3', 42] +pa4(42, self={"20": 1}): !result: [42] +sa(42, self={"20": 1}): !result: [[42], {'20': 1}] +psa1(42, self={"20": 1}): !result: [['abcArgsPSA1', 42], {'20': 1}] +psa2(42, self={"20": 1}): !result: [[42], {'20': 1}] +psa3(42, self={"20": 1}): !result: [['abcArgsPSA3', 42], {'20': 1}] +psa4(42, self={"20": 1}): !result: [[42], {'20': 1}] +a(self={"20": 1}): !result: [] +pa1(self={"20": 1}): !result: ['abcArgsPA1'] +pa2(self={"20": 1}): !result: [] +pa3(self={"20": 1}): !result: ['abcArgsPA3'] +pa4(self={"20": 1}): !result: [] +sa(self={"20": 1}): !result: [[], {'20': 1}] +psa1(self={"20": 1}): !result: [['abcArgsPSA1'], {'20': 1}] +psa2(self={"20": 1}): !result: [[], {'20': 1}] +psa3(self={"20": 1}): !result: [['abcArgsPSA3'], {'20': 1}] +psa4(self={"20": 1}): !result: [[], {'20': 1}] +a.args: None +pa1.args: ['abcArgsPA1'] +pa2.args: None +pa3.args: ['abcArgsPA3'] +pa4.args: None +sa.args: None +psa1.args: ['abcArgsPSA1'] +psa2.args: None +psa3.args: ['abcArgsPSA3'] +psa4.args: None +a.self: None +pa1.self: None +pa2.self: None +pa3.self: {'abcSelfPA3': 'abcSelfPA3Val'} +pa4.self: {'abcSelfPA4': 'abcSelfPA4Val'} +sa.self: None +psa1.self: None +psa2.self: None +psa3.self: {'abcSelfPSA3': 'abcSelfPSA3Val'} +psa4.self: {'abcSelfPSA4': 'abcSelfPSA4Val'} +a.name: 'Args' +pa1.name: 'Args' +pa2.name: 'Args' +pa3.name: 'Args' +pa4.name: 'Args' +sa.name: 'SelfArgs' +psa1.name: 'SelfArgs' +psa2.name: 'SelfArgs' +psa3.name: 'SelfArgs' +psa4.name: 'SelfArgs' ' abcdef -line : +Error detected while processing function RunTest[]..Test: +line : abcdef abcA -line : +line : abcB' ['a', 'dup_a'] ['a', 'a'] @@ -1046,9 +1143,20 @@ l.locked = FailingTrue():NotImplementedError:('bool',) l.xxx = True:AttributeError:('cannot set attribute xxx',) > Function >> FunctionConstructor +>>> FunctionConstructor vim.Function("123"):ValueError:('unnamed function 123 does not exist',) vim.Function("xxx_non_existent_function_xxx"):ValueError:('function xxx_non_existent_function_xxx does not exist',) vim.Function("xxx#non#existent#function#xxx"):NOT FAILED +vim.Function("xxx_non_existent_function_xxx2", args=[]):ValueError:('function xxx_non_existent_function_xxx2 does not exist',) +vim.Function("xxx_non_existent_function_xxx3", self={}):ValueError:('function xxx_non_existent_function_xxx3 does not exist',) +vim.Function("xxx_non_existent_function_xxx4", args=[], self={}):ValueError:('function xxx_non_existent_function_xxx4 does not exist',) +>>> FunctionNew +vim.Function("tr", self="abcFuncSelf"):TypeError:('unable to convert str to vim dictionary',) +vim.Function("tr", args=427423):TypeError:('unable to convert int to vim list',) +vim.Function("tr", self="abcFuncSelf2", args="abcFuncArgs2"):TypeError:('unable to convert str to vim dictionary',) +vim.Function(self="abcFuncSelf2", args="abcFuncArgs2"):TypeError:('unable to convert str to vim dictionary',) +vim.Function("tr", "", self="abcFuncSelf2", args="abcFuncArgs2"):TypeError:('unable to convert str to vim dictionary',) +vim.Function("tr", ""):TypeError:('function takes exactly 1 argument (2 given)',) >> FunctionCall >>> Testing StringToChars using f({%s : 1}) f({1 : 1}):TypeError:('expected str() or unicode() instance, but got int',) diff --git a/src/testdir/test87.in b/src/testdir/test87.in index 535a1437827cc4..e3bc994ba1fd4e 100644 --- a/src/testdir/test87.in +++ b/src/testdir/test87.in @@ -7,6 +7,7 @@ STARTTEST :lang C :fun Test() :py3 import vim +:py3 cb = vim.current.buffer :let l = [] :py3 l=vim.bindeval('l') :py3 f=vim.bindeval('function("strlen")') @@ -200,7 +201,15 @@ EOF :let l = [0, 1, 2, 3] :py3 l=vim.bindeval('l') :lockvar! l -:py3 l[2]='i' +py3 << EOF +def emsg(ei): + return ei[0].__name__ + ':' + repr(ei[1].args) + +try: + l[2]='i' +except vim.error: + cb.append('l[2] threw vim.error: ' + emsg(sys.exc_info())) +EOF :$put =string(l) :unlockvar! l :" @@ -614,7 +623,6 @@ EOF : autocmd BufFilePre * python3 cb.append(vim.eval('expand("")') + ':BufFilePre:' + vim.eval('bufnr("%")')) :augroup END py3 << EOF -cb = vim.current.buffer # Tests BufferAppend and BufferItem cb.append(b[0]) # Tests BufferSlice and BufferAssSlice @@ -859,6 +867,175 @@ EOF :$put =string(py3eval('vim.List()')) :$put =string(py3eval('vim.List(iter(''abc7''))')) :$put =string(py3eval('vim.Function(''tr'')')) +:$put =string(py3eval('vim.Function(''tr'', args=[123, 3, 4])')) +:$put =string(py3eval('vim.Function(''tr'', args=[])')) +:$put =string(py3eval('vim.Function(''tr'', self={})')) +:$put =string(py3eval('vim.Function(''tr'', args=[123, 3, 4], self={})')) +:" +:" Test vim.Function +:function Args(...) +: return a:000 +:endfunction +:function SelfArgs(...) dict +: return [a:000, self] +:endfunction +:" The following four lines should not crash +:let Pt = function('tr', [[]], {'l': []}) +:py3 Pt = vim.bindeval('Pt') +:unlet Pt +:py3 del Pt +py3 << EOF +def ecall(out_prefix, func, *args, **kwargs): + line = out_prefix + ': ' + try: + ret = func(*args, **kwargs) + except Exception: + line += '!exception: ' + emsg(sys.exc_info()) + else: + line += '!result: ' + str(vim.Function('string')(ret), 'utf-8') + cb.append(line) +a = vim.Function('Args') +pa1 = vim.Function('Args', args=['abcArgsPA1']) +pa2 = vim.Function('Args', args=[]) +pa3 = vim.Function('Args', args=['abcArgsPA3'], self={'abcSelfPA3': 'abcSelfPA3Val'}) +pa4 = vim.Function('Args', self={'abcSelfPA4': 'abcSelfPA4Val'}) +cb.append('a: ' + repr(a)) +cb.append('pa1: ' + repr(pa1)) +cb.append('pa2: ' + repr(pa2)) +cb.append('pa3: ' + repr(pa3)) +cb.append('pa4: ' + repr(pa4)) +sa = vim.Function('SelfArgs') +psa1 = vim.Function('SelfArgs', args=['abcArgsPSA1']) +psa2 = vim.Function('SelfArgs', args=[]) +psa3 = vim.Function('SelfArgs', args=['abcArgsPSA3'], self={'abcSelfPSA3': 'abcSelfPSA3Val'}) +psa4 = vim.Function('SelfArgs', self={'abcSelfPSA4': 'abcSelfPSA4Val'}) +cb.append('sa: ' + repr(sa)) +cb.append('psa1: ' + repr(psa1)) +cb.append('psa2: ' + repr(psa2)) +cb.append('psa3: ' + repr(psa3)) +cb.append('psa4: ' + repr(psa4)) + +psar = vim.Function('SelfArgs', args=[{'abcArgsPSAr': 'abcArgsPSArVal'}], self={'abcSelfPSAr': 'abcSelfPSArVal'}) +psar.args[0]['abcArgsPSAr2'] = [psar.self, psar.args[0]] +psar.self['rec'] = psar +psar.self['self'] = psar.self +psar.self['args'] = psar.args + +try: + cb.append('psar: ' + repr(psar)) +except Exception: + cb.append('!!!!!!!! Caught exception: ' + emsg(sys.exc_info())) +EOF +:$put ='s(a): '.string(py3eval('a')) +:$put ='s(pa1): '.string(py3eval('pa1')) +:$put ='s(pa2): '.string(py3eval('pa2')) +:$put ='s(pa3): '.string(py3eval('pa3')) +:$put ='s(pa4): '.string(py3eval('pa4')) +:$put ='s(sa): '.string(py3eval('sa')) +:$put ='s(psa1): '.string(py3eval('psa1')) +:$put ='s(psa2): '.string(py3eval('psa2')) +:$put ='s(psa3): '.string(py3eval('psa3')) +:$put ='s(psa4): '.string(py3eval('psa4')) +: +:py3 ecall('a()', a, ) +:py3 ecall('pa1()', pa1, ) +:py3 ecall('pa2()', pa2, ) +:py3 ecall('pa3()', pa3, ) +:py3 ecall('pa4()', pa4, ) +:py3 ecall('sa()', sa, ) +:py3 ecall('psa1()', psa1, ) +:py3 ecall('psa2()', psa2, ) +:py3 ecall('psa3()', psa3, ) +:py3 ecall('psa4()', psa4, ) +: +:py3 ecall('a(42, 43)', a, 42, 43) +:py3 ecall('pa1(42, 43)', pa1, 42, 43) +:py3 ecall('pa2(42, 43)', pa2, 42, 43) +:py3 ecall('pa3(42, 43)', pa3, 42, 43) +:py3 ecall('pa4(42, 43)', pa4, 42, 43) +:py3 ecall('sa(42, 43)', sa, 42, 43) +:py3 ecall('psa1(42, 43)', psa1, 42, 43) +:py3 ecall('psa2(42, 43)', psa2, 42, 43) +:py3 ecall('psa3(42, 43)', psa3, 42, 43) +:py3 ecall('psa4(42, 43)', psa4, 42, 43) +: +:py3 ecall('a(42, self={"20": 1})', a, 42, self={'20': 1}) +:py3 ecall('pa1(42, self={"20": 1})', pa1, 42, self={'20': 1}) +:py3 ecall('pa2(42, self={"20": 1})', pa2, 42, self={'20': 1}) +:py3 ecall('pa3(42, self={"20": 1})', pa3, 42, self={'20': 1}) +:py3 ecall('pa4(42, self={"20": 1})', pa4, 42, self={'20': 1}) +:py3 ecall('sa(42, self={"20": 1})', sa, 42, self={'20': 1}) +:py3 ecall('psa1(42, self={"20": 1})', psa1, 42, self={'20': 1}) +:py3 ecall('psa2(42, self={"20": 1})', psa2, 42, self={'20': 1}) +:py3 ecall('psa3(42, self={"20": 1})', psa3, 42, self={'20': 1}) +:py3 ecall('psa4(42, self={"20": 1})', psa4, 42, self={'20': 1}) +: +:py3 ecall('a(self={"20": 1})', a, self={'20': 1}) +:py3 ecall('pa1(self={"20": 1})', pa1, self={'20': 1}) +:py3 ecall('pa2(self={"20": 1})', pa2, self={'20': 1}) +:py3 ecall('pa3(self={"20": 1})', pa3, self={'20': 1}) +:py3 ecall('pa4(self={"20": 1})', pa4, self={'20': 1}) +:py3 ecall('sa(self={"20": 1})', sa, self={'20': 1}) +:py3 ecall('psa1(self={"20": 1})', psa1, self={'20': 1}) +:py3 ecall('psa2(self={"20": 1})', psa2, self={'20': 1}) +:py3 ecall('psa3(self={"20": 1})', psa3, self={'20': 1}) +:py3 ecall('psa4(self={"20": 1})', psa4, self={'20': 1}) +py3 << EOF +def s(v): + if v is None: + return repr(v) + else: + return str(vim.Function('string')(v), 'utf-8') + +cb.append('a.args: ' + s(a.args)) +cb.append('pa1.args: ' + s(pa1.args)) +cb.append('pa2.args: ' + s(pa2.args)) +cb.append('pa3.args: ' + s(pa3.args)) +cb.append('pa4.args: ' + s(pa4.args)) +cb.append('sa.args: ' + s(sa.args)) +cb.append('psa1.args: ' + s(psa1.args)) +cb.append('psa2.args: ' + s(psa2.args)) +cb.append('psa3.args: ' + s(psa3.args)) +cb.append('psa4.args: ' + s(psa4.args)) + +cb.append('a.self: ' + s(a.self)) +cb.append('pa1.self: ' + s(pa1.self)) +cb.append('pa2.self: ' + s(pa2.self)) +cb.append('pa3.self: ' + s(pa3.self)) +cb.append('pa4.self: ' + s(pa4.self)) +cb.append('sa.self: ' + s(sa.self)) +cb.append('psa1.self: ' + s(psa1.self)) +cb.append('psa2.self: ' + s(psa2.self)) +cb.append('psa3.self: ' + s(psa3.self)) +cb.append('psa4.self: ' + s(psa4.self)) + +cb.append('a.name: ' + s(a.name)) +cb.append('pa1.name: ' + s(pa1.name)) +cb.append('pa2.name: ' + s(pa2.name)) +cb.append('pa3.name: ' + s(pa3.name)) +cb.append('pa4.name: ' + s(pa4.name)) +cb.append('sa.name: ' + s(sa.name)) +cb.append('psa1.name: ' + s(psa1.name)) +cb.append('psa2.name: ' + s(psa2.name)) +cb.append('psa3.name: ' + s(psa3.name)) +cb.append('psa4.name: ' + s(psa4.name)) + +del s + +del a +del pa1 +del pa2 +del pa3 +del pa4 +del sa +del psa1 +del psa2 +del psa3 +del psa4 +del psar + +del ecall +EOF :" :" Test stdout/stderr :redir => messages @@ -1134,7 +1311,7 @@ ee('vim.foreach_rtp(FailingCall())') ee('vim.foreach_rtp(int, 2)') cb.append('> import') old_rtp = vim.options['rtp'] -vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\') +vim.options['rtp'] = os.getcwd().replace('\\', '\\\\').replace(',', '\\,') ee('import xxx_no_such_module_xxx') ee('import failing_import') ee('import failing') @@ -1218,9 +1395,20 @@ ee('l.locked = FailingTrue()') ee('l.xxx = True') cb.append("> Function") cb.append(">> FunctionConstructor") +cb.append(">>> FunctionConstructor") ee('vim.Function("123")') ee('vim.Function("xxx_non_existent_function_xxx")') ee('vim.Function("xxx#non#existent#function#xxx")') +ee('vim.Function("xxx_non_existent_function_xxx2", args=[])') +ee('vim.Function("xxx_non_existent_function_xxx3", self={})') +ee('vim.Function("xxx_non_existent_function_xxx4", args=[], self={})') +cb.append(">>> FunctionNew") +ee('vim.Function("tr", self="abcFuncSelf")') +ee('vim.Function("tr", args=427423)') +ee('vim.Function("tr", self="abcFuncSelf2", args="abcFuncArgs2")') +ee('vim.Function(self="abcFuncSelf2", args="abcFuncArgs2")') +ee('vim.Function("tr", "", self="abcFuncSelf2", args="abcFuncArgs2")') +ee('vim.Function("tr", "")') cb.append(">> FunctionCall") convertfrompyobject_test('f(%s)') convertfrompymapping_test('fd(self=%s)') @@ -1374,16 +1562,16 @@ def test_keyboard_interrupt(): vim.command('while 1 | endwhile') except KeyboardInterrupt: cb.append('Caught KeyboardInterrupt') - except Exception as e: - cb.append('!!!!!!!! Caught exception: ' + repr(e)) + except Exception: + cb.append('!!!!!!!! Caught exception: ' + emsg(sys.exc_info())) else: cb.append('!!!!!!!! No exception') try: vim.command('$ put =\'Running :put\'') except KeyboardInterrupt: cb.append('!!!!!!!! Caught KeyboardInterrupt') - except Exception as e: - cb.append('!!!!!!!! Caught exception: ' + repr(e)) + except Exception: + cb.append('!!!!!!!! Caught exception: ' + emsg(sys.exc_info())) else: cb.append('No exception') EOF @@ -1403,6 +1591,7 @@ EOF py3 << EOF del cb del ee +del emsg del sys del os del vim @@ -1434,8 +1623,9 @@ EOF :call garbagecollect(1) :" :/^start:/,$wq! test.out +:/^start:/,$w! test.out :" vim: et ts=4 isk-=\: -:call getchar() +:while getchar(0) isnot 0|endwhile ENDTEST start: diff --git a/src/testdir/test87.ok b/src/testdir/test87.ok index 1d9b6e257840b3..25c0b510322b82 100644 --- a/src/testdir/test87.ok +++ b/src/testdir/test87.ok @@ -57,6 +57,7 @@ None [0, 1, 2, 3, 4, 5, 6, 7] [0, 1, 2, 3, 4, 5, 6, 7] [0, 1, 2, 3, 4, 5, 6, 7] +l[2] threw vim.error: error:('list is locked',) [0, 1, 2, 3] [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd'] [function('New'), function('DictNew'), 'NewStart', 1, 2, 3, 'NewEnd', 'DictNewStart', 1, 2, 3, 'DictNewEnd', {'a': 'b'}] @@ -447,7 +448,7 @@ tabpage:__dir__,number,valid,vars,window,windows range:__dir__,append,end,start dictionary:__dir__,get,has_key,items,keys,locked,pop,popitem,scope,update,values list:__dir__,extend,locked -function:__dir__,softspace +function:__dir__,args,self,softspace output:__dir__,close,flush,isatty,readable,seekable,softspace,writable,write,writelines {} {'a': 1} @@ -455,12 +456,108 @@ output:__dir__,close,flush,isatty,readable,seekable,softspace,writable,write,wri [] ['a', 'b', 'c', '7'] function('tr') +function('tr', [123, 3, 4]) +function('tr') +function('tr', {}) +function('tr', [123, 3, 4], {}) +a: +pa1: +pa2: +pa3: +pa4: +sa: +psa1: +psa2: +psa3: +psa4: +psar: +s(a): function('Args') +s(pa1): function('Args', ['abcArgsPA1']) +s(pa2): function('Args') +s(pa3): function('Args', ['abcArgsPA3'], {'abcSelfPA3': 'abcSelfPA3Val'}) +s(pa4): function('Args', {'abcSelfPA4': 'abcSelfPA4Val'}) +s(sa): function('SelfArgs') +s(psa1): function('SelfArgs', ['abcArgsPSA1']) +s(psa2): function('SelfArgs') +s(psa3): function('SelfArgs', ['abcArgsPSA3'], {'abcSelfPSA3': 'abcSelfPSA3Val'}) +s(psa4): function('SelfArgs', {'abcSelfPSA4': 'abcSelfPSA4Val'}) +a(): !result: [] +pa1(): !result: ['abcArgsPA1'] +pa2(): !result: [] +pa3(): !result: ['abcArgsPA3'] +pa4(): !result: [] +sa(): !exception: error:('Vim:E725: Calling dict function without Dictionary: SelfArgs',) +psa1(): !exception: error:('Vim:E725: Calling dict function without Dictionary: SelfArgs',) +psa2(): !exception: error:('Vim:E725: Calling dict function without Dictionary: SelfArgs',) +psa3(): !result: [['abcArgsPSA3'], {'abcSelfPSA3': 'abcSelfPSA3Val'}] +psa4(): !result: [[], {'abcSelfPSA4': 'abcSelfPSA4Val'}] +a(42, 43): !result: [42, 43] +pa1(42, 43): !result: ['abcArgsPA1', 42, 43] +pa2(42, 43): !result: [42, 43] +pa3(42, 43): !result: ['abcArgsPA3', 42, 43] +pa4(42, 43): !result: [42, 43] +sa(42, 43): !exception: error:('Vim:E725: Calling dict function without Dictionary: SelfArgs',) +psa1(42, 43): !exception: error:('Vim:E725: Calling dict function without Dictionary: SelfArgs',) +psa2(42, 43): !exception: error:('Vim:E725: Calling dict function without Dictionary: SelfArgs',) +psa3(42, 43): !result: [['abcArgsPSA3', 42, 43], {'abcSelfPSA3': 'abcSelfPSA3Val'}] +psa4(42, 43): !result: [[42, 43], {'abcSelfPSA4': 'abcSelfPSA4Val'}] +a(42, self={"20": 1}): !result: [42] +pa1(42, self={"20": 1}): !result: ['abcArgsPA1', 42] +pa2(42, self={"20": 1}): !result: [42] +pa3(42, self={"20": 1}): !result: ['abcArgsPA3', 42] +pa4(42, self={"20": 1}): !result: [42] +sa(42, self={"20": 1}): !result: [[42], {'20': 1}] +psa1(42, self={"20": 1}): !result: [['abcArgsPSA1', 42], {'20': 1}] +psa2(42, self={"20": 1}): !result: [[42], {'20': 1}] +psa3(42, self={"20": 1}): !result: [['abcArgsPSA3', 42], {'20': 1}] +psa4(42, self={"20": 1}): !result: [[42], {'20': 1}] +a(self={"20": 1}): !result: [] +pa1(self={"20": 1}): !result: ['abcArgsPA1'] +pa2(self={"20": 1}): !result: [] +pa3(self={"20": 1}): !result: ['abcArgsPA3'] +pa4(self={"20": 1}): !result: [] +sa(self={"20": 1}): !result: [[], {'20': 1}] +psa1(self={"20": 1}): !result: [['abcArgsPSA1'], {'20': 1}] +psa2(self={"20": 1}): !result: [[], {'20': 1}] +psa3(self={"20": 1}): !result: [['abcArgsPSA3'], {'20': 1}] +psa4(self={"20": 1}): !result: [[], {'20': 1}] +a.args: None +pa1.args: ['abcArgsPA1'] +pa2.args: None +pa3.args: ['abcArgsPA3'] +pa4.args: None +sa.args: None +psa1.args: ['abcArgsPSA1'] +psa2.args: None +psa3.args: ['abcArgsPSA3'] +psa4.args: None +a.self: None +pa1.self: None +pa2.self: None +pa3.self: {'abcSelfPA3': 'abcSelfPA3Val'} +pa4.self: {'abcSelfPA4': 'abcSelfPA4Val'} +sa.self: None +psa1.self: None +psa2.self: None +psa3.self: {'abcSelfPSA3': 'abcSelfPSA3Val'} +psa4.self: {'abcSelfPSA4': 'abcSelfPSA4Val'} +a.name: 'Args' +pa1.name: 'Args' +pa2.name: 'Args' +pa3.name: 'Args' +pa4.name: 'Args' +sa.name: 'SelfArgs' +psa1.name: 'SelfArgs' +psa2.name: 'SelfArgs' +psa3.name: 'SelfArgs' +psa4.name: 'SelfArgs' ' abcdef -line : +Error detected while processing function RunTest[]..Test: +line : abcdef abcA -line : +line : abcB' ['a', 'dup_a'] ['a', 'a'] @@ -1046,9 +1143,20 @@ l.locked = FailingTrue():(, NotImplementedError('bo l.xxx = True:(, AttributeError('cannot set attribute xxx',)) > Function >> FunctionConstructor +>>> FunctionConstructor vim.Function("123"):(, ValueError('unnamed function 123 does not exist',)) vim.Function("xxx_non_existent_function_xxx"):(, ValueError('function xxx_non_existent_function_xxx does not exist',)) vim.Function("xxx#non#existent#function#xxx"):NOT FAILED +vim.Function("xxx_non_existent_function_xxx2", args=[]):(, ValueError('function xxx_non_existent_function_xxx2 does not exist',)) +vim.Function("xxx_non_existent_function_xxx3", self={}):(, ValueError('function xxx_non_existent_function_xxx3 does not exist',)) +vim.Function("xxx_non_existent_function_xxx4", args=[], self={}):(, ValueError('function xxx_non_existent_function_xxx4 does not exist',)) +>>> FunctionNew +vim.Function("tr", self="abcFuncSelf"):(, AttributeError('keys',)) +vim.Function("tr", args=427423):(, TypeError('unable to convert int to vim list',)) +vim.Function("tr", self="abcFuncSelf2", args="abcFuncArgs2"):(, AttributeError('keys',)) +vim.Function(self="abcFuncSelf2", args="abcFuncArgs2"):(, AttributeError('keys',)) +vim.Function("tr", "", self="abcFuncSelf2", args="abcFuncArgs2"):(, AttributeError('keys',)) +vim.Function("tr", ""):(, TypeError('function takes exactly 1 argument (2 given)',)) >> FunctionCall >>> Testing StringToChars using f({%s : 1}) f({1 : 1}):(, TypeError('expected bytes() or str() instance, but got int',)) diff --git a/src/version.c b/src/version.c index 7132e0b07200d4..04545d9695f15e 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1731, /**/ 1730, /**/ From 429fcfbf9a9275367fe9441a50a3dcd773497d84 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 14 Apr 2016 16:22:04 +0200 Subject: [PATCH 12/29] patch 7.4.1732 Problem: Folds may close when using autocomplete. (Anmol Sethi) Solution: Increment/decrement disable_fold. (Christian Brabandt, closes #643) --- src/edit.c | 2 ++ src/fold.c | 3 +++ src/globals.h | 4 ++++ src/version.c | 2 ++ 4 files changed, 11 insertions(+) diff --git a/src/edit.c b/src/edit.c index abe26fbb64b89e..f4a835485cb4df 100644 --- a/src/edit.c +++ b/src/edit.c @@ -1424,8 +1424,10 @@ edit( docomplete: compl_busy = TRUE; + disable_fold_update++; /* don't redraw folds here */ if (ins_complete(c, TRUE) == FAIL) compl_cont_status = 0; + disable_fold_update--; compl_busy = FALSE; break; #endif /* FEAT_INS_EXPAND */ diff --git a/src/fold.c b/src/fold.c index e0b2609d981303..8b9ca35ebf174f 100644 --- a/src/fold.c +++ b/src/fold.c @@ -811,6 +811,9 @@ foldUpdate(win_T *wp, linenr_T top, linenr_T bot) { fold_T *fp; + if (disable_fold_update > 0) + return; + /* Mark all folds from top to bot as maybe-small. */ (void)foldFind(&wp->w_folds, top, &fp); while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len diff --git a/src/globals.h b/src/globals.h index 3278ad977568d0..5effdb563034ca 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1176,6 +1176,10 @@ EXTERN int fill_fold INIT(= '-'); EXTERN int fill_diff INIT(= '-'); #endif +#ifdef FEAT_FOLDING +EXTERN int disable_fold_update INIT(= 0); +#endif + /* Whether 'keymodel' contains "stopsel" and "startsel". */ EXTERN int km_stopsel INIT(= FALSE); EXTERN int km_startsel INIT(= FALSE); diff --git a/src/version.c b/src/version.c index 04545d9695f15e..f1dbb6168a8510 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1732, /**/ 1731, /**/ From 839e954aaa72ef62f65416d177f829e681c15466 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 14 Apr 2016 16:46:02 +0200 Subject: [PATCH 13/29] patch 7.4.1733 Problem: "make install" doesn't know about cross-compiling. (Christian Neukirchen) Solution: Add CROSS_COMPILING. (closes #740) --- src/Makefile | 19 +++++++++++++++---- src/auto/configure | 4 ++++ src/config.mk.in | 1 + src/configure.in | 3 +++ src/version.c | 2 ++ 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/Makefile b/src/Makefile index cf9636d526e414..195cbd5c64d541 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1998,23 +1998,25 @@ test1 \ test70 test71 test72 test73 test74 test75 test76 test77 test78 test79 \ test80 test81 test82 test83 test84 test85 test86 test87 test88 test89 \ test90 test91 test92 test93 test94 test95 test97 test98 test99 \ - test100 test101 test102 test103 test104 test105 test107 test108: + test100 test101 test102 test103 test104 test107 test108: cd testdir; rm -f $@.out; $(MAKE) -f Makefile $@.out VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE) # Run individual NEW style test, assuming that Vim was already compiled. test_arglist \ test_assert \ test_assign \ + test_autocmd \ test_backspace_opt \ test_cdo \ test_channel \ test_cursor_func \ test_delete \ test_ex_undo \ - test_expr \ test_expand \ + test_expr \ test_feedkeys \ test_file_perm \ + test_fnamemodify \ test_glob2regpat \ test_hardcopy \ test_help_tagjump \ @@ -2024,17 +2026,22 @@ test_arglist \ test_json \ test_langmap \ test_lispwords \ + test_matchstrpos \ test_menu \ test_packadd \ test_partial \ test_perl \ test_quickfix \ + test_regexp_latin \ + test_regexp_utf8 \ test_reltime \ test_searchpos \ test_set \ test_sort \ + test_statusline \ test_syn_attr \ test_syntax \ + test_tabline \ test_timers \ test_undolevels \ test_unlet \ @@ -2042,6 +2049,8 @@ test_arglist \ test_viml \ test_visual \ test_window_id \ + test_alot_latin \ + test_alot_utf8 \ test_alot: cd testdir; rm -f $@.res test.log messages; $(MAKE) -f Makefile $@.res VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE) @if test -f testdir/test.log; then \ @@ -2126,9 +2135,11 @@ installrtbase: $(HELPSOURCE)/vim.1 $(DEST_VIM) $(DEST_RT) \ # Generate the help tags with ":helptags" to handle all languages. # Move the distributed tags file aside and restore it, to avoid it being # different from the repository. - cd $(HELPSOURCE); if test -f tags; then mv -f tags tags.dist; fi + cd $(HELPSOURCE); if test -z "$(CROSS_COMPILING)" -a -f tags; then \ + mv -f tags tags.dist; fi @echo generating help tags - -@cd $(HELPSOURCE); $(MAKE) VIMEXE=$(DEST_BIN)/$(VIMTARGET) vimtags + -@cd $(HELPSOURCE); if test -z "$(CROSS_COMPILING)"; then \ + $(MAKE) VIMEXE=$(DEST_BIN)/$(VIMTARGET) vimtags; fi cd $(HELPSOURCE); \ files=`ls *.txt tags`; \ files="$$files `ls *.??x tags-?? 2>/dev/null || true`"; \ diff --git a/src/auto/configure b/src/auto/configure index a7082300bda41b..91b075d95a8d08 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -721,6 +721,7 @@ OS_EXTRA_OBJ OS_EXTRA_SRC XCODE_SELECT CPP_MM +CROSS_COMPILING STRIP AWK FGREP @@ -4113,11 +4114,14 @@ else $as_echo "no" >&6; } fi +CROSS_COMPILING= if test "$cross_compiling" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: cannot compile a simple program; if not cross compiling check CC and CFLAGS" >&5 $as_echo "cannot compile a simple program; if not cross compiling check CC and CFLAGS" >&6; } + CROSS_COMPILING=1 fi + test "$GCC" = yes && CPP_MM=M; if test -f ./toolcheck; then diff --git a/src/config.mk.in b/src/config.mk.in index 7c0726c296ffe6..1002d7c7c33061 100644 --- a/src/config.mk.in +++ b/src/config.mk.in @@ -104,6 +104,7 @@ AWK = @AWK@ STRIP = @STRIP@ EXEEXT = @EXEEXT@ +CROSS_COMPILING = @CROSS_COMPILING@ COMPILEDBY = @compiledby@ diff --git a/src/configure.in b/src/configure.in index f29b62c1f9b8b7..0a8c95bc6eb4c0 100644 --- a/src/configure.in +++ b/src/configure.in @@ -88,9 +88,12 @@ fi dnl If configure thinks we are cross compiling, there might be something dnl wrong with the CC or CFLAGS settings, give a useful warning message +CROSS_COMPILING= if test "$cross_compiling" = yes; then AC_MSG_RESULT([cannot compile a simple program; if not cross compiling check CC and CFLAGS]) + CROSS_COMPILING=1 fi +AC_SUBST(CROSS_COMPILING) dnl gcc-cpp has the wonderful -MM option to produce nicer dependencies. dnl But gcc 3.1 changed the meaning! See near the end. diff --git a/src/version.c b/src/version.c index f1dbb6168a8510..873f21c2bcbc11 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1733, /**/ 1732, /**/ From 0f518a8f4d4be4cac10389680f6bd5e3781f94b0 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 14 Apr 2016 16:57:10 +0200 Subject: [PATCH 14/29] patch 7.4.1734 Problem: Test fails when not using utf-8. Solution: Split test in regularand utf-8 part. --- src/testdir/test_alot_utf8.vim | 1 + src/testdir/test_expr.vim | 23 ----------------------- src/testdir/test_expr_utf8.vim | 26 ++++++++++++++++++++++++++ src/version.c | 2 ++ 4 files changed, 29 insertions(+), 23 deletions(-) create mode 100644 src/testdir/test_expr_utf8.vim diff --git a/src/testdir/test_alot_utf8.vim b/src/testdir/test_alot_utf8.vim index 20d919c323da1c..e55555e6e4c99c 100644 --- a/src/testdir/test_alot_utf8.vim +++ b/src/testdir/test_alot_utf8.vim @@ -4,4 +4,5 @@ " These tests use utf8 'encoding'. Setting 'encoding' is in the individual " files, so that they can be run by themselves. +source test_expr_utf8.vim source test_regexp_utf8.vim diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim index cdaf45ee734422..c8c8e2c2a4c8b7 100644 --- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -59,17 +59,6 @@ func Test_strgetchar() call assert_equal(-1, strgetchar('axb', -1)) call assert_equal(-1, strgetchar('axb', 3)) call assert_equal(-1, strgetchar('', 0)) - - if !has('multi_byte') - return - endif - - call assert_equal(char2nr('á'), strgetchar('áxb', 0)) - call assert_equal(char2nr('x'), strgetchar('áxb', 1)) - - call assert_equal(char2nr('a'), strgetchar('àxb', 0)) - call assert_equal(char2nr('̀'), strgetchar('àxb', 1)) - call assert_equal(char2nr('x'), strgetchar('àxb', 2)) endfunc func Test_strcharpart() @@ -84,16 +73,4 @@ func Test_strcharpart() call assert_equal('', strcharpart('axb', -2, 2)) call assert_equal('a', strcharpart('axb', -1, 2)) - - if !has('multi_byte') - return - endif - - call assert_equal('áxb', strcharpart('áxb', 0)) - call assert_equal('á', strcharpart('áxb', 0, 1)) - call assert_equal('x', strcharpart('áxb', 1, 1)) - - call assert_equal('a', strcharpart('àxb', 0, 1)) - call assert_equal('̀', strcharpart('àxb', 1, 1)) - call assert_equal('x', strcharpart('àxb', 2, 1)) endfunc diff --git a/src/testdir/test_expr_utf8.vim b/src/testdir/test_expr_utf8.vim new file mode 100644 index 00000000000000..8b10e63001aa79 --- /dev/null +++ b/src/testdir/test_expr_utf8.vim @@ -0,0 +1,26 @@ +" Tests for expressions using utf-8. +if !has('multi_byte') + finish +endif +set encoding=utf-8 +scriptencoding utf-8 + +func Test_strgetchar() + call assert_equal(char2nr('a'), strgetchar('axb', 0)) + call assert_equal(char2nr('x'), strgetchar('axb', 1)) + call assert_equal(char2nr('b'), strgetchar('axb', 2)) + + call assert_equal(-1, strgetchar('axb', -1)) + call assert_equal(-1, strgetchar('axb', 3)) + call assert_equal(-1, strgetchar('', 0)) +endfunc + +func Test_strcharpart() + call assert_equal('áxb', strcharpart('áxb', 0)) + call assert_equal('á', strcharpart('áxb', 0, 1)) + call assert_equal('x', strcharpart('áxb', 1, 1)) + + call assert_equal('a', strcharpart('àxb', 0, 1)) + call assert_equal('̀', strcharpart('àxb', 1, 1)) + call assert_equal('x', strcharpart('àxb', 2, 1)) +endfunc diff --git a/src/version.c b/src/version.c index 873f21c2bcbc11..a013661c5ad4dd 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1734, /**/ 1733, /**/ From 0f97b79d6b1b2b4cfd4071f20f6bd8a7af30a374 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Sun, 10 Apr 2016 01:50:43 +0900 Subject: [PATCH 15/29] add test for 'conceal' feature of matchadd() --- src/testdir/test_alot.vim | 1 + src/testdir/test_matchadd_conceal.vim | 36 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/testdir/test_matchadd_conceal.vim diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim index 7f9a1a78fed8db..1b44286adc6b06 100644 --- a/src/testdir/test_alot.vim +++ b/src/testdir/test_alot.vim @@ -16,6 +16,7 @@ source test_help_tagjump.vim source test_join.vim source test_lispwords.vim source test_matchstrpos.vim +source test_matchadd_conceal.vim source test_menu.vim source test_partial.vim source test_reltime.vim diff --git a/src/testdir/test_matchadd_conceal.vim b/src/testdir/test_matchadd_conceal.vim new file mode 100644 index 00000000000000..3a4b96fae9436d --- /dev/null +++ b/src/testdir/test_matchadd_conceal.vim @@ -0,0 +1,36 @@ +function! s:screenline(lnum) abort + let line = [] + for c in range(1, winwidth(0)) + call add(line, nr2char(screenchar(a:lnum, c))) + endfor + return s:trim(join(line, '')) +endfunction + +function! s:trim(str) abort + return matchstr(a:str,'^\s*\zs.\{-}\ze\s*$') +endfunction + +function! Test_matchadd_conceal() + if !has('conceal') + return + endif + + " quit! all other windows + silent! only! + new + + " To test targets in the same line string is replaced with conceal char + " correctly, repeat 'TARGET' + 1put ='TARGET_TARGETTARGET' + call cursor(1, 1) + redraw + call assert_equal('TARGET_TARGETTARGET', s:screenline(2)) + + setlocal conceallevel=2 + call matchadd('Conceal', 'TARGET', 10, -1, {'conceal': 't'}) + + redraw + call assert_equal('t_tt', s:screenline(2)) + + quit! +endfunction From 6de0b1c31380b285dbda2cf49509b70fabaec5e8 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Sun, 10 Apr 2016 02:23:36 +0900 Subject: [PATCH 16/29] Fix 'conceal' by matchadd() when :syn off To be precise, when there are no text which matches syntax definition in current buffer. --- src/screen.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/screen.c b/src/screen.c index 8044079b52ec90..82fc18b0e14552 100644 --- a/src/screen.c +++ b/src/screen.c @@ -4910,7 +4910,18 @@ win_line( && vim_strchr(wp->w_p_cocu, 'v') == NULL)) { char_attr = conceal_attr; - if (prev_syntax_id != syntax_seqnr + /* PROBLEM: When trying to show cchar by matchadd(), + * prev_syntax_id and syntax_seqnr might be 0 with :syntax off. + * When trying to show cchar by :syntax match, it's no problem because + * syntax_seqnr is not 0. + * To support showing cchar by matchadd(), change syntax_seqnr + * value to non-zero. + * XXX: better solution? + **/ + if (has_match_conc && syntax_seqnr == 0) + syntax_seqnr = -1; + + if ((prev_syntax_id != syntax_seqnr) && (syn_get_sub_char() != NUL || match_conc || wp->w_p_cole == 1) && wp->w_p_cole != 3) From a25f91f0f2e794bfb4ff7d12ed84be562ce14e4b Mon Sep 17 00:00:00 2001 From: haya14busa Date: Sun, 10 Apr 2016 16:25:55 +0900 Subject: [PATCH 17/29] finish conceal test at the head of file --- src/testdir/test_matchadd_conceal.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/testdir/test_matchadd_conceal.vim b/src/testdir/test_matchadd_conceal.vim index 3a4b96fae9436d..334f3d442a1b5d 100644 --- a/src/testdir/test_matchadd_conceal.vim +++ b/src/testdir/test_matchadd_conceal.vim @@ -1,3 +1,7 @@ +if !has('conceal') + finish +endif + function! s:screenline(lnum) abort let line = [] for c in range(1, winwidth(0)) @@ -11,10 +15,6 @@ function! s:trim(str) abort endfunction function! Test_matchadd_conceal() - if !has('conceal') - return - endif - " quit! all other windows silent! only! new From 8d4165993a930cf76fc303a78d7c0a419ac18fe5 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Sun, 10 Apr 2016 18:46:29 +0900 Subject: [PATCH 18/29] Convert test_match_conceal.in to new style test --- src/Makefile | 1 - src/testdir/Make_all.mak | 1 - src/testdir/test_match_conceal.in | 159 ---------------- src/testdir/test_matchadd_conceal.vim | 259 +++++++++++++++++++++++++- src/testdir/test_undolevels.vim | 3 + 5 files changed, 259 insertions(+), 164 deletions(-) delete mode 100644 src/testdir/test_match_conceal.in diff --git a/src/Makefile b/src/Makefile index 195cbd5c64d541..1543bda9de7618 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1977,7 +1977,6 @@ test1 \ test_listlbr_utf8 \ test_mapping \ test_marks \ - test_match_conceal \ test_nested_function \ test_options \ test_ruby \ diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak index 2540abfbf0a28a..1dca6abac36ea3 100644 --- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -104,7 +104,6 @@ SCRIPTS_ALL = \ test_listlbr.out \ test_mapping.out \ test_marks.out \ - test_match_conceal.out \ test_nested_function.out \ test_options.out \ test_ruby.out \ diff --git a/src/testdir/test_match_conceal.in b/src/testdir/test_match_conceal.in deleted file mode 100644 index aa32b8582bbf37..00000000000000 --- a/src/testdir/test_match_conceal.in +++ /dev/null @@ -1,159 +0,0 @@ -Test for matchadd() and conceal feature - -STARTTEST -:so small.vim -:if !has("conceal") | e! test.ok | w! test.out | qa! | endif -:set term=ansi -:so mbyte.vim -:if &enc !=? 'utf-8'|:e! test.ok|:w! test.out|qa!|endif -:10new|:vsp|:vert resize 20 -:put =\"\#\ This\ is\ a\ Test\" -:norm! mazt -:fu! ScreenChar(width, lines) -: let c='' -: for j in range(1,a:lines) -: for i in range(1,a:width) -: let c.=nr2char(screenchar(j, i)) -: endfor -: let c.="\n" -: endfor -: return c -:endfu -:fu! ScreenAttr(line, pos, eval) -: let g:attr=[] -: for col in a:pos -: call add(g:attr, screenattr(a:line,col)) -: endfor -: " In case all values are zero, probably the terminal -: " isn't set correctly, so catch that case -: let null = (eval(join(g:attr, '+')) == 0) -: let str=substitute(a:eval, '\d\+', 'g:attr[&]', 'g') -: if null || eval(str) -: :let g:attr_test="OK: ". str -: else -: :let g:attr_test="FAILED: ".str -: :let g:attr_test.="\n". join(g:attr, ' ') -: :let g:attr_test.="\n TERM: ". &term -: endif -:endfu -:fu! DoRecordScreen() -: wincmd l -: $put =printf(\"\n%s\", g:test) -: $put =g:line -: $put =g:attr_test -: wincmd p -:endfu -:let g:test ="Test 1: simple addmatch()" -:call matchadd('Conceal', '\%2l ') -:redraw! -:let line=ScreenChar(winwidth(0),1) -:call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5") -:call DoRecordScreen() -: -:let g:test ="Test 2: simple addmatch() and conceal (should be: #XThisXisXaXTest)" -:norm! 'azt -:call clearmatches() -:syntax on -:set concealcursor=n conceallevel=1 -:call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'X'}) -:redraw! -:let line=ScreenChar(winwidth(0),1) -:call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5") -:call DoRecordScreen() -: -:let g:test ="Test 3: addmatch() and conceallevel=3 (should be: #ThisisaTest)" -:norm! 'azt -:set conceallevel=3 -:call clearmatches() -:call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'X'}) -:redraw! -:let line=ScreenChar(winwidth(0),1) -:call ScreenAttr(1,[1,2,7,10,12,16], "0==1 && 1==2 && 1==3 && 1==4 && 0!=5") -:call DoRecordScreen() -: -:let g:test ="Test 4: more match() (should be: #Thisisa Test)" -:norm! 'azt -:call matchadd('ErrorMsg', '\%2l Test', 20, -1, {'conceal': 'X'}) -:redraw! -:let line=ScreenChar(winwidth(0),1) -:call ScreenAttr(1,[1,2,7,10,12,16], "0==1 && 1==2 && 0!=3 && 3==4 && 0!=5 && 3!=5") -:call DoRecordScreen() -: -:let g:test ="Test 5/1: default conceal char (should be: # This is a Test)" -:norm! 'azt -:call clearmatches() -:set conceallevel=1 -:call matchadd('Conceal', '\%2l ', 10, -1, {}) -:redraw! -:let line=ScreenChar(winwidth(0),1) -:call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5") -:call DoRecordScreen() -:let g:test ="Test 5/2: default conceal char (should be: #+This+is+a+Test)" -:norm! 'azt -:set listchars=conceal:+ -:let line=ScreenChar(winwidth(0),1) -:call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5") -:call DoRecordScreen() -:set listchars&vim -: -:let g:test ="Test 6/1: syn and match conceal (should be: #ZThisZisZaZTest)" -:norm! 'azt -:call clearmatches() -:set conceallevel=1 -:call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'Z'}) -:syn match MyConceal /\%2l / conceal containedin=ALL cchar=* -:redraw! -:let line=ScreenChar(winwidth(0),1) -:call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5") -:call DoRecordScreen() -:let g:test ="Test 6/2: syn and match conceal (should be: #*This*is*a*Test)" -:norm! 'azt -:call clearmatches() -:let line=ScreenChar(winwidth(0),1) -:call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5") -:call DoRecordScreen() -: -:let g:test ="Test 7/1: clear matches" -:norm! 'azt -:syn on -:call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'Z'}) -:let a=getmatches() -:call clearmatches() -:redraw! -:let line=ScreenChar(winwidth(0),1) -:call ScreenAttr(1,[1,2,7,10,12,16], "0==1 && 0==2 && 0==3 && 0==4 && 0==5") -:call DoRecordScreen() -:$put =a -:call setmatches(a) -:norm! 'azt -:let g:test ="Test 7/2: reset match using setmatches()" -:norm! 'azt -:let line=ScreenChar(winwidth(0),1) -:call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5") -:call DoRecordScreen() -: -:let g:test ="Test 8: using matchaddpos() (should be #Pis a Test" -:norm! 'azt -:call clearmatches() -:call matchaddpos('Conceal', [[2,2,6]], 10, -1, {'conceal': 'P'}) -:let a=getmatches() -:redraw! -:let line=ScreenChar(winwidth(0),1) -:call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1!=2 && 0==2 && 0==3 && 0!=4 && 0!=5 && 4==5") -:call DoRecordScreen() -:$put =a -: -:let g:test ="Test 9: match using multibyte conceal char (should be: #ˑThisˑisˑaˑTest)" -:norm! 'azt -:call clearmatches() -:call matchadd('Conceal', '\%2l ', 20, -1, {'conceal': "\u02d1"}) -:redraw! -:let line=ScreenChar(winwidth(0),1) -:call ScreenAttr(1,[1,2,7,10,12,16], "0!=1 && 1==2 && 1==3 && 1==4 && 0==5") -:call DoRecordScreen() -: -:"sleep 10 -:%w! test.out -:qa! -ENDTEST -dummy text diff --git a/src/testdir/test_matchadd_conceal.vim b/src/testdir/test_matchadd_conceal.vim index 334f3d442a1b5d..477d86cba66aba 100644 --- a/src/testdir/test_matchadd_conceal.vim +++ b/src/testdir/test_matchadd_conceal.vim @@ -1,3 +1,4 @@ +" Test for matchadd() and conceal feature if !has('conceal') finish endif @@ -14,9 +15,261 @@ function! s:trim(str) abort return matchstr(a:str,'^\s*\zs.\{-}\ze\s*$') endfunction -function! Test_matchadd_conceal() - " quit! all other windows - silent! only! +function! Test_simple_matchadd() + new + + 1put='# This is a Test' + " 1234567890123456 + let expect = '# This is a Test' + + call cursor(1, 1) + call matchadd('Conceal', '\%2l ') + redraw! + let lnum = 2 + call assert_equal(expect, s:screenline(lnum)) + call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 2)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) + call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 16)) + + quit! +endfunction + +function! Test_simple_matchadd_and_conceal() + new + setlocal concealcursor=n conceallevel=1 + + 1put='# This is a Test' + " 1234567890123456 + let expect = '#XThisXisXaXTest' + + call cursor(1, 1) + call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'X'}) + redraw! + let lnum = 2 + call assert_equal(expect, s:screenline(lnum)) + call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 2)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) + call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 16)) + + quit! +endfunction + +function! Test_matchadd_and_conceallevel_3() + new + + setlocal conceallevel=3 + " set filetype and :syntax on to change screenattr() + setlocal filetype=conf + syntax on + + 1put='# This is a Test' + " 1234567890123456 + let expect = '#ThisisaTest' + + call cursor(1, 1) + call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'X'}) + redraw! + let lnum = 2 + call assert_equal(expect, s:screenline(lnum)) + call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 2)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) + call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 16)) + + " more matchadd() + " 1234567890123456 + let expect = '#Thisisa Test' + + call matchadd('ErrorMsg', '\%2l Test', 20, -1, {'conceal': 'X'}) + redraw! + call assert_equal(expect, s:screenline(lnum)) + call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 2)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) + call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 10)) + call assert_true(screenattr(lnum, 10) ==# screenattr(lnum, 12)) + call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 16)) + call assert_true(screenattr(lnum, 10) !=# screenattr(lnum, 16)) + + syntax off + quit! +endfunction + +function! Test_default_conceal_char() + new + setlocal concealcursor=n conceallevel=1 + + 1put='# This is a Test' + " 1234567890123456 + let expect = '# This is a Test' + + call cursor(1, 1) + call matchadd('Conceal', '\%2l ', 10, -1, {}) + redraw! + let lnum = 2 + call assert_equal(expect, s:screenline(lnum)) + call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 2)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) + call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 16)) + + " 1234567890123456 + let expect = '#+This+is+a+Test' + let listchars_save = &listchars + set listchars=conceal:+ + redraw! + + call assert_equal(expect, s:screenline(lnum)) + call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 2)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) + call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 16)) + + let &listchars = listchars_save + quit! +endfunction + +function! Test_syn_and_match_conceal() + new + setlocal concealcursor=n conceallevel=1 + + 1put='# This is a Test' + " 1234567890123456 + let expect = '#ZThisZisZaZTest' + + call cursor(1, 1) + call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'Z'}) + syntax match MyConceal /\%2l / conceal containedin=ALL cchar=* + redraw! + let lnum = 2 + call assert_equal(expect, s:screenline(lnum)) + call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 2)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) + call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 16)) + + " 1234567890123456 + let expect = '#*This*is*a*Test' + call clearmatches() + redraw! + + call assert_equal(expect, s:screenline(lnum)) + call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 2)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) + call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 16)) + + syntax off + quit! +endfunction + +function! Test_clearmatches() + new + setlocal concealcursor=n conceallevel=1 + + 1put='# This is a Test' + " 1234567890123456 + let expect = '# This is a Test' + + call cursor(1, 1) + call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'Z'}) + let a = getmatches() + call clearmatches() + redraw! + + let lnum = 2 + call assert_equal(expect, s:screenline(lnum)) + call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 2)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) + call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 16)) + + " reset match using setmatches() + " 1234567890123456 + let expect = '#ZThisZisZaZTest' + call setmatches(a) + redraw! + + call assert_equal(expect, s:screenline(lnum)) + call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 2)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) + call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 16)) + call assert_equal({'group': 'Conceal', 'pattern': '\%2l ', 'priority': 10, 'id': a[0].id, 'conceal': 'Z'}, a[0]) + + quit! +endfunction + +function! Test_using_matchaddpos() + new + setlocal concealcursor=n conceallevel=1 + " set filetype and :syntax on to change screenattr() + setlocal filetype=conf + syntax on + + 1put='# This is a Test' + " 1234567890123456 + let expect = '#Pis a Test' + + call cursor(1, 1) + call matchaddpos('Conceal', [[2,2,6]], 10, -1, {'conceal': 'P'}) + let a = getmatches() + redraw! + + let lnum = 2 + call assert_equal(expect, s:screenline(lnum)) + call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 2)) + call assert_true(screenattr(lnum, 2) !=# screenattr(lnum, 7)) + call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 7)) + call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 10)) + call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 12)) + call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 16)) + call assert_true(screenattr(lnum, 12) ==# screenattr(lnum, 16)) + call assert_equal({'group': 'Conceal', 'id': a[0].id, 'priority': 10, 'pos1': [2, 2, 6], 'conceal': 'P'}, a[0]) + + syntax off + quit! +endfunction + +function! Test_match_using_multibyte_conceal_char() + so mbyte.vim + if &enc !=? 'utf-8' + return + endif + + new + setlocal concealcursor=n conceallevel=1 + + 1put='# This is a Test' + " 1234567890123456 + let expect = '#ˑThisˑisˑaˑTest' + + call cursor(1, 1) + call matchadd('Conceal', '\%2l ', 20, -1, {'conceal': "\u02d1"}) + redraw! + + let lnum = 2 + call assert_equal(expect, s:screenline(lnum)) + call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 2)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) + call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) + call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 16)) + + quit! +endfunction + +function! Test_matchadd_repeat_conceal_with_syntax_off() new " To test targets in the same line string is replaced with conceal char diff --git a/src/testdir/test_undolevels.vim b/src/testdir/test_undolevels.vim index 7bb25effb5297d..5da14b5b70e1b7 100644 --- a/src/testdir/test_undolevels.vim +++ b/src/testdir/test_undolevels.vim @@ -41,4 +41,7 @@ func Test_global_local_undolevels() call assert_equal(50, &g:undolevels) call assert_equal(-123456, &l:undolevels) + " Drop created windows + new + only! endfunc From 7efdcd52910ff9ef1898219c1f5be711f00a44f6 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Sun, 10 Apr 2016 19:12:26 +0900 Subject: [PATCH 19/29] Revert "Fix 'conceal' by matchadd() when :syn off" This reverts commit fd3b7a0d2d0206b99e008401b6fd6828d5faa01f. --- src/screen.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/screen.c b/src/screen.c index 82fc18b0e14552..8044079b52ec90 100644 --- a/src/screen.c +++ b/src/screen.c @@ -4910,18 +4910,7 @@ win_line( && vim_strchr(wp->w_p_cocu, 'v') == NULL)) { char_attr = conceal_attr; - /* PROBLEM: When trying to show cchar by matchadd(), - * prev_syntax_id and syntax_seqnr might be 0 with :syntax off. - * When trying to show cchar by :syntax match, it's no problem because - * syntax_seqnr is not 0. - * To support showing cchar by matchadd(), change syntax_seqnr - * value to non-zero. - * XXX: better solution? - **/ - if (has_match_conc && syntax_seqnr == 0) - syntax_seqnr = -1; - - if ((prev_syntax_id != syntax_seqnr) + if (prev_syntax_id != syntax_seqnr && (syn_get_sub_char() != NUL || match_conc || wp->w_p_cole == 1) && wp->w_p_cole != 3) From 37f22c69ff2dd72d1e3c3bff7e132d51d8702004 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Sun, 10 Apr 2016 19:14:33 +0900 Subject: [PATCH 20/29] apply @ichizok's patch It solves the problem by an even better solution. --- src/screen.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/screen.c b/src/screen.c index 8044079b52ec90..b92cbf9e264dee 100644 --- a/src/screen.c +++ b/src/screen.c @@ -3057,8 +3057,8 @@ win_line( wrapping */ int vcol_off = 0; /* offset for concealed characters */ int did_wcol = FALSE; - int match_conc = FALSE; /* cchar for match functions */ - int has_match_conc = FALSE; /* match wants to conceal */ + int match_conc = 0; /* cchar for match functions */ + int has_match_conc = 0; /* match wants to conceal */ int old_boguscols = 0; # define VCOL_HLC (vcol - vcol_off) # define FIX_FOR_BOGUSCOLS \ @@ -3595,7 +3595,7 @@ win_line( for (;;) { #ifdef FEAT_CONCEAL - has_match_conc = FALSE; + has_match_conc = 0; #endif /* Skip this quickly when working on the text. */ if (draw_state != WL_LINE) @@ -3944,11 +3944,12 @@ win_line( if (cur != NULL && syn_name2id((char_u *)"Conceal") == cur->hlg_id) { - has_match_conc = TRUE; + has_match_conc = + v == (long)shl->startcol ? 2 : 1; match_conc = cur->conceal_char; } else - has_match_conc = match_conc = FALSE; + has_match_conc = match_conc = 0; #endif } else if (v == (long)shl->endcol) @@ -4905,12 +4906,12 @@ win_line( if ( wp->w_p_cole > 0 && (wp != curwin || lnum != wp->w_cursor.lnum || conceal_cursor_line(wp) ) - && ( (syntax_flags & HL_CONCEAL) != 0 || has_match_conc) + && ( (syntax_flags & HL_CONCEAL) != 0 || has_match_conc > 0) && !(lnum_in_visual_area && vim_strchr(wp->w_p_cocu, 'v') == NULL)) { char_attr = conceal_attr; - if (prev_syntax_id != syntax_seqnr + if ((prev_syntax_id != syntax_seqnr || has_match_conc > 1) && (syn_get_sub_char() != NUL || match_conc || wp->w_p_cole == 1) && wp->w_p_cole != 3) From de2dedea26fd463e223a5f532885c5d4552c1241 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Sun, 10 Apr 2016 19:58:24 +0900 Subject: [PATCH 21/29] Run test_matchadd_conceal.vim individually --- src/Makefile | 1 + src/testdir/Make_all.mak | 1 + src/testdir/test_alot.vim | 1 - src/testdir/test_matchadd_conceal.vim | 2 ++ 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 1543bda9de7618..2810cb3bfe01cd 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2025,6 +2025,7 @@ test_arglist \ test_json \ test_langmap \ test_lispwords \ + test_matchadd_conceal \ test_matchstrpos \ test_menu \ test_packadd \ diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak index 1dca6abac36ea3..2fb8a55d659907 100644 --- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -174,6 +174,7 @@ NEW_TESTS = test_arglist.res \ test_increment.res \ test_json.res \ test_langmap.res \ + test_matchadd_conceal.res \ test_packadd.res \ test_perl.res \ test_quickfix.res \ diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim index 1b44286adc6b06..7f9a1a78fed8db 100644 --- a/src/testdir/test_alot.vim +++ b/src/testdir/test_alot.vim @@ -16,7 +16,6 @@ source test_help_tagjump.vim source test_join.vim source test_lispwords.vim source test_matchstrpos.vim -source test_matchadd_conceal.vim source test_menu.vim source test_partial.vim source test_reltime.vim diff --git a/src/testdir/test_matchadd_conceal.vim b/src/testdir/test_matchadd_conceal.vim index 477d86cba66aba..4d2fcaf0301f2b 100644 --- a/src/testdir/test_matchadd_conceal.vim +++ b/src/testdir/test_matchadd_conceal.vim @@ -3,6 +3,8 @@ if !has('conceal') finish endif +set term=ansi + function! s:screenline(lnum) abort let line = [] for c in range(1, winwidth(0)) From 5cbc2fa6170e6d2dbab3423ac60de346d623ebb8 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Sun, 10 Apr 2016 20:18:35 +0900 Subject: [PATCH 22/29] Check gui_running before set term --- src/testdir/test_matchadd_conceal.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/testdir/test_matchadd_conceal.vim b/src/testdir/test_matchadd_conceal.vim index 4d2fcaf0301f2b..a4d8c3156bf18a 100644 --- a/src/testdir/test_matchadd_conceal.vim +++ b/src/testdir/test_matchadd_conceal.vim @@ -3,7 +3,9 @@ if !has('conceal') finish endif -set term=ansi +if !has('gui_running') + set term=ansi +endif function! s:screenline(lnum) abort let line = [] From 98fd1bb44c4ee1a6c3c855f0de6dfcdcd9475c65 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Sun, 10 Apr 2016 20:39:28 +0900 Subject: [PATCH 23/29] Use assert_equal() and assert_notequal() instead of assert_true() --- src/testdir/test_matchadd_conceal.vim | 127 +++++++++++++------------- 1 file changed, 64 insertions(+), 63 deletions(-) diff --git a/src/testdir/test_matchadd_conceal.vim b/src/testdir/test_matchadd_conceal.vim index a4d8c3156bf18a..65614a7f99c9d4 100644 --- a/src/testdir/test_matchadd_conceal.vim +++ b/src/testdir/test_matchadd_conceal.vim @@ -31,11 +31,12 @@ function! Test_simple_matchadd() redraw! let lnum = 2 call assert_equal(expect, s:screenline(lnum)) - call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 2)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) - call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 16)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) quit! endfunction @@ -53,11 +54,11 @@ function! Test_simple_matchadd_and_conceal() redraw! let lnum = 2 call assert_equal(expect, s:screenline(lnum)) - call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 2)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) - call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 16)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) quit! endfunction @@ -79,11 +80,11 @@ function! Test_matchadd_and_conceallevel_3() redraw! let lnum = 2 call assert_equal(expect, s:screenline(lnum)) - call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 2)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) - call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 16)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 16)) " more matchadd() " 1234567890123456 @@ -92,12 +93,12 @@ function! Test_matchadd_and_conceallevel_3() call matchadd('ErrorMsg', '\%2l Test', 20, -1, {'conceal': 'X'}) redraw! call assert_equal(expect, s:screenline(lnum)) - call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 2)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) - call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 10)) - call assert_true(screenattr(lnum, 10) ==# screenattr(lnum, 12)) - call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 16)) - call assert_true(screenattr(lnum, 10) !=# screenattr(lnum, 16)) + call assert_equal(screenattr(lnum, 1) , screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2) , screenattr(lnum, 7)) + call assert_notequal(screenattr(lnum, 1) , screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 10), screenattr(lnum, 12)) + call assert_notequal(screenattr(lnum, 1) , screenattr(lnum, 16)) + call assert_notequal(screenattr(lnum, 10), screenattr(lnum, 16)) syntax off quit! @@ -116,11 +117,11 @@ function! Test_default_conceal_char() redraw! let lnum = 2 call assert_equal(expect, s:screenline(lnum)) - call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 2)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) - call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 16)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) " 1234567890123456 let expect = '#+This+is+a+Test' @@ -129,11 +130,11 @@ function! Test_default_conceal_char() redraw! call assert_equal(expect, s:screenline(lnum)) - call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 2)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) - call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 16)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) let &listchars = listchars_save quit! @@ -153,11 +154,11 @@ function! Test_syn_and_match_conceal() redraw! let lnum = 2 call assert_equal(expect, s:screenline(lnum)) - call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 2)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) - call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 16)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) " 1234567890123456 let expect = '#*This*is*a*Test' @@ -165,11 +166,11 @@ function! Test_syn_and_match_conceal() redraw! call assert_equal(expect, s:screenline(lnum)) - call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 2)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) - call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 16)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) syntax off quit! @@ -191,11 +192,11 @@ function! Test_clearmatches() let lnum = 2 call assert_equal(expect, s:screenline(lnum)) - call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 2)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) - call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 16)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) " reset match using setmatches() " 1234567890123456 @@ -204,11 +205,11 @@ function! Test_clearmatches() redraw! call assert_equal(expect, s:screenline(lnum)) - call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 2)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) - call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 16)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) call assert_equal({'group': 'Conceal', 'pattern': '\%2l ', 'priority': 10, 'id': a[0].id, 'conceal': 'Z'}, a[0]) quit! @@ -232,13 +233,13 @@ function! Test_using_matchaddpos() let lnum = 2 call assert_equal(expect, s:screenline(lnum)) - call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 2)) - call assert_true(screenattr(lnum, 2) !=# screenattr(lnum, 7)) - call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 7)) - call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 10)) - call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 12)) - call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 16)) - call assert_true(screenattr(lnum, 12) ==# screenattr(lnum, 16)) + call assert_notequal(screenattr(lnum, 1) , screenattr(lnum, 2)) + call assert_notequal(screenattr(lnum, 2) , screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 1) , screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 1) , screenattr(lnum, 10)) + call assert_notequal(screenattr(lnum, 1) , screenattr(lnum, 12)) + call assert_notequal(screenattr(lnum, 1) , screenattr(lnum, 16)) + call assert_equal(screenattr(lnum, 12), screenattr(lnum, 16)) call assert_equal({'group': 'Conceal', 'id': a[0].id, 'priority': 10, 'pos1': [2, 2, 6], 'conceal': 'P'}, a[0]) syntax off @@ -264,11 +265,11 @@ function! Test_match_using_multibyte_conceal_char() let lnum = 2 call assert_equal(expect, s:screenline(lnum)) - call assert_true(screenattr(lnum, 1) !=# screenattr(lnum, 2)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 7)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 10)) - call assert_true(screenattr(lnum, 2) ==# screenattr(lnum, 12)) - call assert_true(screenattr(lnum, 1) ==# screenattr(lnum, 16)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) quit! endfunction From 79a51de3367e271ef920c2682e1e8f73e37e81e4 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Sun, 10 Apr 2016 22:49:35 +0900 Subject: [PATCH 24/29] See has('unix') --- src/testdir/test_matchadd_conceal.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testdir/test_matchadd_conceal.vim b/src/testdir/test_matchadd_conceal.vim index 65614a7f99c9d4..98af2e9426647d 100644 --- a/src/testdir/test_matchadd_conceal.vim +++ b/src/testdir/test_matchadd_conceal.vim @@ -3,7 +3,7 @@ if !has('conceal') finish endif -if !has('gui_running') +if !has('gui_running') && has('unix') set term=ansi endif From 5d70bfbdda380a8bb55a713d327f33b670ccedb1 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Tue, 12 Apr 2016 08:29:50 +0900 Subject: [PATCH 25/29] set encoding=utf-8 instead of skipping test It means the test will run on Windows as well. --- src/testdir/test_matchadd_conceal.vim | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/testdir/test_matchadd_conceal.vim b/src/testdir/test_matchadd_conceal.vim index 98af2e9426647d..25ed801652f473 100644 --- a/src/testdir/test_matchadd_conceal.vim +++ b/src/testdir/test_matchadd_conceal.vim @@ -247,10 +247,8 @@ function! Test_using_matchaddpos() endfunction function! Test_match_using_multibyte_conceal_char() - so mbyte.vim - if &enc !=? 'utf-8' - return - endif + let encoding_save = &encoding + set encoding=utf-8 new setlocal concealcursor=n conceallevel=1 @@ -271,6 +269,7 @@ function! Test_match_using_multibyte_conceal_char() call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) + let &encoding = encoding_save quit! endfunction From fca49f9b66d9d0c3bcad47047708505c2e8f0a78 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Tue, 12 Apr 2016 08:56:59 +0900 Subject: [PATCH 26/29] Check has('multi_byte') --- src/testdir/test_matchadd_conceal.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/testdir/test_matchadd_conceal.vim b/src/testdir/test_matchadd_conceal.vim index 25ed801652f473..3332ad04a373b8 100644 --- a/src/testdir/test_matchadd_conceal.vim +++ b/src/testdir/test_matchadd_conceal.vim @@ -247,6 +247,9 @@ function! Test_using_matchaddpos() endfunction function! Test_match_using_multibyte_conceal_char() + if !has('multi_byte') + return + endif let encoding_save = &encoding set encoding=utf-8 From eeedaa699c911b59e6151930465dddac2f3a8532 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Tue, 12 Apr 2016 08:57:34 +0900 Subject: [PATCH 27/29] Remove test_match_conceal.ok I forgot to remove it. --- src/testdir/test_match_conceal.ok | 52 ------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 src/testdir/test_match_conceal.ok diff --git a/src/testdir/test_match_conceal.ok b/src/testdir/test_match_conceal.ok deleted file mode 100644 index 11c379e2f86cfa..00000000000000 --- a/src/testdir/test_match_conceal.ok +++ /dev/null @@ -1,52 +0,0 @@ - -# This is a Test - -Test 1: simple addmatch() -# This is a Test -OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5] - -Test 2: simple addmatch() and conceal (should be: #XThisXisXaXTest) -#XThisXisXaXTest -OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5] - -Test 3: addmatch() and conceallevel=3 (should be: #ThisisaTest) -#ThisisaTest -OK: g:attr[0]==g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]!=g:attr[5] - -Test 4: more match() (should be: #Thisisa Test) -#Thisisa Test -OK: g:attr[0]==g:attr[1] && g:attr[1]==g:attr[2] && g:attr[0]!=g:attr[3] && g:attr[3]==g:attr[4] && g:attr[0]!=g:attr[5] && g:attr[3]!=g:attr[5] - -Test 5/1: default conceal char (should be: # This is a Test) -# This is a Test -OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5] - -Test 5/2: default conceal char (should be: #+This+is+a+Test) -#+This+is+a+Test -OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5] - -Test 6/1: syn and match conceal (should be: #ZThisZisZaZTest) -#ZThisZisZaZTest -OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5] - -Test 6/2: syn and match conceal (should be: #*This*is*a*Test) -#*This*is*a*Test -OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5] - -Test 7/1: clear matches -# This is a Test -OK: g:attr[0]==g:attr[1] && g:attr[0]==g:attr[2] && g:attr[0]==g:attr[3] && g:attr[0]==g:attr[4] && g:attr[0]==g:attr[5] -{'group': 'Conceal', 'pattern': '\%2l ', 'priority': 10, 'id': 10, 'conceal': 'Z'} - -Test 7/2: reset match using setmatches() -#ZThisZisZaZTest -OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5] - -Test 8: using matchaddpos() (should be #Pis a Test -#Pis a Test -OK: g:attr[0]!=g:attr[1] && g:attr[1]!=g:attr[2] && g:attr[0]==g:attr[2] && g:attr[0]==g:attr[3] && g:attr[0]!=g:attr[4] && g:attr[0]!=g:attr[5] && g:attr[4]==g:attr[5] -{'group': 'Conceal', 'id': 11, 'priority': 10, 'pos1': [2, 2, 6], 'conceal': 'P'} - -Test 9: match using multibyte conceal char (should be: #ˑThisˑisˑaˑTest) -#ˑThisˑisˑaˑTest -OK: g:attr[0]!=g:attr[1] && g:attr[1]==g:attr[2] && g:attr[1]==g:attr[3] && g:attr[1]==g:attr[4] && g:attr[0]==g:attr[5] From afa5886e7c2c5408facd953679a0eb7cc8b771db Mon Sep 17 00:00:00 2001 From: haya14busa Date: Thu, 14 Apr 2016 20:39:02 +0900 Subject: [PATCH 28/29] Check multi_byte_encoding instead of multi_byte --- src/testdir/test_matchadd_conceal.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testdir/test_matchadd_conceal.vim b/src/testdir/test_matchadd_conceal.vim index 3332ad04a373b8..865a052c8bf461 100644 --- a/src/testdir/test_matchadd_conceal.vim +++ b/src/testdir/test_matchadd_conceal.vim @@ -247,7 +247,7 @@ function! Test_using_matchaddpos() endfunction function! Test_match_using_multibyte_conceal_char() - if !has('multi_byte') + if !has('multi_byte_encoding') return endif let encoding_save = &encoding From c50276bdf6c3f9e11b88242c45ff4057e69c3c04 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Fri, 15 Apr 2016 00:15:14 +0900 Subject: [PATCH 29/29] Move test for utf8 to test_matchadd_conceal_utf8.vim --- src/testdir/test_alot_utf8.vim | 1 + src/testdir/test_matchadd_conceal.vim | 30 --------------- src/testdir/test_matchadd_conceal_utf8.vim | 45 ++++++++++++++++++++++ 3 files changed, 46 insertions(+), 30 deletions(-) create mode 100644 src/testdir/test_matchadd_conceal_utf8.vim diff --git a/src/testdir/test_alot_utf8.vim b/src/testdir/test_alot_utf8.vim index e55555e6e4c99c..8824ee5e1525c0 100644 --- a/src/testdir/test_alot_utf8.vim +++ b/src/testdir/test_alot_utf8.vim @@ -5,4 +5,5 @@ " files, so that they can be run by themselves. source test_expr_utf8.vim +source test_matchadd_conceal_utf8.vim source test_regexp_utf8.vim diff --git a/src/testdir/test_matchadd_conceal.vim b/src/testdir/test_matchadd_conceal.vim index 865a052c8bf461..5da28160c1bbeb 100644 --- a/src/testdir/test_matchadd_conceal.vim +++ b/src/testdir/test_matchadd_conceal.vim @@ -246,36 +246,6 @@ function! Test_using_matchaddpos() quit! endfunction -function! Test_match_using_multibyte_conceal_char() - if !has('multi_byte_encoding') - return - endif - let encoding_save = &encoding - set encoding=utf-8 - - new - setlocal concealcursor=n conceallevel=1 - - 1put='# This is a Test' - " 1234567890123456 - let expect = '#ˑThisˑisˑaˑTest' - - call cursor(1, 1) - call matchadd('Conceal', '\%2l ', 20, -1, {'conceal': "\u02d1"}) - redraw! - - let lnum = 2 - call assert_equal(expect, s:screenline(lnum)) - call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) - call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) - call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) - call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) - call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) - - let &encoding = encoding_save - quit! -endfunction - function! Test_matchadd_repeat_conceal_with_syntax_off() new diff --git a/src/testdir/test_matchadd_conceal_utf8.vim b/src/testdir/test_matchadd_conceal_utf8.vim new file mode 100644 index 00000000000000..8293fbe75cdcb3 --- /dev/null +++ b/src/testdir/test_matchadd_conceal_utf8.vim @@ -0,0 +1,45 @@ +" Test for matchadd() and conceal feature using utf-8. +if !has('conceal') || !has('multi_byte') + finish +endif +set encoding=utf-8 +scriptencoding utf-8 + +if !has('gui_running') && has('unix') + set term=ansi +endif + +function! s:screenline(lnum) abort + let line = [] + for c in range(1, winwidth(0)) + call add(line, nr2char(screenchar(a:lnum, c))) + endfor + return s:trim(join(line, '')) +endfunction + +function! s:trim(str) abort + return matchstr(a:str,'^\s*\zs.\{-}\ze\s*$') +endfunction + +function! Test_match_using_multibyte_conceal_char() + new + setlocal concealcursor=n conceallevel=1 + + 1put='# This is a Test' + " 1234567890123456 + let expect = '#ˑThisˑisˑaˑTest' + + call cursor(1, 1) + call matchadd('Conceal', '\%2l ', 20, -1, {'conceal': "\u02d1"}) + redraw! + + let lnum = 2 + call assert_equal(expect, s:screenline(lnum)) + call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) + call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) + call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) + + quit! +endfunction