To: vim_dev@googlegroups.com Subject: Patch 8.2.1652 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1652 Problem: Cannot translate lines in the options window. Solution: Use the AddOption() function to split descriptions where indicated by a line break. (issue #6800) Files: runtime/optwin.vim *** ../vim-8.2.1651/runtime/optwin.vim 2020-09-09 15:10:48.460213889 +0200 --- runtime/optwin.vim 2020-09-10 14:24:28.392689581 +0200 *************** *** 1,7 **** " These commands create the option window. " " Maintainer: Bram Moolenaar ! " Last Change: 2020 aug 30 " If there already is an option window, jump to that one. let buf = bufnr('option-window') --- 1,7 ---- " These commands create the option window. " " Maintainer: Bram Moolenaar ! " Last Change: 2020 Sep 10 " If there already is an option window, jump to that one. let buf = bufnr('option-window') *************** *** 20,26 **** set cpo&vim " function to be called when is hit in the option-window ! fun! CR() " If on a continued comment line, go back to the first comment line let lnum = search("^[^\t]", 'bWcn') --- 20,26 ---- set cpo&vim " function to be called when is hit in the option-window ! func CR() " If on a continued comment line, go back to the first comment line let lnum = search("^[^\t]", 'bWcn') *************** *** 47,56 **** elseif match(line, '^ \=[0-9]') >= 0 exe "norm! /" . line . "\zt" endif ! endfun " function to be called when is hit in the option-window ! fun! Space() let lnum = line(".") let line = getline(lnum) --- 47,56 ---- elseif match(line, '^ \=[0-9]') >= 0 exe "norm! /" . line . "\zt" endif ! endfunc " function to be called when is hit in the option-window ! func Space() let lnum = line(".") let line = getline(lnum) *************** *** 67,80 **** endif endif ! endfun let s:local_to_window = gettext('(local to window)') let s:local_to_buffer = gettext('(local to buffer)') " find the window in which the option applies " returns 0 for global option, 1 for local option, -1 for error ! fun! Find(lnum) let line = getline(a:lnum - 1) if line =~ s:local_to_window || line =~ s:local_to_buffer let local = 1 --- 67,80 ---- endif endif ! endfunc let s:local_to_window = gettext('(local to window)') let s:local_to_buffer = gettext('(local to buffer)') " find the window in which the option applies " returns 0 for global option, 1 for local option, -1 for error ! func Find(lnum) let line = getline(a:lnum - 1) if line =~ s:local_to_window || line =~ s:local_to_buffer let local = 1 *************** *** 95,104 **** let local = -1 endif return local ! endfun " Update a "set" line in the option window ! fun! Update(lnum, line, local, thiswin) " get the new value of the option and update the option window line if match(a:line, "=") >= 0 let name = substitute(a:line, '^ \tset \([^=]*\)=.*', '\1', "") --- 95,104 ---- let local = -1 endif return local ! endfunc " Update a "set" line in the option window ! func Update(lnum, line, local, thiswin) " get the new value of the option and update the option window line if match(a:line, "=") >= 0 let name = substitute(a:line, '^ \tset \([^=]*\)=.*', '\1', "") *************** *** 123,129 **** endif endif set nomodified ! endfun " Reset 'title' and 'icon' to make it work faster. " Reset 'undolevels' to avoid undo'ing until the buffer is empty. --- 123,129 ---- endif endif set nomodified ! endfunc " Reset 'title' and 'icon' to make it work faster. " Reset 'undolevels' to avoid undo'ing until the buffer is empty. *************** *** 159,193 **** " These functions are called often below. Keep them fast! " Init a local binary option ! fun! BinOptionL(name) let val = getwinvar(winnr('#'), '&' . a:name) call append("$", substitute(substitute(" \tset " . val . a:name . "\t" . \!val . a:name, "0", "no", ""), "1", "", "")) ! endfun " Init a global binary option ! fun! BinOptionG(name, val) call append("$", substitute(substitute(" \tset " . a:val . a:name . "\t" . \!a:val . a:name, "0", "no", ""), "1", "", "")) ! endfun " Init a local string option ! fun! OptionL(name) let val = escape(getwinvar(winnr('#'), '&' . a:name), " \t\\\"|") call append("$", " \tset " . a:name . "=" . val) ! endfun " Init a global string option ! fun! OptionG(name, val) call append("$", " \tset " . a:name . "=" . escape(a:val, " \t\\\"|")) ! endfun let s:idx = 1 let s:lnum = line("$") call append("$", "") ! fun! Header(text) let line = s:idx . " " . a:text if s:idx < 10 let line = " " . line --- 159,203 ---- " These functions are called often below. Keep them fast! + " Add an option name and explanation. The text can contain "\n" characters + " where a line break is to be inserted. + func AddOption(name, text) + let lines = split(a:text, "\n") + call append("$", a:name .. "\t" .. lines[0]) + for line in lines[1:] + call append("$", "\t" .. line) + endfor + endfunc + " Init a local binary option ! func BinOptionL(name) let val = getwinvar(winnr('#'), '&' . a:name) call append("$", substitute(substitute(" \tset " . val . a:name . "\t" . \!val . a:name, "0", "no", ""), "1", "", "")) ! endfunc " Init a global binary option ! func BinOptionG(name, val) call append("$", substitute(substitute(" \tset " . a:val . a:name . "\t" . \!a:val . a:name, "0", "no", ""), "1", "", "")) ! endfunc " Init a local string option ! func OptionL(name) let val = escape(getwinvar(winnr('#'), '&' . a:name), " \t\\\"|") call append("$", " \tset " . a:name . "=" . val) ! endfunc " Init a global string option ! func OptionG(name, val) call append("$", " \tset " . a:name . "=" . escape(a:val, " \t\\\"|")) ! endfunc let s:idx = 1 let s:lnum = line("$") call append("$", "") ! func Header(text) let line = s:idx . " " . a:text if s:idx < 10 let line = " " . line *************** *** 198,212 **** call append(s:lnum, line) let s:idx = s:idx + 1 let s:lnum = s:lnum + 1 ! endfun " Get the value of 'pastetoggle'. It could be a special key. ! fun! PTvalue() redir @a silent set pt redir END return substitute(@a, '[^=]*=\(.*\)', '\1', "") ! endfun " Restore the previous value of 'cpoptions' here, it's used below. let &cpo = s:cpo_save --- 208,222 ---- call append(s:lnum, line) let s:idx = s:idx + 1 let s:lnum = s:lnum + 1 ! endfunc " Get the value of 'pastetoggle'. It could be a special key. ! func PTvalue() redir @a silent set pt redir END return substitute(@a, '[^=]*=\(.*\)', '\1', "") ! endfunc " Restore the previous value of 'cpoptions' here, it's used below. let &cpo = s:cpo_save *************** *** 240,247 **** call Header("moving around, searching and patterns") call append("$", "whichwrap\tlist of flags specifying which commands wrap to another line") call OptionG("ww", &ww) ! call append("$", "startofline\tmany jump commands move the cursor to the first non-blank") ! call append("$", "\tcharacter of a line") call BinOptionG("sol", &sol) call append("$", "paragraphs\tnroff macro names that separate paragraphs") call OptionG("para", ¶) --- 250,256 ---- call Header("moving around, searching and patterns") call append("$", "whichwrap\tlist of flags specifying which commands wrap to another line") call OptionG("ww", &ww) ! call AddOption("startofline", gettext("many jump commands move the cursor to the first non-blank\ncharacter of a line")) call BinOptionG("sol", &sol) call append("$", "paragraphs\tnroff macro names that separate paragraphs") call OptionG("para", ¶) *************** *** 286,300 **** call Header("tags") ! call append("$", "tagbsearch\tuse binary searching in tags files") call BinOptionG("tbs", &tbs) call append("$", "taglength\tnumber of significant characters in a tag name or zero") call append("$", " \tset tl=" . &tl) call append("$", "tags\tlist of file names to search for tags") call append("$", "\t(global or local to buffer)") call OptionG("tag", &tag) ! call append("$", "tagcase\thow to handle case when searching in tags files:") ! call append("$", "\t\"followic\" to follow 'ignorecase', \"ignore\" or \"match\"") call append("$", "\t(global or local to buffer)") call OptionG("tc", &tc) call append("$", "tagrelative\tfile names in a tags file are relative to the tags file") --- 295,308 ---- call Header("tags") ! call AddOption("tagbsearch", gettext("use binary searching in tags files")) call BinOptionG("tbs", &tbs) call append("$", "taglength\tnumber of significant characters in a tag name or zero") call append("$", " \tset tl=" . &tl) call append("$", "tags\tlist of file names to search for tags") call append("$", "\t(global or local to buffer)") call OptionG("tag", &tag) ! call AddOption("tagcase", gettext("how to handle case when searching in tags files:\n\"followic\" to follow 'ignorecase', \"ignore\" or \"match\"")) call append("$", "\t(global or local to buffer)") call OptionG("tc", &tc) call append("$", "tagrelative\tfile names in a tags file are relative to the tags file") *************** *** 1446,1452 **** \ call unload() | delfun unload augroup END ! fun! unload() delfun CR delfun Space delfun Find --- 1454,1460 ---- \ call unload() | delfun unload augroup END ! func unload() delfun CR delfun Space delfun Find *************** *** 1457,1463 **** delfun BinOptionG delfun Header au! optwin ! endfun " Restore the previous value of 'title' and 'icon'. let &title = s:old_title --- 1465,1471 ---- delfun BinOptionG delfun Header au! optwin ! endfunc " Restore the previous value of 'title' and 'icon'. let &title = s:old_title *** ../vim-8.2.1651/src/version.c 2020-09-09 22:43:15.362693356 +0200 --- src/version.c 2020-09-10 14:23:04.872920089 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 1652, /**/ -- LAUNCELOT: Isn't there a St. Aaaaarrrrrrggghhh's in Cornwall? ARTHUR: No, that's Saint Ives. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///