To: vim-dev@vim.org Subject: Patch 5.6a.012 Fcc: outbox From: Bram Moolenaar ------------ Patch 5.6a.012 (depends on 5.6a.008) Problem: Some Syntax menu entries caused a hit-return prompt. Solution: Call a function to make the command shorter. Also rename a few functions to avoid name clashes. Files: runtime/menu.vim *** ../vim-5.6a.11/runtime/menu.vim Thu Dec 23 10:31:26 1999 --- runtime/menu.vim Mon Dec 27 15:10:56 1999 *************** *** 3,9 **** " Note that ":amenu" is often used to make a menu work in all modes. " " Maintainer: Bram Moolenaar ! " Last change: 1999 Dec 22 " Make sure the '<' and 'C' flags are not included in 'cpoptions', otherwise " would not be recognized. See ":help 'cpoptions'". --- 3,9 ---- " Note that ":amenu" is often used to make a menu work in all modes. " " Maintainer: Bram Moolenaar ! " Last change: 1999 Dec 27 " Make sure the '<' and 'C' flags are not included in 'cpoptions', otherwise " would not be recognized. See ":help 'cpoptions'". *************** *** 118,144 **** let bmenu_priority = 60 endif ! func! Bmenu_add() if g:bmenu_wait == 0 ! call Menufilename(expand(""), expand("")) endif endfunc ! func! Bmenu_remove() if g:bmenu_wait == 0 ! let munge = Mungename(expand(""), expand("")) if g:bmenu_short == 0 exe 'aun &Buffers.' . munge else ! exe 'aun &Buffers.' . Hash2(munge) . munge endif let g:bmenu_count = g:bmenu_count - 1 endif endfunc " buffer menu stuff ! func! Bmenu(...) let g:bmenu_wait = 1 let g:bmenu_short = 1 let g:bmenu_count = 0 --- 118,144 ---- let bmenu_priority = 60 endif ! func! BmenuAdd() if g:bmenu_wait == 0 ! call BMenuFilename(expand(""), expand("")) endif endfunc ! func! BmenuRemove() if g:bmenu_wait == 0 ! let munge = BmenuMunge(expand(""), expand("")) if g:bmenu_short == 0 exe 'aun &Buffers.' . munge else ! exe 'aun &Buffers.' . BmenuHash2(munge) . munge endif let g:bmenu_count = g:bmenu_count - 1 endif endfunc " buffer menu stuff ! func! BmenuShow(...) let g:bmenu_wait = 1 let g:bmenu_short = 1 let g:bmenu_count = 0 *************** *** 157,163 **** " create new menu; make 'cpo' empty to include the let cpo_save = &cpo let &cpo = "" ! exe 'am ' . g:bmenu_priority . ".2 &Buffers.Refresh :call Bmenu()" exe 'am ' . g:bmenu_priority . ".4 &Buffers.Delete :bd" exe 'am ' . g:bmenu_priority . ".6 &Buffers.Alternate :b #" exe 'am ' . g:bmenu_priority . ".8 &Buffers.-SEP- :" --- 157,163 ---- " create new menu; make 'cpo' empty to include the let cpo_save = &cpo let &cpo = "" ! exe 'am ' . g:bmenu_priority . ".2 &Buffers.Refresh :call BmenuShow()" exe 'am ' . g:bmenu_priority . ".4 &Buffers.Delete :bd" exe 'am ' . g:bmenu_priority . ".6 &Buffers.Alternate :b #" exe 'am ' . g:bmenu_priority . ".8 &Buffers.-SEP- :" *************** *** 179,204 **** let buf = 1 while buf <= bufnr('$') if bufexists(buf) ! call Menufilename(bufname(buf), buf) endif let buf = buf + 1 endwhile let g:bmenu_wait = 0 aug buffer_list au! ! au BufCreate,BufFilePost * call Bmenu_add() ! au BufDelete,BufFilePre * call Bmenu_remove() aug END endfunc ! func! Hash(name) " Make name all upper case, so that chars are between 32 and 96 let nm = substitute(a:name, ".*", '\U\0', "") " convert first six chars into a number for sorting: return (char2nr(nm[0]) - 32) * 0x1000000 + (char2nr(nm[1]) - 32) * 0x40000 + (char2nr(nm[2]) - 32) * 0x1000 + (char2nr(nm[3]) - 32) * 0x40 + (char2nr(nm[4]) - 32) * 0x40 + (char2nr(nm[5]) - 32) endfunc ! func! Hash2(name) let nm = substitute(a:name, ".", '\L\0', "") if nm[0] >= 'a' && nm[0] <= 'd' return '&abcd.' --- 179,204 ---- let buf = 1 while buf <= bufnr('$') if bufexists(buf) ! call BMenuFilename(bufname(buf), buf) endif let buf = buf + 1 endwhile let g:bmenu_wait = 0 aug buffer_list au! ! au BufCreate,BufFilePost * call BmenuAdd() ! au BufDelete,BufFilePre * call BmenuRemove() aug END endfunc ! func! BmenuHash(name) " Make name all upper case, so that chars are between 32 and 96 let nm = substitute(a:name, ".*", '\U\0', "") " convert first six chars into a number for sorting: return (char2nr(nm[0]) - 32) * 0x1000000 + (char2nr(nm[1]) - 32) * 0x40000 + (char2nr(nm[2]) - 32) * 0x1000 + (char2nr(nm[3]) - 32) * 0x40 + (char2nr(nm[4]) - 32) * 0x40 + (char2nr(nm[5]) - 32) endfunc ! func! BmenuHash2(name) let nm = substitute(a:name, ".", '\L\0', "") if nm[0] >= 'a' && nm[0] <= 'd' return '&abcd.' *************** *** 217,229 **** endfunc " take a buffer number, return a name to insert into a menu: ! func! Menufilename(name, num) ! let munge = Mungename(a:name, a:num) ! let hash = Hash(munge) if g:bmenu_short == 0 let name = 'am ' . g:bmenu_priority . '.' . hash .' &Buffers.' . munge else ! let name = 'am ' . g:bmenu_priority . '.' . hash . '.' . hash .' &Buffers.' . Hash2(munge) . munge endif " make 'cpo' empty to include the let cpo_save = &cpo --- 217,229 ---- endfunc " take a buffer number, return a name to insert into a menu: ! func! BMenuFilename(name, num) ! let munge = BmenuMunge(a:name, a:num) ! let hash = BmenuHash(munge) if g:bmenu_short == 0 let name = 'am ' . g:bmenu_priority . '.' . hash .' &Buffers.' . munge else ! let name = 'am ' . g:bmenu_priority . '.' . hash . '.' . hash .' &Buffers.' . BmenuHash2(munge) . munge endif " make 'cpo' empty to include the let cpo_save = &cpo *************** *** 232,238 **** let &cpo = cpo_save endfunc ! func! Mungename(fname, bnum) let name = a:fname if name == '' let name = '[No File]' --- 232,238 ---- let &cpo = cpo_save endfunc ! func! BmenuMunge(fname, bnum) let name = a:fname if name == '' let name = '[No File]' *************** *** 253,263 **** " When just starting Vim, load the buffer menu later if has("vim_starting") augroup LoadBufferMenu ! au! VimEnter * if !exists("no_buffers_menu") | call Bmenu() | endif au VimEnter * au! LoadBufferMenu augroup END else ! call Bmenu() endif endif " !exists("no_buffers_menu") --- 253,263 ---- " When just starting Vim, load the buffer menu later if has("vim_starting") augroup LoadBufferMenu ! au! VimEnter * if !exists("no_buffers_menu") | call BmenuShow() | endif au VimEnter * au! LoadBufferMenu augroup END else ! call BmenuShow() endif endif " !exists("no_buffers_menu") *************** *** 677,689 **** am 50.95 &Syntax.-SEP1- : am 50.100 &Syntax.Set\ 'syntax'\ only :let syntax_menu_synonly=1 ! am 50.101 &Syntax.Set\ 'filetype'\ too :if exists("syntax_menu_synonly")unlet syntax_menu_synonlyendif am 50.110 &Syntax.&Off :syn off am 50.112 &Syntax.&Manual :syn manual am 50.114 &Syntax.A&utomatic :syn on ! am 50.116 &Syntax.&on\ (this\ file) :if !exists("syntax_on")syn manualendifset syn=ON am 50.118 &Syntax.o&ff\ (this\ file) :syn clear am 50.700 &Syntax.-SEP3- : --- 678,701 ---- am 50.95 &Syntax.-SEP1- : am 50.100 &Syntax.Set\ 'syntax'\ only :let syntax_menu_synonly=1 ! am 50.101 &Syntax.Set\ 'filetype'\ too :call SmenuNosynonly() ! fun! SmenuNosynonly() ! if exists("syntax_menu_synonly") ! unlet syntax_menu_synonly ! endif ! endfun am 50.110 &Syntax.&Off :syn off am 50.112 &Syntax.&Manual :syn manual am 50.114 &Syntax.A&utomatic :syn on ! am 50.116 &Syntax.&on\ (this\ file) :call SmenuSynoff() ! fun! SmenuSynoff() ! if !exists("syntax_on") ! syn manual ! endif ! set syn=ON ! endfun am 50.118 &Syntax.o&ff\ (this\ file) :syn clear am 50.700 &Syntax.-SEP3- : *** ../vim-5.6a.11/src/version.c Mon Dec 27 14:43:22 1999 --- src/version.c Mon Dec 27 15:19:06 1999 *************** *** 420,421 **** --- 420,423 ---- { /* Add new patch number below this line */ + /**/ + 12, /**/ -- If you don't get everything you want, think of everything you didn't get and don't want. --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\-- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /