ZyX_I avatar ZyX_I committed 12ddf9f

@/fwc: Made `path' pipe expand current argument

Comments (0)

Files changed (6)

 path {pathspec}                                                   *FWC-c-path*
     Checker: checks whether current argument is a path matching given 
              specification.
+    Filter: before checking expands path without globbing (uses |expand()| 
+            with \, [, ], ? and * escaped). This means that you can use 
+            ~ directory shortcut, |:_%|, |:_#|, enviroment variables, 
+            |`-expansion| and |`=|.
                     {pathspec} :: [df]? "r"? [wWp]? "x"?
                                 & ! ( "d" | ^ ) "r"
                                 & ! "d" [wWp]? "x"
     0.1: Posted strdisplaywidth function
 @/fwc:
     0.1: (intfuncs-0.1) Added `idof' checker
+    0.2: (intfuncs-0.2) Made `path' filter expand argument
 
 vim: ft=help:tw=78

plugin/frawor/fwc.vim

 "▶1 Header
 scriptencoding utf-8
-execute frawor#Setup('0.1', {'@/fwc/compiler': '0.0',
+execute frawor#Setup('0.2', {'@/fwc/compiler': '0.0',
             \                '@/decorators'  : '0.0'}, 1)
 "▶1 Define messages
 if v:lang=~?'ru'

plugin/frawor/fwc/intfuncs.vim

 "▶1 Header
 scriptencoding utf-8
-execute frawor#Setup('0.1', {'@/resources': '0.0',
+execute frawor#Setup('0.2', {'@/resources': '0.0',
             \                '@/os':        '0.0',
             \                '@/signs':     '0.0',}, 1)
 let s:r={}
     endif
     return self
 endfunction
+"▶2 pipe
+function s:r.path.pipe(...)
+    let curargstr=self.argstr()
+    call self.let(curargstr, 'expand(escape('.curargstr.', "\\[]?*"))')
+    return call(s:r.path.check, a:000, self)
+endfunction
 "▶2 complete
 function s:r.path.complete(desc, idx, type)
     let spec=a:desc[1]
 plugin/frawor/fwc/compiler:isfile
 plugin/frawor/fwc/compiler:isdir
 plugin/frawor/fwc/compiler:nread
+plugin/frawor/fwc/compiler:isdir
 ::: Section <Checks/Built-in checks/either>
 plugin/frawor/fwc/compiler:eitherfail
 plugin/frawor/fwc/compiler:nbool

test/fwctests.dat

 ['path dp',         'check'], [dirdefghi],          1
 ['path fr',         'check'], ['.'],                0
 ['path fr',         'check'], ['foo'],              1
+['path d',          'check'], ['$HOME'],            0
+['path d',          'check'], ['~'],                1
+['path d',         'filter'], ['$HOME'],            [$HOME]
+['path d',         'filter'], ['~'],                [$HOME]
 #▶3 either
 ['either bool, isreg',      'check'], ['abc'],         1
 ['either bool, isreg',      'check'], [2],             0
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.