changeset 27538:f37561549ec2

Update runtime files; use compiled functions Commit: https://github.com/vim/vim/commit/3e79c97c18c50f97797ab13ed81c4011eba9aba0 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 4 19:48:06 2022 +0000 Update runtime files; use compiled functions
author Bram Moolenaar <Bram@vim.org>
date Fri, 04 Feb 2022 21:00:05 +0100
parents 063952f68595
children ce4c2f4ce1f9
files runtime/autoload/dist/ft.vim runtime/doc/uganda.txt runtime/ftplugin.vim runtime/indent.vim runtime/makemenu.vim runtime/menu.vim runtime/synmenu.vim
diffstat 7 files changed, 473 insertions(+), 510 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -893,4 +893,4 @@ enddef
 
 
 # Uncomment this line to check for compilation errors early
-defcompile
+# defcompile
--- a/runtime/doc/uganda.txt
+++ b/runtime/doc/uganda.txt
@@ -1,4 +1,4 @@
-*uganda.txt*    For Vim version 8.2.  Last change: 2020 Jan 08
+*uganda.txt*    For Vim version 8.2.  Last change: 2022 Feb 04
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -11,9 +11,9 @@ Vim is Charityware.  You can use and cop
 encouraged to make a donation for needy children in Uganda.  Please see |kcc|
 below or visit the ICCF web site, available at these URLs:
 
-	http://iccf-holland.org/
-	http://www.vim.org/iccf/
-	http://www.iccf.nl/
+	https://iccf-holland.org/
+	https://www.vim.org/iccf/
+	https://www.iccf.nl/
 
 You can also sponsor the development of Vim.  Vim sponsors can vote for
 features.  See |sponsor|.  The money goes to Uganda anyway.
@@ -169,10 +169,11 @@ households are stimulated to build a pro
 production site for cement slabs.  These are used to build a good latrine.
 They are sold below cost price.
 
-There is a small clinic at the project, which provides children and their
-family with medical help.  When needed, transport to a hospital is offered.
-Immunization programs are carried out and help is provided when an epidemic is
-breaking out (measles and cholera have been a problem).
+There is a clinic at the project, which provides children and their family
+medical help.  Since 2020 a maternity ward was added and 24/7 service is
+available.  When needed, transport to a hospital is offered.  Immunization
+programs are carried out and help is provided when an epidemic is breaking out
+(measles and cholera have been a problem).
 							*donate*
 Summer 1994 to summer 1995 I spent a whole year at the centre, working as a
 volunteer.  I have helped to expand the centre and worked in the area of water
@@ -214,44 +215,29 @@ Check the ICCF web site for the latest i
 
 
 USA:		The methods mentioned below can be used.
-		Sending a check to the Nehemiah Group Outreach Society (NGOS)
-		is no longer possible, unfortunately. We are looking for
-		another way to get you an IRS tax receipt.
-		For sponsoring a child contact KCF in Canada (see below). US
-		checks can be sent to them to lower banking costs.
+		If you must send a check send it to our Canadian partner:
+		https://www.kuwasha.net/
 
-Canada:		Contact Kibaale Children's Fund (KCF) in Surrey, Canada.  They
-		take care of the Canadian sponsors for the children in
-		Kibaale.  KCF forwards 100% of the money to the project in
-		Uganda.  You can send them a one time donation directly.
+Canada:		Contact Kuwasha in Surrey, Canada.  They take care of the
+		Canadian sponsors for the children in Kibaale.  Kuwasha
+		forwards 100% of the money to the project in Uganda.  You can
+		send them a one time donation directly.
 		Please send me a note so that I know what has been donated
-		because of Vim.  Ask KCF for information about sponsorship.
-			Kibaale Children's Fund c/o Pacific Academy
-			10238-168 Street
-			Surrey, B.C. V4N 1Z4
-			Canada
-			Phone: 604-581-5353
-		If you make a donation to Kibaale Children's Fund (KCF) you
-		will receive a tax receipt which can be submitted with your
-		tax return.
+		because of Vim.  Look on their for information about
+		sponsorship: https://www.kuwasha.net/
+		If you make a donation to Kuwasha you will receive a tax
+		receipt which can be submitted with your tax return.
 
-Holland:	Transfer to the account of "Stichting ICCF Holland" in Lisse.
-		This will allow for tax deduction if you live in Holland.
-			Postbank, nr. 4548774
-			IBAN: NL95 INGB 0004 5487 74
+Holland:	Transfer to the account of "Stichting ICCF Holland" in
+		Amersfoort.  This will allow for tax deduction if you live in
+		Holland.  ING bank, IBAN: NL95 INGB 0004 5487 74
 
 Germany:	It is possible to make donations that allow for a tax return.
 		Check the ICCF web site for the latest information:
-			http://iccf-holland.org/germany.html
+			https://iccf-holland.org/germany.html
 
-World:		Use a postal money order.  That should be possible from any
-		country, mostly from the post office.  Use this name (which is
-		in my passport): "Abraham Moolenaar".  Use Euro for the
-		currency if possible.
-
-Europe:		Use a bank transfer if possible.  Your bank should have a form
-		that you can use for this.  See "Others" below for the swift
-		code and IBAN number.
+Europe:		Use a bank transfer if possible.  See "Others" below for the
+		swift code and IBAN number.
 		Any other method should work.  Ask for information about
 		sponsorship.
 
@@ -261,28 +247,12 @@ Credit Card:	You can use PayPal to send 
 		    https://www.paypal.com/en_US/mrb/pal=XAC62PML3GF8Q
 		The e-mail address for sending the money to is:
 		    Bram@iccf-holland.org
-		For amounts above 400 Euro ($500) sending a check is
-		preferred.
 
 Others:		Transfer to one of these accounts if possible:
-		    Postbank, account 4548774
-				Swift code: INGB NL 2A
-				IBAN: NL95 INGB 0004 5487 74
-			under the name "stichting ICCF Holland", Lisse
-		    If that doesn't work:
-		    Rabobank Lisse, account 3765.05.117
-				Swift code: RABO NL 2U
-			under the name "Bram Moolenaar", Lisse
-		Otherwise, send a check in euro or US dollars to the address
-		below.  Minimal amount: $70 (my bank does not accept smaller
-		amounts for foreign check, sorry)
+		    ING bank: 	IBAN: NL95 INGB 0004 5487 74
+				Swift code: INGBNL2A
+		    under the name "stichting ICCF Holland", Amersfoort
+		Checks are not accepted.
 
-Address to send checks to:
-			Bram Moolenaar
-			Finsterruetihof 1
-			8134 Adliswil
-			Switzerland
-
-This address is expected to be valid for a long time.
 
  vim:tw=78:ts=8:noet:ft=help:norl:
--- a/runtime/ftplugin.vim
+++ b/runtime/ftplugin.vim
@@ -1,7 +1,7 @@
 " Vim support file to switch on loading plugins for file types
 "
 " Maintainer:	Bram Moolenaar <Bram@vim.org>
-" Last change:	2006 Apr 30
+" Last change:	2022 Feb 04
 
 if exists("did_load_ftplugin")
   finish
@@ -10,26 +10,26 @@ let did_load_ftplugin = 1
 
 augroup filetypeplugin
   au FileType * call s:LoadFTPlugin()
+augroup END
 
-  func! s:LoadFTPlugin()
-    if exists("b:undo_ftplugin")
-      exe b:undo_ftplugin
-      unlet! b:undo_ftplugin b:did_ftplugin
+def s:LoadFTPlugin()
+  if exists("b:undo_ftplugin")
+    exe b:undo_ftplugin
+    unlet! b:undo_ftplugin b:did_ftplugin
+  endif
+
+  var s = expand("<amatch>")
+  if s != ""
+    if &cpo =~# "S" && exists("b:did_ftplugin")
+      # In compatible mode options are reset to the global values, need to
+      # set the local values also when a plugin was already used.
+      unlet b:did_ftplugin
     endif
 
-    let s = expand("<amatch>")
-    if s != ""
-      if &cpo =~# "S" && exists("b:did_ftplugin")
-	" In compatible mode options are reset to the global values, need to
-	" set the local values also when a plugin was already used.
-	unlet b:did_ftplugin
-      endif
-
-      " When there is a dot it is used to separate filetype names.  Thus for
-      " "aaa.bbb" load "aaa" and then "bbb".
-      for name in split(s, '\.')
-	exe 'runtime! ftplugin/' . name . '.vim ftplugin/' . name . '_*.vim ftplugin/' . name . '/*.vim'
-      endfor
-    endif
-  endfunc
-augroup END
+    # When there is a dot it is used to separate filetype names.  Thus for
+    # "aaa.bbb" load "aaa" and then "bbb".
+    for name in split(s, '\.')
+      exe 'runtime! ftplugin/' .. name .. '.vim ftplugin/' .. name .. '_*.vim ftplugin/' .. name .. '/*.vim'
+    endfor
+  endif
+enddef
--- a/runtime/indent.vim
+++ b/runtime/indent.vim
@@ -1,7 +1,7 @@
 " Vim support file to switch on loading indent files for file types
 "
 " Maintainer:	Bram Moolenaar <Bram@vim.org>
-" Last Change:	2008 Feb 22
+" Last Change:	2022 Feb 04
 
 if exists("did_indent_on")
   finish
@@ -10,22 +10,23 @@ let did_indent_on = 1
 
 augroup filetypeindent
   au FileType * call s:LoadIndent()
-  func! s:LoadIndent()
-    if exists("b:undo_indent")
-      exe b:undo_indent
-      unlet! b:undo_indent b:did_indent
+augroup END
+
+def s:LoadIndent()
+  if exists("b:undo_indent")
+    exe b:undo_indent
+    unlet! b:undo_indent b:did_indent
+  endif
+  var s = expand("<amatch>")
+  if s != ""
+    if exists("b:did_indent")
+      unlet b:did_indent
     endif
-    let s = expand("<amatch>")
-    if s != ""
-      if exists("b:did_indent")
-	unlet b:did_indent
-      endif
 
-      " When there is a dot it is used to separate filetype names.  Thus for
-      " "aaa.bbb" load "indent/aaa.vim" and then "indent/bbb.vim".
-      for name in split(s, '\.')
-	exe 'runtime! indent/' . name . '.vim'
-      endfor
-    endif
-  endfunc
-augroup END
+    # When there is a dot it is used to separate filetype names.  Thus for
+    # "aaa.bbb" load "indent/aaa.vim" and then "indent/bbb.vim".
+    for name in split(s, '\.')
+      exe 'runtime! indent/' .. name .. '.vim'
+    endfor
+  endif
+enddef
--- a/runtime/makemenu.vim
+++ b/runtime/makemenu.vim
@@ -1,52 +1,54 @@
-" Script to define the syntax menu in synmenu.vim
-" Maintainer:	Bram Moolenaar <Bram@vim.org>
-" Last Change:	2019 Dec 07
+vim9script
 
-" This is used by "make menu" in the src directory.
+# Script to define the syntax menu in synmenu.vim
+# Maintainer:	Bram Moolenaar <Bram@vim.org>
+# Last Change:	2022 Feb 04
+
+# This is used by "make menu" in the src directory.
 edit <sfile>:p:h/synmenu.vim
 
-/The Start Of The Syntax Menu/+1,/The End Of The Syntax Menu/-1d
-let s:lnum = line(".") - 1
-call append(s:lnum, "")
-let s:lnum = s:lnum + 1
+:/The Start Of The Syntax Menu/+1,/The End Of The Syntax Menu/-1d
+var lnum = line(".") - 1
+call append(lnum, "")
+lnum += 1
 
-" Use the SynMenu command and function to define all menu entries
-command! -nargs=* SynMenu call <SID>Syn(<q-args>)
+# Use the SynMenu command and function to define all menu entries
+command! -nargs=* SynMenu call Syn(<q-args>)
 
-let s:cur_menu_name = ""
-let s:cur_menu_nr = 0
-let s:cur_menu_item = 0
-let s:cur_menu_char = ""
+var cur_menu_name = ""
+var cur_menu_nr = 0
+var cur_menu_item = 0
+var cur_menu_char = ""
 
-fun! <SID>Syn(arg)
-  " isolate menu name: until the first dot
-  let i = match(a:arg, '\.')
-  let menu_name = strpart(a:arg, 0, i)
-  let r = strpart(a:arg, i + 1, 999)
-  " isolate submenu name: until the colon
-  let i = match(r, ":")
-  let submenu_name = strpart(r, 0, i)
-  " after the colon is the syntax name
-  let syntax_name = strpart(r, i + 1, 999)
+def Syn(arg: string)
+  # isolate menu name: until the first dot
+  var i = match(arg, '\.')
+  var menu_name = strpart(arg, 0, i)
+  var r = strpart(arg, i + 1, 999)
+  # isolate submenu name: until the colon
+  i = match(r, ":")
+  var submenu_name = strpart(r, 0, i)
+  # after the colon is the syntax name
+  var syntax_name = strpart(r, i + 1, 999)
 
-  if s:cur_menu_name != menu_name
-    let s:cur_menu_name = menu_name
-    let s:cur_menu_nr = s:cur_menu_nr + 10
-    let s:cur_menu_item = 100
-    let s:cur_menu_char = submenu_name[0]
+  if cur_menu_name != menu_name
+    cur_menu_name = menu_name
+    cur_menu_nr += 10
+    cur_menu_item = 100
+    cur_menu_char = submenu_name[0]
   else
-    " When starting a new letter, insert a menu separator.
-    let c = submenu_name[0]
+    # When starting a new letter, insert a menu separator.
+    var c = submenu_name[0]
     if c != s:cur_menu_char
-      exe 'an 50.' . s:cur_menu_nr . '.' . s:cur_menu_item . ' &Syntax.' . menu_name . ".-" . c . '- <nul>'
-      let s:cur_menu_item = s:cur_menu_item + 10
-      let s:cur_menu_char = c
+      exe 'an 50.' .. s:cur_menu_nr .. '.' .. s:cur_menu_item .. ' &Syntax.' .. menu_name .. ".-" .. c .. '- <nul>'
+      cur_menu_item += 10
+      cur_menu_char = c
     endif
   endif
-  call append(s:lnum, 'an 50.' . s:cur_menu_nr . '.' . s:cur_menu_item . ' &Syntax.' . menu_name . "." . submenu_name . ' :cal SetSyn("' . syntax_name . '")<CR>')
-  let s:cur_menu_item = s:cur_menu_item + 10
-  let s:lnum = s:lnum + 1
-endfun
+  append(lnum, 'an 50.' .. s:cur_menu_nr .. '.' .. s:cur_menu_item .. ' &Syntax.' .. menu_name .. "." .. submenu_name .. ' :cal SetSyn("' .. syntax_name .. '")<CR>')
+  cur_menu_item += 10
+  lnum += 1
+enddef
 
 SynMenu AB.A2ps\ config:a2ps
 SynMenu AB.Aap:aap
@@ -676,6 +678,6 @@ SynMenu WXYZ.YAML:yaml
 SynMenu WXYZ.Yacc:yacc
 SynMenu WXYZ.Zimbu:zimbu
 
-call append(s:lnum, "")
+append(lnum, "")
 
 wq
--- 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 <Bram@vim.org>
-" Last Change:	2021 Dec 22
+" Last Change:	2022 Feb 04
 
 " 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.
@@ -33,7 +33,7 @@ if exists("v:lang") || &langmenu != ""
   if strlen(s:lang) > 1 && s:lang !~? '^en_us'
     " When the language does not include the charset add 'encoding'
     if s:lang =~ '^\a\a$\|^\a\a_\a\a$'
-      let s:lang = s:lang . '.' . &enc
+      let s:lang = s:lang .. '.' .. &enc
     endif
 
     " We always use a lowercase name.
@@ -49,26 +49,26 @@ if exists("v:lang") || &langmenu != ""
     " same menu file for them.
     let s:lang = substitute(s:lang, 'iso_8859-15\=$', "latin1", "")
     menutrans clear
-    exe "runtime! lang/menu_" . s:lang . ".vim"
+    exe "runtime! lang/menu_" .. s:lang .. ".vim"
 
     if !exists("did_menu_trans")
       " There is no exact match, try matching with a wildcard added
       " (e.g. find menu_de_de.iso_8859-1.vim if s:lang == de_DE).
       let s:lang = substitute(s:lang, '\.[^.]*', "", "")
-      exe "runtime! lang/menu_" . s:lang . "[^a-z]*vim"
+      exe "runtime! lang/menu_" .. s:lang .. "[^a-z]*vim"
 
       if !exists("did_menu_trans") && s:lang =~ '_'
 	" If the language includes a region try matching without that region.
 	" (e.g. find menu_de.vim if s:lang == de_DE).
 	let langonly = substitute(s:lang, '_.*', "", "")
-	exe "runtime! lang/menu_" . langonly . "[^a-z]*vim"
+	exe "runtime! lang/menu_" .. langonly .. "[^a-z]*vim"
       endif
 
       if !exists("did_menu_trans") && strlen($LANG) > 1 && s:lang !~ '^en_us'
 	" On windows locale names are complicated, try using $LANG, it might
 	" have been set by set_init_1().  But don't do this for "en" or "en_us".
 	" But don't match "slovak" when $LANG is "sl".
-	exe "runtime! lang/menu_" . tolower($LANG) . "[^a-z]*vim"
+	exe "runtime! lang/menu_" .. tolower($LANG) .. "[^a-z]*vim"
       endif
     endif
   endif
@@ -104,19 +104,19 @@ if exists(':tlmenu')
   tlnoremenu 9999.90 &Help.&About			<C-W>:intro<CR>
 endif
 
-fun! s:Helpfind()
+def 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_<Del>)\nPrepend ' for an option name (e.g.: 'shiftwidth')"
+    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_<Del>)\nPrepend ' for an option name (e.g.: 'shiftwidth')"
   endif
-  let h = inputdialog(g:menutrans_help_dialog)
+  var h = inputdialog(g:menutrans_help_dialog)
   if h != ""
-    let v:errmsg = ""
-    silent! exe "help " . h
+    v:errmsg = ""
+    silent! exe "help " .. h
     if v:errmsg != ""
       echo v:errmsg
     endif
   endif
-endfun
+enddef
 
 " File menu
 an 10.310 &File.&Open\.\.\.<Tab>:e		:browse confirm e<CR>
@@ -154,16 +154,9 @@ an 10.600 &File.-SEP4-				<Nop>
 an 10.610 &File.Sa&ve-Exit<Tab>:wqa		:confirm wqa<CR>
 an 10.620 &File.E&xit<Tab>:qa			:confirm qa<CR>
 
-func s:SelectAll()
-  exe "norm! gg" . (&slm == "" ? "VG" : "gH\<C-O>G")
-endfunc
-
-func s:FnameEscape(fname)
-  if exists('*fnameescape')
-    return fnameescape(a:fname)
-  endif
-  return escape(a:fname, " \t\n*?[{`$\\%#'\"|!<")
-endfunc
+def s:SelectAll()
+  exe "norm! gg" .. (&slm == "" ? "VG" : "gH\<C-O>G")
+enddef
 
 " Edit menu
 an 20.310 &Edit.&Undo<Tab>u			u
@@ -182,8 +175,8 @@ cnoremenu	 &Edit.&Paste<Tab>"+gP		<C-R>+
 if exists(':tlmenu')
   tlnoremenu	 &Edit.&Paste<Tab>"+gP		<C-W>"+
 endif
-exe 'vnoremenu <script> &Edit.&Paste<Tab>"+gP	' . paste#paste_cmd['v']
-exe 'inoremenu <script> &Edit.&Paste<Tab>"+gP	' . paste#paste_cmd['i']
+exe 'vnoremenu <script> &Edit.&Paste<Tab>"+gP	' .. paste#paste_cmd['v']
+exe 'inoremenu <script> &Edit.&Paste<Tab>"+gP	' .. paste#paste_cmd['i']
 nnoremenu 20.370 &Edit.Put\ &Before<Tab>[p	[p
 inoremenu	 &Edit.Put\ &Before<Tab>[p	<C-O>[p
 nnoremenu 20.380 &Edit.Put\ &After<Tab>]p	]p
@@ -214,32 +207,33 @@ an 20.425	 &Edit.-SEP3-				<Nop>
 an 20.430	 &Edit.Settings\ &Window		:options<CR>
 an 20.435	 &Edit.Startup\ &Settings		:call <SID>EditVimrc()<CR>
 
-fun! s:EditVimrc()
+def s:EditVimrc()
+  var fname: string
   if $MYVIMRC != ''
-    let fname = $MYVIMRC
+    fname = $MYVIMRC
   elseif has("win32")
     if $HOME != ''
-      let fname = $HOME . "/_vimrc"
+      fname = $HOME .. "/_vimrc"
     else
-      let fname = $VIM . "/_vimrc"
+      fname = $VIM .. "/_vimrc"
     endif
   elseif has("amiga")
-    let fname = "s:.vimrc"
+    fname = "s:.vimrc"
   else
-    let fname = $HOME . "/.vimrc"
+    fname = $HOME .. "/.vimrc"
   endif
-  let fname = s:FnameEscape(fname)
+  fname = fnameescape(fname)
   if &mod
-    exe "split " . fname
+    exe "split " .. fname
   else
-    exe "edit " . fname
+    exe "edit " .. fname
   endif
-endfun
+enddef
 
-fun! s:FixFText()
-  " Fix text in nameless register to be used with :promptfind.
+def s:FixFText(): string
+  # Fix text in nameless register to be used with :promptfind.
   return substitute(@", "[\r\n]", '\\n', 'g')
-endfun
+enddef
 
 " Edit/Global Settings
 an 20.440.100 &Edit.&Global\ Settings.Toggle\ Pattern\ &Highlight<Tab>:set\ hls!	:set hls! hls?<CR>
@@ -272,34 +266,34 @@ an <silent> 20.440.320 &Edit.&Global\ Se
 an <silent> 20.440.330 &Edit.&Global\ Settings.Toggle\ &Left\ Scrollbar	:call <SID>ToggleGuiOption("l")<CR>
 an <silent> 20.440.340 &Edit.&Global\ Settings.Toggle\ &Right\ Scrollbar :call <SID>ToggleGuiOption("r")<CR>
 
-fun! s:SearchP()
+def s:SearchP()
   if !exists("g:menutrans_path_dialog")
-    let g:menutrans_path_dialog = "Enter search path for files.\nSeparate directory names with a comma."
+    g:menutrans_path_dialog = "Enter search path for files.\nSeparate directory names with a comma."
   endif
-  let n = inputdialog(g:menutrans_path_dialog, substitute(&path, '\\ ', ' ', 'g'))
+  var n = inputdialog(g:menutrans_path_dialog, substitute(&path, '\\ ', ' ', 'g'))
   if n != ""
-    let &path = substitute(n, ' ', '\\ ', 'g')
+    &path = substitute(n, ' ', '\\ ', 'g')
   endif
-endfun
+enddef
 
-fun! s:TagFiles()
+def s:TagFiles()
   if !exists("g:menutrans_tags_dialog")
-    let g:menutrans_tags_dialog = "Enter names of tag files.\nSeparate the names with a comma."
+    g:menutrans_tags_dialog = "Enter names of tag files.\nSeparate the names with a comma."
   endif
-  let n = inputdialog(g:menutrans_tags_dialog, substitute(&tags, '\\ ', ' ', 'g'))
+  var n = inputdialog(g:menutrans_tags_dialog, substitute(&tags, '\\ ', ' ', 'g'))
   if n != ""
-    let &tags = substitute(n, ' ', '\\ ', 'g')
+    &tags = substitute(n, ' ', '\\ ', 'g')
   endif
-endfun
+enddef
 
-fun! s:ToggleGuiOption(option)
-    " If a:option is already set in guioptions, then we want to remove it
-    if match(&guioptions, "\\C" . a:option) > -1
-	exec "set go-=" . a:option
-    else
-	exec "set go+=" . a:option
-    endif
-endfun
+def s:ToggleGuiOption(option: string)
+  # If a:option is already set in guioptions, then we want to remove it
+  if match(&guioptions, "\\C" .. option) > -1
+    exec "set go-=" .. option
+  else
+    exec "set go+=" .. option
+  endif
+enddef
 
 " Edit/File Settings
 
@@ -331,34 +325,36 @@ an 20.440.620.80 &Edit.F&ile\ Settings.S
 
 an <silent> 20.440.630 &Edit.F&ile\ Settings.Te&xt\ Width\.\.\.  :call <SID>TextWidth()<CR>
 an <silent> 20.440.640 &Edit.F&ile\ Settings.&File\ Format\.\.\.  :call <SID>FileFormat()<CR>
-fun! s:TextWidth()
+
+def s:TextWidth()
   if !exists("g:menutrans_textwidth_dialog")
-    let g:menutrans_textwidth_dialog = "Enter new text width (0 to disable formatting): "
+    g:menutrans_textwidth_dialog = "Enter new text width (0 to disable formatting): "
   endif
-  let n = inputdialog(g:menutrans_textwidth_dialog, &tw)
+  var n = inputdialog(g:menutrans_textwidth_dialog, &tw .. '')
   if n != ""
-    " Remove leading zeros to avoid it being used as an octal number.
-    " But keep a zero by itself.
-    let tw = substitute(n, "^0*", "", "")
-    let &tw = tw == '' ? 0 : tw
+    # Remove leading zeros to avoid it being used as an octal number.
+    # But keep a zero by itself.
+    var tw = substitute(n, "^0*", "", "")
+    &tw = tw == '' ? 0 : tw
   endif
-endfun
+enddef
 
-fun! s:FileFormat()
+def s:FileFormat()
   if !exists("g:menutrans_fileformat_dialog")
-    let g:menutrans_fileformat_dialog = "Select format for writing the file"
+    g:menutrans_fileformat_dialog = "Select format for writing the file"
   endif
   if !exists("g:menutrans_fileformat_choices")
-    let g:menutrans_fileformat_choices = "&Unix\n&Dos\n&Mac\n&Cancel"
+    g:menutrans_fileformat_choices = "&Unix\n&Dos\n&Mac\n&Cancel"
   endif
+  var def_choice: number
   if &ff == "dos"
-    let def = 2
+    def_choice = 2
   elseif &ff == "mac"
-    let def = 3
+    def_choice = 3
   else
-    let def = 1
+    def_choice = 1
   endif
-  let n = confirm(g:menutrans_fileformat_dialog, g:menutrans_fileformat_choices, def, "Question")
+  var n = confirm(g:menutrans_fileformat_dialog, g:menutrans_fileformat_choices, def_choice, "Question")
   if n == 1
     set ff=unix
   elseif n == 2
@@ -366,32 +362,33 @@ fun! s:FileFormat()
   elseif n == 3
     set ff=mac
   endif
-endfun
+enddef
 
 let s:did_setup_color_schemes = 0
 
 " Setup the Edit.Color Scheme submenu
-func s:SetupColorSchemes() abort
+def s:SetupColorSchemes()
   if s:did_setup_color_schemes
     return
   endif
-  let s:did_setup_color_schemes = 1
+  s:did_setup_color_schemes = 1
 
-  let n = globpath(&runtimepath, "colors/*.vim", 1, 1)
-  let n += globpath(&packpath, "pack/*/start/*/colors/*.vim", 1, 1)
-  let n += globpath(&packpath, "pack/*/opt/*/colors/*.vim", 1, 1)
+  var n = globpath(&runtimepath, "colors/*.vim", 1, 1)
+  n += globpath(&packpath, "pack/*/start/*/colors/*.vim", 1, 1)
+  n += globpath(&packpath, "pack/*/opt/*/colors/*.vim", 1, 1)
 
-  " Ignore case for VMS and windows, sort on name
-  let names = sort(map(n, 'substitute(v:val, "\\c.*[/\\\\:\\]]\\([^/\\\\:]*\\)\\.vim", "\\1", "")'), 1)
+  # Ignore case for VMS and windows, sort on name
+  var names = sort(map(n, 'substitute(v:val, "\\c.*[/\\\\:\\]]\\([^/\\\\:]*\\)\\.vim", "\\1", "")'), 1)
 
-  " define all the submenu entries
-  let idx = 100
+  # define all the submenu entries
+  var idx = 100
   for name in names
-    exe "an 20.450." . idx . ' &Edit.C&olor\ Scheme.' . name . " :colors " . name . "<CR>"
-    let idx = idx + 10
+    exe "an 20.450." .. idx .. ' &Edit.C&olor\ Scheme.' .. name .. " :colors " .. name .. "<CR>"
+    idx += 10
   endfor
   silent! aunmenu &Edit.Show\ C&olor\ Schemes\ in\ Menu
-endfun
+enddef
+
 if exists("do_no_lazyload_menus")
   call s:SetupColorSchemes()
 else
@@ -403,31 +400,33 @@ endif
 if has("keymap")
   let s:did_setup_keymaps = 0
 
-  func s:SetupKeymaps() abort
+  def s:SetupKeymaps()
     if s:did_setup_keymaps
       return
     endif
-    let s:did_setup_keymaps = 1
+    s:did_setup_keymaps = 1
 
-    let n = globpath(&runtimepath, "keymap/*.vim", 1, 1)
-    if !empty(n)
-      let idx = 100
+    var names = globpath(&runtimepath, "keymap/*.vim", 1, 1)
+    if !empty(names)
+      var idx = 100
       an 20.460.90 &Edit.&Keymap.None :set keymap=<CR>
-      for name in n
-	" Ignore case for VMS and windows
-	let name = substitute(name, '\c.*[/\\:\]]\([^/\\:_]*\)\(_[0-9a-zA-Z-]*\)\=\.vim', '\1', '')
-	exe "an 20.460." . idx . ' &Edit.&Keymap.' . name . " :set keymap=" . name . "<CR>"
-	let idx = idx + 10
+      for name in names
+	# Ignore case for VMS and windows
+	var mapname = substitute(name, '\c.*[/\\:\]]\([^/\\:_]*\)\(_[0-9a-zA-Z-]*\)\=\.vim', '\1', '')
+	exe "an 20.460." .. idx .. ' &Edit.&Keymap.' .. mapname .. " :set keymap=" .. mapname .. "<CR>"
+	idx += 10
       endfor
     endif
     silent! aunmenu &Edit.Show\ &Keymaps\ in\ Menu
-  endfun
+  enddef
+
   if exists("do_no_lazyload_menus")
     call s:SetupKeymaps()
   else
     an <silent> 20.460 &Edit.Show\ &Keymaps\ in\ Menu :call <SID>SetupKeymaps()<CR>
   endif
 endif
+
 if has("win32") || has("gui_motif") || has("gui_gtk") || has("gui_kde") || has("gui_photon") || has("gui_mac")
   an 20.470 &Edit.Select\ Fo&nt\.\.\.	:set guifont=*<CR>
 endif
@@ -445,7 +444,7 @@ an 40.300 &Tools.&Jump\ to\ This\ Tag<Ta
 vunmenu &Tools.&Jump\ to\ This\ Tag<Tab>g^]
 vnoremenu &Tools.&Jump\ to\ This\ Tag<Tab>g^]	g<C-]>
 an 40.310 &Tools.Jump\ &Back<Tab>^T		<C-T>
-an 40.320 &Tools.Build\ &Tags\ File		:exe "!" . g:ctags_command<CR>
+an 40.320 &Tools.Build\ &Tags\ File		:exe "!" .. g:ctags_command<CR>
 
 if has("folding") || has("spell")
   an 40.330 &Tools.-SEP1-						<Nop>
@@ -469,50 +468,47 @@ if has("spell")
   an <silent> 40.335.270 &Tools.&Spelling.&Find\ More\ Languages	:call <SID>SpellLang()<CR>
 
   let s:undo_spelllang = ['aun &Tools.&Spelling.&Find\ More\ Languages']
-  func s:SpellLang()
+  def s:SpellLang()
     for cmd in s:undo_spelllang
-      exe "silent! " . cmd
+      exe "silent! " .. cmd
     endfor
-    let s:undo_spelllang = []
+    s:undo_spelllang = []
 
-    if &enc == "iso-8859-15"
-      let enc = "latin1"
-    else
-      let enc = &enc
-    endif
+    var enc = &enc == "iso-8859-15" ? "latin1" : &enc
 
     if !exists("g:menutrans_set_lang_to")
-      let g:menutrans_set_lang_to = 'Set Language to'
+      g:menutrans_set_lang_to = 'Set Language to'
     endif
 
-    let found = 0
-    let s = globpath(&runtimepath, "spell/*." . enc . ".spl", 1, 1)
-    if !empty(s)
-      let n = 300
-      for f in s
-	let nm = substitute(f, '.*spell[/\\]\(..\)\.[^/\\]*\.spl', '\1', "")
+    var found = 0
+    var _nm = ''
+    var names = globpath(&runtimepath, "spell/*." .. enc .. ".spl", 1, 1)
+    if !empty(names)
+      var n = 300
+      for f in names
+	var nm = substitute(f, '.*spell[/\\]\(..\)\.[^/\\]*\.spl', '\1', "")
 	if nm != "en" && nm !~ '/'
-          let _nm = nm
-	  let found += 1
-	  let menuname = '&Tools.&Spelling.' . escape(g:menutrans_set_lang_to, "\\. \t|") . '\ "' . nm . '"'
-	  exe 'an 40.335.' . n . ' ' . menuname . ' :set spl=' . nm . ' spell<CR>'
-	  let s:undo_spelllang += ['aun ' . menuname]
+          _nm = nm
+	  found += 1
+	  var menuname = '&Tools.&Spelling.' .. escape(g:menutrans_set_lang_to, "\\. \t|") .. '\ "' .. nm .. '"'
+	  exe 'an 40.335.' .. n .. ' ' .. menuname .. ' :set spl=' .. nm .. ' spell<CR>'
+	  s:undo_spelllang += ['aun ' .. menuname]
 	endif
-	let n += 10
+	n += 10
       endfor
     endif
     if found == 0
       echomsg "Could not find other spell files"
     elseif found == 1
-      echomsg "Found spell file " . _nm
+      echomsg "Found spell file " .. _nm
     else
-      echomsg "Found " . found . " more spell files"
+      echomsg "Found " .. found .. " more spell files"
     endif
-    " Need to redo this when 'encoding' is changed.
+    # Need to redo this when 'encoding' is changed.
     augroup spellmenu
     au! EncodingChanged * call <SID>SpellLang()
     augroup END
-  endfun
+  enddef
 
 endif
 
@@ -581,66 +577,67 @@ an <silent> 40.540 &Tools.Conve&rt\ Back
 
 " Use a function to do the conversion, so that it also works with 'insertmode'
 " set.
-func s:XxdConv()
-  let mod = &mod
+def s:XxdConv()
+  var mod = &mod
   if has("vms")
-    %!mc vim:xxd
+    :%!mc vim:xxd
   else
-    call s:XxdFind()
-    exe '%!' . g:xxdprogram
+    s:XxdFind()
+    exe '%!' .. g:xxdprogram
   endif
-  if getline(1) =~ "^0000000:"		" only if it worked
+  if getline(1) =~ "^0000000:"		# only if it worked
     set ft=xxd
   endif
-  let &mod = mod
-endfun
+  &mod = mod
+enddef
 
-func s:XxdBack()
-  let mod = &mod
+def s:XxdBack()
+  var mod = &mod
   if has("vms")
-    %!mc vim:xxd -r
+    :%!mc vim:xxd -r
   else
-    call s:XxdFind()
-    exe '%!' . g:xxdprogram . ' -r'
+    s:XxdFind()
+    exe '%!' .. g:xxdprogram .. ' -r'
   endif
   set ft=
   doautocmd filetypedetect BufReadPost
-  let &mod = mod
-endfun
+  &mod = mod
+enddef
 
-func s:XxdFind()
+def s:XxdFind()
   if !exists("g:xxdprogram")
-    " On the PC xxd may not be in the path but in the install directory
+    # On the PC xxd may not be in the path but in the install directory
     if has("win32") && !executable("xxd")
-      let g:xxdprogram = $VIMRUNTIME . (&shellslash ? '/' : '\') . "xxd.exe"
+      g:xxdprogram = $VIMRUNTIME .. (&shellslash ? '/' : '\') .. "xxd.exe"
       if g:xxdprogram =~ ' '
-	let g:xxdprogram = '"' .. g:xxdprogram .. '"'
+	g:xxdprogram = '"' .. g:xxdprogram .. '"'
       endif
     else
-      let g:xxdprogram = "xxd"
+      g:xxdprogram = "xxd"
     endif
   endif
-endfun
+enddef
 
 let s:did_setup_compilers = 0
 
 " Setup the Tools.Compiler submenu
-func s:SetupCompilers() abort
+def s:SetupCompilers()
   if s:did_setup_compilers
     return
   endif
-  let s:did_setup_compilers = 1
+  s:did_setup_compilers = 1
 
-  let n = globpath(&runtimepath, "compiler/*.vim", 1, 1)
-  let idx = 100
-  for name in n
-    " Ignore case for VMS and windows
-    let name = substitute(name, '\c.*[/\\:\]]\([^/\\:]*\)\.vim', '\1', '')
-    exe "an 30.440." . idx . ' &Tools.Se&t\ Compiler.' . name . " :compiler " . name . "<CR>"
-    let idx = idx + 10
+  var names = globpath(&runtimepath, "compiler/*.vim", 1, 1)
+  var idx = 100
+  for name in names
+    # Ignore case for VMS and windows
+    var cname = substitute(name, '\c.*[/\\:\]]\([^/\\:]*\)\.vim', '\1', '')
+    exe "an 30.440." .. idx .. ' &Tools.Se&t\ Compiler.' .. cname .. " :compiler " .. cname .. "<CR>"
+    idx += 10
   endfor
   silent! aunmenu &Tools.Show\ Compiler\ Se&ttings\ in\ Menu
-endfun
+enddef
+
 if exists("do_no_lazyload_menus")
   call s:SetupCompilers()
 else
@@ -649,13 +646,13 @@ endif
 
 " Load ColorScheme, Compiler Setting and Keymap menus when idle.
 if !exists("do_no_lazyload_menus")
-  func s:SetupLazyloadMenus()
-    call s:SetupColorSchemes()
-    call s:SetupCompilers()
+  def s:SetupLazyloadMenus()
+    s:SetupColorSchemes()
+    s:SetupCompilers()
     if has("keymap")
-      call s:SetupKeymaps()
+      s:SetupKeymaps()
     endif
-  endfunc
+  enddef
   augroup SetupLazyloadMenus
     au!
     au CursorHold,CursorHoldI * call <SID>SetupLazyloadMenus() | au! SetupLazyloadMenus
@@ -680,135 +677,133 @@ if !exists("bmenu_priority")
 endif
 
 " invoked from a BufCreate or BufFilePost autocommand
-func s:BMAdd()
+def s:BMAdd()
   if s:bmenu_wait == 0
-    " when adding too many buffers, redraw in short format
+    # when adding too many buffers, redraw in short format
     if s:bmenu_count == &menuitems && s:bmenu_short == 0
-      call s:BMShow()
+      s:BMShow()
     else
-      let name = expand("<afile>")
-      let num = expand("<abuf>") + 0 " add zero to convert to a number type
+      var name = expand("<afile>")
+      var num = str2nr(expand("<abuf>"))
       if s:BMCanAdd(name, num)
-	call <SID>BMFilename(name, num)
-	let s:bmenu_count += 1
+	s:BMFilename(name, num)
+	s:bmenu_count += 1
       endif
     endif
   endif
-endfunc
+enddef
 
 " invoked from a BufDelete or BufFilePre autocommand
-func s:BMRemove()
+def s:BMRemove()
   if s:bmenu_wait == 0
-    let bufnum = expand("<abuf>")
+    var bufnum = expand("<abuf>")
     if s:bmenu_items->has_key(bufnum)
-      let menu_name = s:bmenu_items[bufnum]
-      exe 'silent! aun &Buffers.' . menu_name
-      let s:bmenu_count = s:bmenu_count - 1
+      var menu_name = s:bmenu_items[bufnum]
+      exe 'silent! aun &Buffers.' .. menu_name
+      s:bmenu_count = s:bmenu_count - 1
       unlet s:bmenu_items[bufnum]
     endif
   endif
-endfunc
+enddef
 
 " Return non-zero if buffer with number "name" / "num" is useful to add in the
 " buffer menu.
-func s:BMCanAdd(name, num)
-  " no directory or unlisted buffer
-  if isdirectory(a:name) || !buflisted(a:num)
-    return 0
-  endif
-
-  " no name with control characters
-  if a:name =~ '[\x01-\x1f]'
-    return 0
+def s:BMCanAdd(name: string, num: number): bool
+  # no directory or unlisted buffer
+  if isdirectory(name) || !buflisted(num)
+    return false
   endif
 
-  " no special buffer, such as terminal or popup
-  let buftype = getbufvar(a:num, '&buftype')
-  if buftype != '' && buftype != 'nofile' && buftype != 'nowrite'
-    return 0
+  # no name with control characters
+  if name =~ '[\x01-\x1f]'
+    return false
   endif
 
-  " only existing buffers
-  return bufexists(a:num)
-endfunc
-
-" Create the buffer menu (delete an existing one first).
-func s:BMShow(...)
-  let s:bmenu_wait = 1
-  let s:bmenu_short = 1
-  let s:bmenu_count = 0
-  let s:bmenu_items = {}
-  "
-  " get new priority, if exists
-  if a:0 == 1
-    let g:bmenu_priority = a:1
+  # no special buffer, such as terminal or popup
+  var buftype = getbufvar(num, '&buftype')
+  if buftype != '' && buftype != 'nofile' && buftype != 'nowrite'
+    return false
   endif
 
-  " Remove old menu, if it exists; keep one entry to avoid a torn off menu to
-  " disappear.  Use try/catch to avoid setting v:errmsg
-  try | unmenu &Buffers | catch | endtry
-  exe 'noremenu ' . g:bmenu_priority . ".1 &Buffers.Dummy l"
-  try | unmenu! &Buffers | catch | endtry
+  # only existing buffers
+  return bufexists(num)
+enddef
+
+" Create the buffer menu (delete an existing one first).
+def s:BMShow()
+  s:bmenu_wait = 1
+  s:bmenu_short = 1
+  s:bmenu_count = 0
+  s:bmenu_items = {}
 
-  " create new menu; set 'cpo' to include the <CR>
-  let cpo_save = &cpo
-  set cpo&vim
-  exe 'an <silent> ' . g:bmenu_priority . ".2 &Buffers.&Refresh\\ menu :call <SID>BMShow()<CR>"
-  exe 'an ' . g:bmenu_priority . ".4 &Buffers.&Delete :confirm bd<CR>"
-  exe 'an ' . g:bmenu_priority . ".6 &Buffers.&Alternate :confirm b #<CR>"
-  exe 'an ' . g:bmenu_priority . ".7 &Buffers.&Next :confirm bnext<CR>"
-  exe 'an ' . g:bmenu_priority . ".8 &Buffers.&Previous :confirm bprev<CR>"
-  exe 'an ' . g:bmenu_priority . ".9 &Buffers.-SEP- :"
-  let &cpo = cpo_save
+  # Remove old menu, if it exists; keep one entry to avoid a torn off menu to
+  # disappear.  Use try/catch to avoid setting v:errmsg
+  try 
+    unmenu &Buffers 
+  catch 
+  endtry
+  exe 'noremenu ' .. g:bmenu_priority .. ".1 &Buffers.Dummy l"
+  try 
+    unmenu! &Buffers 
+  catch 
+  endtry
+
+  # create new menu
+  exe 'an <silent> ' .. g:bmenu_priority .. ".2 &Buffers.&Refresh\\ menu :call <SID>BMShow()<CR>"
+  exe 'an ' .. g:bmenu_priority .. ".4 &Buffers.&Delete :confirm bd<CR>"
+  exe 'an ' .. g:bmenu_priority .. ".6 &Buffers.&Alternate :confirm b #<CR>"
+  exe 'an ' .. g:bmenu_priority .. ".7 &Buffers.&Next :confirm bnext<CR>"
+  exe 'an ' .. g:bmenu_priority .. ".8 &Buffers.&Previous :confirm bprev<CR>"
+  exe 'an ' .. g:bmenu_priority .. ".9 &Buffers.-SEP- :"
   unmenu &Buffers.Dummy
 
-  " figure out how many buffers there are
-  let buf = 1
+  # figure out how many buffers there are
+  var buf = 1
   while buf <= bufnr('$')
     if s:BMCanAdd(bufname(buf), buf)
-      let s:bmenu_count = s:bmenu_count + 1
+      s:bmenu_count = s:bmenu_count + 1
     endif
-    let buf = buf + 1
+    buf += 1
   endwhile
   if s:bmenu_count <= &menuitems
-    let s:bmenu_short = 0
+    s:bmenu_short = 0
   endif
 
-  " iterate through buffer list, adding each buffer to the menu:
-  let buf = 1
+  # iterate through buffer list, adding each buffer to the menu:
+  buf = 1
   while buf <= bufnr('$')
-    let name = bufname(buf)
+    var name = bufname(buf)
     if s:BMCanAdd(name, buf)
-      call <SID>BMFilename(name, buf)
+      call s:BMFilename(name, buf)
     endif
-    let buf = buf + 1
+    buf += 1
   endwhile
-  let s:bmenu_wait = 0
+  s:bmenu_wait = 0
   aug buffer_list
-  au!
-  au BufCreate,BufFilePost * call <SID>BMAdd()
-  au BufDelete,BufFilePre * call <SID>BMRemove()
+    au!
+    au BufCreate,BufFilePost * call s:BMAdd()
+    au BufDelete,BufFilePre * call s:BMRemove()
   aug END
-endfunc
+enddef
 
-func s:BMHash(name)
-  " Make name all upper case, so that chars are between 32 and 96
-  let nm = substitute(a:name, ".*", '\U\0', "")
+def s:BMHash(name: string): number
+  # Make name all upper case, so that chars are between 32 and 96
+  var nm = substitute(name, ".*", '\U\0', "")
+  var sp: number
   if has("ebcdic")
-    " HACK: Replace all non alphabetics with 'Z'
-    "       Just to make it work for now.
-    let nm = substitute(nm, "[^A-Z]", 'Z', "g")
-    let sp = char2nr('A') - 1
+    # HACK: Replace all non alphabetics with 'Z'
+    #       Just to make it work for now.
+    nm = substitute(nm, "[^A-Z]", 'Z', "g")
+    sp = char2nr('A') - 1
   else
-    let sp = char2nr(' ')
+    sp = char2nr(' ')
   endif
-  " convert first six chars into a number for sorting:
+  # convert first six chars into a number for sorting:
   return (char2nr(nm[0]) - sp) * 0x800000 + (char2nr(nm[1]) - sp) * 0x20000 + (char2nr(nm[2]) - sp) * 0x1000 + (char2nr(nm[3]) - sp) * 0x80 + (char2nr(nm[4]) - sp) * 0x20 + (char2nr(nm[5]) - sp)
-endfunc
+enddef
 
-func s:BMHash2(name)
-  let nm = substitute(a:name, ".", '\L\0', "")
-  " Not exactly right for EBCDIC...
+def s:BMHash2(name: string): string
+  var nm = substitute(name, ".", '\L\0', "")
   if nm[0] < 'a' || nm[0] > 'z'
     return '&others.'
   elseif nm[0] <= 'd'
@@ -824,72 +819,70 @@ func s:BMHash2(name)
   else
     return '&u-z.'
   endif
-endfunc
+enddef
 
 " Insert a buffer name into the buffer menu.
-func s:BMFilename(name, num)
-  let munge = <SID>BMMunge(a:name, a:num)
-  let hash = <SID>BMHash(munge)
+def s:BMFilename(name: string, num: number)
+  var munge = s:BMMunge(name, num)
+  var hash = s:BMHash(munge)
+  var cmd: string
   if s:bmenu_short == 0
-    let s:bmenu_items[a:num] = munge
-    let cmd = 'an ' . g:bmenu_priority . '.' . hash . ' &Buffers.' . munge
+    s:bmenu_items[num] = munge
+    cmd = 'an ' .. g:bmenu_priority .. '.' .. hash .. ' &Buffers.' .. munge
   else
-    let menu_name = <SID>BMHash2(munge) . munge
-    let s:bmenu_items[a:num] = menu_name
-    let cmd = 'an ' . g:bmenu_priority . '.' . hash . '.' . hash . ' &Buffers.' . menu_name
+    var menu_name = s:BMHash2(munge) .. munge
+    s:bmenu_items[num] = menu_name
+    cmd = 'an ' .. g:bmenu_priority .. '.' .. hash .. '.' .. hash .. ' &Buffers.' .. menu_name
   endif
-  " set 'cpo' to include the <CR>
-  let cpo_save = &cpo
-  set cpo&vim
-  exe cmd . ' :confirm b' . a:num . '<CR>'
-  let &cpo = cpo_save
-endfunc
+  exe cmd .. ' :confirm b' .. num .. '<CR>'
+enddef
 
 " Truncate a long path to fit it in a menu item.
 if !exists("g:bmenu_max_pathlen")
   let g:bmenu_max_pathlen = 35
 endif
-func s:BMTruncName(fname)
-  let name = a:fname
+
+def s:BMTruncName(fname: string): string
+  var name = fname
   if g:bmenu_max_pathlen < 5
-    let name = ""
+    name = ""
   else
-    let len = strlen(name)
+    var len = strlen(name)
     if len > g:bmenu_max_pathlen
-      let amountl = (g:bmenu_max_pathlen / 2) - 2
-      let amountr = g:bmenu_max_pathlen - amountl - 3
-      let pattern = '^\(.\{,' . amountl . '}\).\{-}\(.\{,' . amountr . '}\)$'
-      let left = substitute(name, pattern, '\1', '')
-      let right = substitute(name, pattern, '\2', '')
+      var amountl = (g:bmenu_max_pathlen / 2) - 2
+      var amountr = g:bmenu_max_pathlen - amountl - 3
+      var pattern = '^\(.\{,' .. amountl .. '}\).\{-}\(.\{,' .. amountr .. '}\)$'
+      var left = substitute(name, pattern, '\1', '')
+      var right = substitute(name, pattern, '\2', '')
       if strlen(left) + strlen(right) < len
-	let name = left . '...' . right
+	name = left .. '...' .. right
       endif
     endif
   endif
   return name
-endfunc
+enddef
 
-func s:BMMunge(fname, bnum)
-  let name = a:fname
+def s:BMMunge(fname: string, bnum: number): string
+  var name = fname
   if name == ''
     if !exists("g:menutrans_no_file")
-      let g:menutrans_no_file = "[No Name]"
+      g:menutrans_no_file = "[No Name]"
     endif
-    let name = g:menutrans_no_file
+    name = g:menutrans_no_file
   else
-    let name = fnamemodify(name, ':p:~')
+    name = fnamemodify(name, ':p:~')
   endif
-  " detach file name and separate it out:
-  let name2 = fnamemodify(name, ':t')
-  if a:bnum >= 0
-    let name2 = name2 . ' (' . a:bnum . ')'
+  # detach file name and separate it out:
+  var name2 = fnamemodify(name, ':t')
+  if bnum >= 0
+    name2 = name2 .. ' (' .. bnum .. ')'
   endif
-  let name = name2 . "\t" . <SID>BMTruncName(fnamemodify(name,':h'))
-  let name = escape(name, "\\. \t|")
-  let name = substitute(name, "&", "&&", "g")
-  let name = substitute(name, "\n", "^@", "g")
+  name = name2 .. "\t" .. s:BMTruncName(fnamemodify(name, ':h'))
+  name = escape(name, "\\. \t|")
+  name = substitute(name, "&", "&&", "g")
+  name = substitute(name, "\n", "^@", "g")
   return name
-endfunc
+enddef
 
 " When just starting Vim, load the buffer menu later
 if has("vim_starting")
@@ -910,13 +903,13 @@ an 70.320 &Window.Sp&lit\ To\ #<Tab>^W^^
 an 70.330 &Window.Split\ &Vertically<Tab>^Wv	<C-W>v
 an <silent> 70.332 &Window.Split\ File\ E&xplorer	:call MenuExplOpen()<CR>
 if !exists("*MenuExplOpen")
-  fun MenuExplOpen()
+  def MenuExplOpen()
     if @% == ""
-      20vsp .
+      :20vsp .
     else
-      exe "20vsp " . s:FnameEscape(expand("%:p:h"))
+      exe ":20vsp " .. fnameescape(expand("%:p:h"))
     endif
-  endfun
+  enddef
 endif
 an 70.335 &Window.-SEP1-				<Nop>
 an 70.340 &Window.&Close<Tab>^Wc			:confirm close<CR>
@@ -943,8 +936,8 @@ vnoremenu 1.30 PopUp.&Copy		"+y
 cnoremenu 1.30 PopUp.&Copy		<C-Y>
 nnoremenu 1.40 PopUp.&Paste		"+gP
 cnoremenu 1.40 PopUp.&Paste		<C-R>+
-exe 'vnoremenu <script> 1.40 PopUp.&Paste	' . paste#paste_cmd['v']
-exe 'inoremenu <script> 1.40 PopUp.&Paste	' . paste#paste_cmd['i']
+exe 'vnoremenu <script> 1.40 PopUp.&Paste	' .. paste#paste_cmd['v']
+exe 'inoremenu <script> 1.40 PopUp.&Paste	' .. paste#paste_cmd['i']
 vnoremenu 1.50 PopUp.&Delete		x
 an 1.55 PopUp.-SEP2-			<Nop>
 vnoremenu 1.60 PopUp.Select\ Blockwise	<C-V>
@@ -986,77 +979,75 @@ cnoremenu <script> <silent> 1.100 PopUp.
 if has("spell")
   " Spell suggestions in the popup menu.  Note that this will slow down the
   " appearance of the menu!
-  func s:SpellPopup()
+  def s:SpellPopup()
     if exists("s:changeitem") && s:changeitem != ''
-      call <SID>SpellDel()
+      call s:SpellDel()
     endif
 
-    " Return quickly if spell checking is not enabled.
+    # Return quickly if spell checking is not enabled.
     if !&spell || &spelllang == ''
       return
     endif
 
-    let curcol = col('.')
-    let [w, a] = spellbadword()
-    if col('.') > curcol		" don't use word after the cursor
-      let w = ''
+    var curcol = col('.')
+    var w: string
+    var a: string
+    [w, a] = spellbadword()
+    if col('.') > curcol		# don't use word after the cursor
+      w = ''
     endif
     if w != ''
       if a == 'caps'
-	let s:suglist = [substitute(w, '.*', '\u&', '')]
+	s:suglist = [substitute(w, '.*', '\u&', '')]
       else
-	let s:suglist = spellsuggest(w, 10)
+	s:suglist = spellsuggest(w, 10)
       endif
       if len(s:suglist) > 0
 	if !exists("g:menutrans_spell_change_ARG_to")
-	  let g:menutrans_spell_change_ARG_to = 'Change\ "%s"\ to'
+	  g:menutrans_spell_change_ARG_to = 'Change\ "%s"\ to'
 	endif
-	let s:changeitem = printf(g:menutrans_spell_change_ARG_to, escape(w, ' .'))
-	let s:fromword = w
-	let pri = 1
-	" set 'cpo' to include the <CR>
-	let cpo_save = &cpo
-	set cpo&vim
+	s:changeitem = printf(g:menutrans_spell_change_ARG_to, escape(w, ' .'))
+	s:fromword = w
+	var pri = 1
 	for sug in s:suglist
-	  exe 'anoremenu 1.5.' . pri . ' PopUp.' . s:changeitem . '.' . escape(sug, ' .')
-		\ . ' :call <SID>SpellReplace(' . pri . ')<CR>'
-	  let pri += 1
+	  exe 'anoremenu 1.5.' .. pri .. ' PopUp.' .. s:changeitem .. '.' .. escape(sug, ' .')
+		\ .. ' :call <SID>SpellReplace(' .. pri .. ')<CR>'
+	  pri += 1
 	endfor
 
 	if !exists("g:menutrans_spell_add_ARG_to_word_list")
-	  let g:menutrans_spell_add_ARG_to_word_list = 'Add\ "%s"\ to\ Word\ List'
+	  g:menutrans_spell_add_ARG_to_word_list = 'Add\ "%s"\ to\ Word\ List'
 	endif
-	let s:additem = printf(g:menutrans_spell_add_ARG_to_word_list, escape(w, ' .'))
-	exe 'anoremenu 1.6 PopUp.' . s:additem . ' :spellgood ' . w . '<CR>'
+	s:additem = printf(g:menutrans_spell_add_ARG_to_word_list, escape(w, ' .'))
+	exe 'anoremenu 1.6 PopUp.' .. s:additem .. ' :spellgood ' .. w .. '<CR>'
 
 	if !exists("g:menutrans_spell_ignore_ARG")
-	  let g:menutrans_spell_ignore_ARG = 'Ignore\ "%s"'
+	  g:menutrans_spell_ignore_ARG = 'Ignore\ "%s"'
 	endif
-	let s:ignoreitem = printf(g:menutrans_spell_ignore_ARG, escape(w, ' .'))
-	exe 'anoremenu 1.7 PopUp.' . s:ignoreitem . ' :spellgood! ' . w . '<CR>'
+	s:ignoreitem = printf(g:menutrans_spell_ignore_ARG, escape(w, ' .'))
+	exe 'anoremenu 1.7 PopUp.' .. s:ignoreitem .. ' :spellgood! ' .. w .. '<CR>'
 
 	anoremenu 1.8 PopUp.-SpellSep- :
-	let &cpo = cpo_save
       endif
     endif
-    call cursor(0, curcol)	" put the cursor back where it was
-  endfunc
+    call cursor(0, curcol)	# put the cursor back where it was
+  enddef
 
-  func s:SpellReplace(n)
-    let l = getline('.')
-    " Move the cursor to the start of the word.
+  def s:SpellReplace(n: number)
+    var l = getline('.')
+    # Move the cursor to the start of the word.
     call spellbadword()
-    call setline('.', strpart(l, 0, col('.') - 1) . s:suglist[a:n - 1]
-	  \ . strpart(l, col('.') + len(s:fromword) - 1))
-  endfunc
+    call setline('.', strpart(l, 0, col('.') - 1) .. s:suglist[n - 1]
+	  \ .. strpart(l, col('.') + len(s:fromword) - 1))
+  enddef
 
-  func s:SpellDel()
-    exe "aunmenu PopUp." . s:changeitem
-    exe "aunmenu PopUp." . s:additem
-    exe "aunmenu PopUp." . s:ignoreitem
+  def s:SpellDel()
+    exe "aunmenu PopUp." .. s:changeitem
+    exe "aunmenu PopUp." .. s:additem
+    exe "aunmenu PopUp." .. s:ignoreitem
     aunmenu PopUp.-SpellSep-
-    let s:changeitem = ''
-  endfun
+    s:changeitem = ''
+  enddef
 
   augroup SpellPopupMenu
     au! MenuPopup * call <SID>SpellPopup()
@@ -1089,8 +1080,8 @@ if has("toolbar")
   cnoremenu 1.80 ToolBar.Copy		<C-Y>
   nnoremenu 1.90 ToolBar.Paste		"+gP
   cnoremenu	 ToolBar.Paste		<C-R>+
-  exe 'vnoremenu <script>	 ToolBar.Paste	' . paste#paste_cmd['v']
-  exe 'inoremenu <script>	 ToolBar.Paste	' . paste#paste_cmd['i']
+  exe 'vnoremenu <script>	 ToolBar.Paste	' .. paste#paste_cmd['v']
+  exe 'inoremenu <script>	 ToolBar.Paste	' .. paste#paste_cmd['i']
 
   if !has("gui_athena")
     an 1.95   ToolBar.-sep3-		<Nop>
@@ -1108,7 +1099,7 @@ if has("toolbar")
 
   an 1.245 ToolBar.-sep6-		<Nop>
   an 1.250 ToolBar.Make			:make<CR>
-  an 1.270 ToolBar.RunCtags		:exe "!" . g:ctags_command<CR>
+  an 1.270 ToolBar.RunCtags		:exe "!" .. g:ctags_command<CR>
   an 1.280 ToolBar.TagJump		g<C-]>
 
   an 1.295 ToolBar.-sep7-		<Nop>
@@ -1145,22 +1136,23 @@ else
 endif
 
 " Select a session to load; default to current session name if present
-fun! s:LoadVimSesn()
+def s:LoadVimSesn()
+  var name: string
   if strlen(v:this_session) > 0
-    let name = s:FnameEscape(v:this_session)
+    name = fnameescape(v:this_session)
   else
-    let name = "Session.vim"
+    name = "Session.vim"
   endif
-  execute "browse so " . name
-endfun
+  execute "browse so " .. name
+enddef
 
 " Select a session to save; default to current session name if present
-fun! s:SaveVimSesn()
+def s:SaveVimSesn()
   if strlen(v:this_session) == 0
-    let v:this_session = "Session.vim"
+    v:this_session = "Session.vim"
   endif
-  execute "browse mksession! " . s:FnameEscape(v:this_session)
-endfun
+  execute "browse mksession! " .. fnameescape(v:this_session)
+enddef
 
 endif
 
@@ -1173,7 +1165,7 @@ if !exists("did_install_syntax_menu")
   an 50.214 &Syntax.A&utomatic		:syn on<CR>
   an <silent> 50.216 &Syntax.On/Off\ for\ &This\ File :call <SID>SynOnOff()<CR>
   if !exists("*s:SynOnOff")
-    fun s:SynOnOff()
+    def s:SynOnOff()
       if has("syntax_items")
 	syn clear
       else
@@ -1182,7 +1174,7 @@ if !exists("did_install_syntax_menu")
 	endif
 	set syn=ON
       endif
-    endfun
+    enddef
   endif
 endif
 
@@ -1209,6 +1201,9 @@ an 50.710 &Syntax.Co&lor\ Test		:sp $VIM
 an 50.720 &Syntax.&Highlight\ Test	:runtime syntax/hitest.vim<CR>
 an 50.730 &Syntax.&Convert\ to\ HTML	:runtime syntax/2html.vim<CR>
 
+" Uncomment this to compile the functions early to find any mistakes
+defcompile
+
 endif " !exists("did_install_syntax_menu")
 
 " Restore the previous value of 'cpoptions'.
--- a/runtime/synmenu.vim
+++ b/runtime/synmenu.vim
@@ -2,31 +2,26 @@
 " This file is normally sourced from menu.vim.
 "
 " Maintainer:	Bram Moolenaar <Bram@vim.org>
-" Last Change:	2017 Oct 28
+" Last Change:	2022 Feb 04
 
 " Define the SetSyn function, used for the Syntax menu entries.
 " Set 'filetype' and also 'syntax' if it is manually selected.
-fun! SetSyn(name)
-  if a:name == "fvwm1"
-    let use_fvwm_1 = 1
-    let use_fvwm_2 = 0
-    let name = "fvwm"
-  elseif a:name == "fvwm2"
-    let use_fvwm_2 = 1
-    let use_fvwm_1 = 0
-    let name = "fvwm"
-  else
-    let name = a:name
+def SetSyn(name: string)
+  var filetype = name
+  if name == "fvwm1" || name == "fvwm2"
+    g:use_fvwm_1 = name == "fvwm1"
+    g:use_fvwm_2 = name == "fvwm2"
+    filetype = "fvwm"
   endif
   if !exists("s:syntax_menu_synonly")
-    exe "set ft=" . name
+    exe "set ft=" .. filetype
     if exists("g:syntax_manual")
-      exe "set syn=" . name
+      exe "set syn=" .. filetype
     endif
   else
-    exe "set syn=" . name
+    exe "set syn=" .. filetype
   endif
-endfun
+enddef
 
 " <> notation is used here, remove '<' from 'cpoptions'
 let s:cpo_save = &cpo
@@ -404,7 +399,6 @@ an 50.90.120 &Syntax.PQ.Pam\ config :cal
 an 50.90.130 &Syntax.PQ.PApp :cal SetSyn("papp")<CR>
 an 50.90.140 &Syntax.PQ.Pascal :cal SetSyn("pascal")<CR>
 an 50.90.150 &Syntax.PQ.Password\ file :cal SetSyn("passwd")<CR>
-an 50.90.490 &Syntax.PQ.Pbtxt :cal SetSyn("pbtxt")<CR>
 an 50.90.160 &Syntax.PQ.PCCTS :cal SetSyn("pccts")<CR>
 an 50.90.170 &Syntax.PQ.PDF :cal SetSyn("pdf")<CR>
 an 50.90.180 &Syntax.PQ.Perl.Perl :cal SetSyn("perl")<CR>
@@ -457,19 +451,20 @@ an 50.100.180 &Syntax.R.RCS.RCS\ file :c
 an 50.100.190 &Syntax.R.Readline\ config :cal SetSyn("readline")<CR>
 an 50.100.200 &Syntax.R.Rebol :cal SetSyn("rebol")<CR>
 an 50.100.210 &Syntax.R.ReDIF :cal SetSyn("redif")<CR>
-an 50.100.220 &Syntax.R.Relax\ NG :cal SetSyn("rng")<CR>
-an 50.100.230 &Syntax.R.Remind :cal SetSyn("remind")<CR>
-an 50.100.240 &Syntax.R.Relax\ NG\ compact :cal SetSyn("rnc")<CR>
-an 50.100.250 &Syntax.R.Renderman.Renderman\ Shader\ Lang :cal SetSyn("sl")<CR>
-an 50.100.260 &Syntax.R.Renderman.Renderman\ Interface\ Bytestream :cal SetSyn("rib")<CR>
-an 50.100.270 &Syntax.R.Resolv\.conf :cal SetSyn("resolv")<CR>
-an 50.100.280 &Syntax.R.Reva\ Forth :cal SetSyn("reva")<CR>
-an 50.100.290 &Syntax.R.Rexx :cal SetSyn("rexx")<CR>
-an 50.100.300 &Syntax.R.Robots\.txt :cal SetSyn("robots")<CR>
-an 50.100.310 &Syntax.R.RockLinux\ package\ desc\. :cal SetSyn("desc")<CR>
-an 50.100.320 &Syntax.R.Rpcgen :cal SetSyn("rpcgen")<CR>
-an 50.100.330 &Syntax.R.RPL/2 :cal SetSyn("rpl")<CR>
-an 50.100.340 &Syntax.R.ReStructuredText :cal SetSyn("rst")<CR>
+an 50.100.220 &Syntax.R.Rego :cal SetSyn("rego")<CR>
+an 50.100.230 &Syntax.R.Relax\ NG :cal SetSyn("rng")<CR>
+an 50.100.240 &Syntax.R.Remind :cal SetSyn("remind")<CR>
+an 50.100.250 &Syntax.R.Relax\ NG\ compact :cal SetSyn("rnc")<CR>
+an 50.100.260 &Syntax.R.Renderman.Renderman\ Shader\ Lang :cal SetSyn("sl")<CR>
+an 50.100.270 &Syntax.R.Renderman.Renderman\ Interface\ Bytestream :cal SetSyn("rib")<CR>
+an 50.100.280 &Syntax.R.Resolv\.conf :cal SetSyn("resolv")<CR>
+an 50.100.290 &Syntax.R.Reva\ Forth :cal SetSyn("reva")<CR>
+an 50.100.300 &Syntax.R.Rexx :cal SetSyn("rexx")<CR>
+an 50.100.310 &Syntax.R.Robots\.txt :cal SetSyn("robots")<CR>
+an 50.100.320 &Syntax.R.RockLinux\ package\ desc\. :cal SetSyn("desc")<CR>
+an 50.100.330 &Syntax.R.Rpcgen :cal SetSyn("rpcgen")<CR>
+an 50.100.340 &Syntax.R.RPL/2 :cal SetSyn("rpl")<CR>
+an 50.100.350 &Syntax.R.ReStructuredText :cal SetSyn("rst")<CR>
 an 50.110.100 &Syntax.M.ReStructuredText\ with\ R\ statements :cal SetSyn("rrst")<CR>
 an 50.120.100 &Syntax.R.RTF :cal SetSyn("rtf")<CR>
 an 50.120.110 &Syntax.R.Ruby :cal SetSyn("ruby")<CR>
@@ -652,11 +647,11 @@ an 50.170.440 &Syntax.WXYZ.Zimbu :cal Se
 an 50.195 &Syntax.-SEP1-			<Nop>
 
 an <silent> 50.200 &Syntax.Set\ '&syntax'\ Only :call <SID>Setsynonly()<CR>
-fun! s:Setsynonly()
+fun s:Setsynonly()
   let s:syntax_menu_synonly = 1
 endfun
 an <silent> 50.202 &Syntax.Set\ '&filetype'\ Too :call <SID>Nosynonly()<CR>
-fun! s:Nosynonly()
+fun s:Nosynonly()
   if exists("s:syntax_menu_synonly")
     unlet s:syntax_menu_synonly
   endif