vim9 script lambda

34 views
Skip to first unread message

Ni Va

unread,
Jan 16, 2022, 7:07:56 AM1/16/22
to vim_use
Hi,

Using this simple vim9script imported from $MYVIMRC, I encounter a lambda error that I don't happen to find the origin.
Capture.PNG



Config Win10 Gvim 8.2.4103


Code
com! -nargs=1 -bang -complete=dir Zip call MainHelper.ZipUpDir(<bang> '<args>')

export def ZipUpDir(path: string) #{{{

  if !isdirectory(path)
        echomsg 'This is not a valid directory ' .. path
        return
  else
        echomsg 'This is a valid directory ' .. path
  endif


  var sevenZ: dict<string> = { 'exe':  expand('$vimruntime/7za.exe '), 'compression': ' -mx9 ', 'exclusion': '' }


  var forbidden_extensions: list<string> = ['*.pack', '*.gif', '*.obj', '*.png', '*.vader', '*.git', '*\\.git/']
  forbidden_extensions                  += [ '*.ncb', '*.ipch', '*.vgr', '*.bin', '*.raw', 'Browse.VC.db'] #Special E10-E12
  var extensions: list<string>           = ['*.obj', '*.git', '*\\.git/']
  sevenZ.exclusion                       = join(map(copy(forbidden_extensions), '"-xr!" .. v:val'))


  var zipSourcePath: string = fnamemodify(path, ':p:h')->substitute("\\", "/", "g")
  var zipName:       string = split(zipSourcePath, '/')[-1] .. '.7z'
  var zipNameOnly:   string = fnamemodify(zipName, ":t:r")


  # Create stamped directory or simple base directory
  var baseDir:    string = expand('$userprofile/desktop/') .. zipNameOnly  .. '/'
  var stampedDir: string = expand('$userprofile/desktop/') .. strftime('%Y%m%d_') .. zipNameOnly .. '/'
  call mkdir(stampedDir, "p", 0x777)


  # Zip command line
  @z = stampedDir .. zipName
  var zip_cmd: string = sevenZ.exe .. sevenZ.exclusion  .. ' a "' .. @z .. '" "' .. zipSourcePath .. '"' .. sevenZ.compression


  # Zip's job
  var jobid: job
  var source: list<number>

  def OutCb(l: list<any>) #2{{{
    # echomsg 'OutCb' .. string(l)
    # eval [][0]
  enddef #2}}}

  def ExitCb(l: list<any>) #2{{{
    # echomsg 'ExitCb' .. string(l)
        # sleep 1m
        # source += l
        # echomsg 'Exiting ' .. string(l) .. ' ' .. string(@z)
  enddef #2}}}

  jobid = job_start(zip_cmd, { out_cb: OutCb, exit_cb:  ExitCb, mode: 'raw', timeout: 1200000 } )
  echomsg 'Jobid: ' .. string(jobid)

enddef #}}}

Bram Moolenaar

unread,
Jan 16, 2022, 10:53:16 AM1/16/22
to vim...@googlegroups.com, Ni Va

Ni Va wrote:

> Using this simple vim9script imported from $MYVIMRC, I encounter a lambda
> error that I don't happen to find the origin.
> [image: Capture.PNG]

The code you included does not have a lambda definition. You can
probably find out where they were coming from with:

:verbose func <lambda>7

> *Code*
> com! -nargs=1 -bang -complete=dir Zip call MainHelper.ZipUpDir(<bang>
> '<args>')

This "<bang>" appears to be misplaced.

Otherwise, the lines have been split in the mail system, thus it's a it
difficult to reproduce anything.


--
You know you use Vim too much when you have this alias in your
~/.bashrc file: alias :e=/bin/vim (Eljay Love-Jensen)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Message has been deleted

Ni Va

unread,
Jan 16, 2022, 1:51:12 PM1/16/22
to vim_use
This is found

   def <lambda>7(l: list<any>)
        Last set from D:\Logiciels\Vim\vimfiles\plugged\nv-helper.vim\autoload\helper.vim line 263
1        # echomsg 'OutCb' .. string(l)
2        # eval [][0]


Here in Red 

    def OutCb(l: list<any>) #2{{{
      # echomsg 'OutCb' .. string(l)
      # eval [][0]
    enddef #2}}}
 
    def ExitCb(l: list<any>) #2{{{
      # echomsg 'ExitCb' .. string(l)
          # sleep 1m
          # source += l
          # echomsg 'Exiting ' .. string(l) .. ' ' .. string(@z)
    enddef #2}}}

Reply all
Reply to author
Forward
0 new messages