Commits

ZyX_I  committed 6aae2d2

@/os: Removed @/functions dependency

  • Participants
  • Parent commits 66930a7

Comments (0)

Files changed (2)

File plugin/frawor/os.vim

             \exists('g:frawor__donotload')
     finish
 endif
-execute frawor#Setup('0.0', {'plugin/frawor/resources': '0.0',
-            \                'plugin/frawor/functions': '0.0'}, 1)
+execute frawor#Setup('0.0', {'@/resources': '0.0'}, 1)
 "▶1 Define messages
 if v:lang=~?'ru'
     let s:_messages={
     let s:os.fullname='unknown'
 endfor
 "▶2 os.name
-if s:os.fullname[-3:]==#'nix' || s:os.fullname[:2]==#'mac' ||
-            \s:os.fullname==#'qnx' || s:os.fullname==#'vms'
+if s:os.fullname[-3:] is 'nix' || s:os.fullname[:2] is 'mac' ||
+            \s:os.fullname is 'qnx' || s:os.fullname is 'vms'
     let s:os.name='posix'
-elseif s:os.fullname[:2]==#'win'
+elseif s:os.fullname[:2] is 'win'
     let s:os.name='nt'
-elseif s:os.fullname==#'os2'
+elseif s:os.fullname is 'os2'
     let s:os.name='os2'
 else
     let s:os.name='other'
 "▲2
 let s:os.sep=fnamemodify(expand('<sfile>:h'), ':p')[-1:]
 "▶2 os.linesep
-if s:os.name==#'nt'
+if s:os.name is 'nt'
     let s:os.linesep="\r\n"
-elseif s:os.fullname[:2]==#'mac'
+elseif s:os.fullname[:2] is 'mac'
     let s:os.linesep="\r"
 else
     let s:os.linesep="\n"
 endif
 "▶2 os.pathsep
-if s:os.name==#'nt' || s:os.name==#'os2'
+if s:os.name is 'nt' || s:os.name is 'os2'
     let s:os.pathsep=';'
 else
     let s:os.pathsep=':'
 endfunction
 "▶3 os.path.join      :: path[, path[, ...]] | [path] → path
 "▶4 s:eps
-if s:os.name==#'nt'
+if s:os.name is 'nt'
     let s:eps='[/\\]'
 else
     let s:eps='\V'.escape(s:os.sep, '\')
 function s:os.listdir(path, ...)
     let path=s:os.path.abspath(a:path)
     let filelist=s:F.globdir(path)
-    if s:os.name==#'posix'
+    if s:os.name is 'posix'
         let filelist+=s:F.globdir(a:path, '.*')
     else
         call filter(filelist, '!empty(v:val)')
             let addfragment=""
         endif
         let tail=fnamemodify(file, ':t')
-        if tail==#'.' || tail==#'..'
+        if tail is '.' || tail is '..'
             continue
         endif
         if file[0]!=#'/'
     return 0
 endfunction
 "▶2 os.run            :: command[, cwd::path] → String + sh
+let s:opts={
+            \ 'eventignore': 'all',
+            \   'autowrite':   0,
+            \'autowriteall':   0,
+            \  'lazyredraw':   1,
+        \}
 function s:os.run(command, ...)
-    if s:os.name==#'nt'
+    if s:os.name is 'nt'
         let cmd=escape(a:command[0], '\ %')
         if len(a:command)>1
-            let cmd.=" ".join(map(a:command[1:],
+            let cmd.=' '.join(map(a:command[1:],
                         \'((v:val=~#"^[[:alnum:]/\\-]\\+$")?'.
                         \   '(v:val):'.
                         \   '(shellescape(v:val)))'))
     else
         let cmd=join(map(copy(a:command), 'shellescape(v:val)'))
     endif
-    if a:0
-        new
-        if !s:os.chdir(a:1, 1)
-            bwipeout
-            return -1
+    try
+        if a:0
+            let savedopts={}
+            for [opt, val] in items(s:opts)
+                let savedopts[opt]=eval('&g:'.opt)
+                execute 'let &g:'.opt.'='.val
+            endfor
+            new
+            if !s:os.chdir(a:1, 1)
+                bwipeout
+                return -1
+            endif
         endif
-    endif
-    call system(cmd)
-    redraw!
-    return v:shell_error
+        call system(cmd)
+        redraw!
+        return v:shell_error
+    finally
+        if exists('savedopts')
+            for [opt, val] in items(savedopts)
+                execute 'let &g:'.opt.'='.val
+            endfor
+        endif
+    endtry
 endfunction
-let s:os.run=s:_f.wrapfunc({'function': s:os.run,
-            \             '@altervars': [['&g:eventignore', 'all'],
-            \                            ['&g:autowrite',     0  ],
-            \                            ['&g:autowriteall',  0  ],
-            \                            ['&g:lazyredraw',    1  ]]})
 "▶2 mkdir, makedirs
 if exists("*mkdir")
     "▶3 os.makedirs       :: path[, mode] → Bool + FS

File test/reload-frawor.ok

 unloadpre: plugin/frawor/options
 unloadpre: plugin/writefile-feature
 unloadpre: plugin/frawor/os
+unloadpre: plugin/frawor/functions
+unloadpre: plugin/frawor/checks
 unloadpre: plugin/frawor/fwc
 unloadpre: plugin/frawor/fwc/compiler
 unloadpre: plugin/frawor/fwc/parser
 unloadpre: plugin/frawor/resources
-unloadpre: plugin/frawor/checks
-unloadpre: plugin/frawor/functions
 unloadpre: plugin/frawor
 unload: autoload/frawor
 unload: plugin/frawor/commands
 unload: plugin/frawor/tcl
 unload: plugin/ignoredeps-feature
 _unload
-register: plugin/frawor/options
-load: plugin/frawor/options
-register: plugin/frawor/autocommands
-load: plugin/frawor/autocommands
-register: plugin/ignoredeps-feature
-load: plugin/ignoredeps-feature
+register: plugin/frawor/fwc
+load: plugin/frawor/fwc
 register: plugin/frawor/functions
 load: plugin/frawor/functions
+register: plugin/frawor/checks
+load: plugin/frawor/checks
 register: plugin/frawor/os
 load: plugin/frawor/os
 register: autoload/frawor
 load: autoload/frawor
-register: plugin/writefile-feature
-load: plugin/writefile-feature
-register: plugin/frawor/fwc
-load: plugin/frawor/fwc
+register: plugin/ignoredeps-feature
+load: plugin/ignoredeps-feature
+register: plugin/frawor/autocommands
+load: plugin/frawor/autocommands
+register: plugin/frawor/fwc/parser
+load: plugin/frawor/fwc/parser
 register: plugin/frawor
 load: plugin/frawor
 register: plugin/frawor/fwc/compiler
 load: plugin/frawor/fwc/compiler
-register: plugin/frawor/fwc/parser
-load: plugin/frawor/fwc/parser
-register: plugin/frawor/checks
-load: plugin/frawor/checks
 register: plugin/frawor/resources
 load: plugin/frawor/resources
+register: plugin/writefile-feature
+load: plugin/writefile-feature
+register: plugin/frawor/options
+load: plugin/frawor/options
 register: plugin/frawor/tcl
 load: plugin/frawor/tcl
 register: plugin/frawor/ruby