aboutsummaryrefslogtreecommitdiff
path: root/vim/bundle/tlib_vim/autoload/tlib/rx.vim
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2016-06-30 16:03:25 +0200
committerKarel Kočí <cynerd@email.cz>2016-06-30 16:03:25 +0200
commite573b3020c032400eed60b649a2cbf55266e6bb0 (patch)
tree8f572394ac8433529c7a8e70d160a2fbe8268b4e /vim/bundle/tlib_vim/autoload/tlib/rx.vim
parentb8c667bd64b3edd38d56c63c5bd1db53a23b4499 (diff)
downloadmyconfigs-e573b3020c032400eed60b649a2cbf55266e6bb0.tar.gz
myconfigs-e573b3020c032400eed60b649a2cbf55266e6bb0.tar.bz2
myconfigs-e573b3020c032400eed60b649a2cbf55266e6bb0.zip
Add current configurations from old repository
Diffstat (limited to 'vim/bundle/tlib_vim/autoload/tlib/rx.vim')
-rw-r--r--vim/bundle/tlib_vim/autoload/tlib/rx.vim60
1 files changed, 60 insertions, 0 deletions
diff --git a/vim/bundle/tlib_vim/autoload/tlib/rx.vim b/vim/bundle/tlib_vim/autoload/tlib/rx.vim
new file mode 100644
index 0000000..8389983
--- /dev/null
+++ b/vim/bundle/tlib_vim/autoload/tlib/rx.vim
@@ -0,0 +1,60 @@
+" @Author: Tom Link (micathom AT gmail com?subject=[vim])
+" @Website: http://www.vim.org/account/profile.php?user_id=4037
+" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
+" @Revision: 113
+
+
+" :def: function! tlib#rx#Escape(text, ?magic='m')
+" magic can be one of: m, M, v, V
+" See :help 'magic'
+function! tlib#rx#Escape(text, ...) "{{{3
+ TVarArg 'magic'
+ if empty(magic)
+ let magic = 'm'
+ endif
+ if magic =~# '^\\\?m$'
+ return escape(a:text, '^$.*\[]~')
+ elseif magic =~# '^\\\?M$'
+ return escape(a:text, '^$\')
+ elseif magic =~# '^\\\?V$'
+ return escape(a:text, '\')
+ elseif magic =~# '^\\\?v$'
+ return substitute(a:text, '[^0-9a-zA-Z_]', '\\&', 'g')
+ else
+ echoerr 'tlib: Unsupported magic type'
+ return a:text
+ endif
+endf
+
+" :def: function! tlib#rx#EscapeReplace(text, ?magic='m')
+" Escape return |sub-replace-special|.
+function! tlib#rx#EscapeReplace(text, ...) "{{{3
+ TVarArg ['magic', 'm']
+ if magic ==# 'm' || magic ==# 'v'
+ return escape(a:text, '\&~')
+ elseif magic ==# 'M' || magic ==# 'V'
+ return escape(a:text, '\')
+ else
+ echoerr 'magic must be one of: m, v, M, V'
+ endif
+endf
+
+
+function! tlib#rx#Suffixes(...) "{{{3
+ TVarArg ['magic', 'm']
+ let sfx = split(&suffixes, ',')
+ call map(sfx, 'tlib#rx#Escape(v:val, magic)')
+ if magic ==# 'v'
+ return '('. join(sfx, '|') .')$'
+ elseif magic ==# 'V'
+ return '\('. join(sfx, '\|') .'\)\$'
+ else
+ return '\('. join(sfx, '\|') .'\)$'
+ endif
+endf
+
+
+function! tlib#rx#LooksLikeRegexp(text) abort "{{{3
+ return a:text =~ '[.?*+{}\[\]]'
+endf
+