Sunday, January 16, 2022

vim9 script lambda

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 #}}}

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/6f7415c8-6f56-4bc9-b751-1987faecee44n%40googlegroups.com.

No comments:

Post a Comment