From 7dfd466437d506d800c7db12cc8a111357e13aff Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 7 Dec 2022 14:04:54 +0800 Subject: [PATCH 1/3] vim-patch:8.2.1768: cannot use the help menu from a terminal window Problem: Cannot use the help menu from a terminal window. Solution: Add ":tlnoremenu" commands. (Yee Cheng Chin, closes vim/vim#7023) https://github.com/vim/vim/commit/b45cd36bd90f71e4a35b1ef1f75a3bedef6d8bac Co-authored-by: Bram Moolenaar --- runtime/menu.vim | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/runtime/menu.vim b/runtime/menu.vim index 0a5ac36095..187818b41d 100644 --- a/runtime/menu.vim +++ b/runtime/menu.vim @@ -2,7 +2,7 @@ " You can also use this as a start for your own set of menus. " " Maintainer: Bram Moolenaar -" Last Change: 2020 Mar 29 +" Last Change: 2020 Sep 28 " Note that ":an" (short for ":anoremenu") is often used to make a menu work " in all modes and avoid side effects from mappings defined by the user. @@ -89,6 +89,21 @@ an 9999.75 &Help.-sep2- an 9999.80 &Help.&Version :version an 9999.90 &Help.&About :intro +if exists(':tlmenu') + tlnoremenu 9999.10 &Help.&Overview :help + tlnoremenu 9999.20 &Help.&User\ Manual :help usr_toc + tlnoremenu 9999.30 &Help.&How-To\ Links :help how-to + tlnoremenu 9999.40 &Help.&Find\.\.\. :call Helpfind() + tlnoremenu 9999.45 &Help.-sep1- + tlnoremenu 9999.50 &Help.&Credits :help credits + tlnoremenu 9999.60 &Help.Co&pying :help copying + tlnoremenu 9999.70 &Help.&Sponsor/Register :help sponsor + tlnoremenu 9999.70 &Help.O&rphans :help kcc + tlnoremenu 9999.75 &Help.-sep2- + tlnoremenu 9999.80 &Help.&Version :version + tlnoremenu 9999.90 &Help.&About :intro +endif + fun! s:Helpfind() if !exists("g:menutrans_help_dialog") let g:menutrans_help_dialog = "Enter a command or word to find help on:\n\nPrepend i_ for Input mode commands (e.g.: i_CTRL-X)\nPrepend c_ for command-line editing commands (e.g.: c_)\nPrepend ' for an option name (e.g.: 'shiftwidth')" From c61af03cd2c310c1ee472b4529c34f6656574770 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 7 Dec 2022 14:11:26 +0800 Subject: [PATCH 2/3] vim-patch:0e6adf8a29d5 Update runtime files https://github.com/vim/vim/commit/0e6adf8a29d5c2c96c42cc7157f71bf22c2ad471 Co-authored-by: Bram Moolenaar --- runtime/doc/map.txt | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 2ecfefca7f..b495b355cf 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -872,28 +872,35 @@ Here is an example that counts the number of spaces with : > " doubling works on a line nnoremap CountSpaces() .. '_' - function CountSpaces(type = '') abort + function CountSpaces(virtualedit = '', irregular_block = v:false, type = '') abort if a:type == '' - set opfunc=CountSpaces + let &operatorfunc = function('CountSpaces', [&virtualedit, v:false]) + set virtualedit=block return 'g@' endif + let cb_save = &clipboard let sel_save = &selection let reg_save = getreginfo('"') - let cb_save = &clipboard let visual_marks_save = [getpos("'<"), getpos("'>")] try - set clipboard= selection=inclusive - let commands = #{line: "'[V']y", char: "`[v`]y", block: "`[\`]y"} - silent exe 'noautocmd keepjumps normal! ' .. get(commands, a:type, '') - echom count(getreg('"'), ' ') + set clipboard= selection=inclusive virtualedit= + let commands = #{line: "'[V']", char: "`[v`]", block: "`[\`]"}->get(a:type, 'v') + if getpos("']")[-1] != 0 || a:irregular_block + let commands ..= 'oO$' + let &operatorfunc = function('CountSpaces', [a:virtualedit, v:true]) + endif + let commands ..= 'y' + execute 'silent noautocmd keepjumps normal! ' .. commands + echomsg getreg('"')->count(' ') finally call setreg('"', reg_save) call setpos("'<", visual_marks_save[0]) call setpos("'>", visual_marks_save[1]) let &clipboard = cb_save let &selection = sel_save + let &virtualedit = a:virtualedit endtry endfunction From 214c9ed1e2ad7881103a0eaed646a29e3e1392cd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 7 Dec 2022 14:07:30 +0800 Subject: [PATCH 3/3] vim-patch:fa3b72348d88 Update runtime files https://github.com/vim/vim/commit/fa3b72348d88343390fbe212cfc230fec1602fc2 Co-authored-by: Bram Moolenaar --- runtime/doc/map.txt | 53 ++++++++++++++++++++++++++++------------- runtime/doc/options.txt | 2 +- runtime/menu.vim | 7 +++++- 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index b495b355cf..b51268eebf 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -872,35 +872,56 @@ Here is an example that counts the number of spaces with : > " doubling works on a line nnoremap CountSpaces() .. '_' - function CountSpaces(virtualedit = '', irregular_block = v:false, type = '') abort + function CountSpaces(context = {}, type = '') abort if a:type == '' - let &operatorfunc = function('CountSpaces', [&virtualedit, v:false]) + let context = #{ + \ dot_command: v:false, + \ extend_block: '', + \ virtualedit: [&l:virtualedit, &g:virtualedit], + \ } + let &operatorfunc = function('CountSpaces', [context]) set virtualedit=block return 'g@' endif - let cb_save = &clipboard - let sel_save = &selection - let reg_save = getreginfo('"') - let visual_marks_save = [getpos("'<"), getpos("'>")] + let save = #{ + \ clipboard: &clipboard, + \ selection: &selection, + \ virtualedit: [&l:virtualedit, &g:virtualedit], + \ register: getreginfo('"'), + \ visual_marks: [getpos("'<"), getpos("'>")], + \ } try set clipboard= selection=inclusive virtualedit= - let commands = #{line: "'[V']", char: "`[v`]", block: "`[\`]"}->get(a:type, 'v') - if getpos("']")[-1] != 0 || a:irregular_block - let commands ..= 'oO$' - let &operatorfunc = function('CountSpaces', [a:virtualedit, v:true]) + let commands = #{ + \ line: "'[V']", + \ char: "`[v`]", + \ block: "`[\`]", + \ }[a:type] + let [_, _, col, off] = getpos("']") + if off != 0 + let vcol = getline("'[")->strpart(0, col + off)->strdisplaywidth() + if vcol >= [line("'["), '$']->virtcol() - 1 + let a:context.extend_block = '$' + else + let a:context.extend_block = vcol .. '|' + endif + endif + if a:context.extend_block != '' + let commands ..= 'oO' .. a:context.extend_block endif let commands ..= 'y' execute 'silent noautocmd keepjumps normal! ' .. commands echomsg getreg('"')->count(' ') finally - call setreg('"', reg_save) - call setpos("'<", visual_marks_save[0]) - call setpos("'>", visual_marks_save[1]) - let &clipboard = cb_save - let &selection = sel_save - let &virtualedit = a:virtualedit + call setreg('"', save.register) + call setpos("'<", save.visual_marks[0]) + call setpos("'>", save.visual_marks[1]) + let &clipboard = save.clipboard + let &selection = save.selection + let [&l:virtualedit, &g:virtualedit] = get(a:context.dot_command ? save : a:context, 'virtualedit') + let a:context.dot_command = v:true endtry endfunction diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 17b91fe2b6..2e5381e5fe 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -324,7 +324,7 @@ the name, e.g. "123". Examples: set opfunc={a\ ->\ MyOpFunc(a)} " set using a funcref variable let Fn = function('MyTagFunc') - let &tagfunc = string(Fn) + let &tagfunc = Fn " set using a lambda expression let &tagfunc = {t -> MyTagFunc(t)} " set using a variable with lambda expression diff --git a/runtime/menu.vim b/runtime/menu.vim index 187818b41d..1c48d617eb 100644 --- a/runtime/menu.vim +++ b/runtime/menu.vim @@ -2,7 +2,7 @@ " You can also use this as a start for your own set of menus. " " Maintainer: Bram Moolenaar -" Last Change: 2020 Sep 28 +" Last Change: 2021 Dec 22 " Note that ":an" (short for ":anoremenu") is often used to make a menu work " in all modes and avoid side effects from mappings defined by the user. @@ -717,6 +717,11 @@ func s:BMCanAdd(name, num) return 0 endif + " no name with control characters + if a:name =~ '[\x01-\x1f]' + return 0 + endif + " no special buffer, such as terminal or popup let buftype = getbufvar(a:num, '&buftype') if buftype != '' && buftype != 'nofile' && buftype != 'nowrite'