annotate runtime/plugin/logiPat.vim @ 34538:c865c2f93a04 v9.1.0171

patch 9.1.0171: Small split-move related improvements Commit: https://github.com/vim/vim/commit/5cac1a9bee0798d70a7fd80363a1f697759638e8 Author: Sean Dewar <6256228+seandewar@users.noreply.github.com> Date: Tue Mar 12 21:11:39 2024 +0100 patch 9.1.0171: Small split-move related improvements Problem: small improvements can be made to split-move related functions. Solution: apply them (Sean Dewar): - Improve some doc comments (frame_flatten should still work for non-current tabpages, despite the topframe check, which looks benign, though I'm unsure if it's still needed; see #2467). - f_win_splitmove should check_split_disallowed on wp, not targetwin, as that's what win_splitmove checks (though it's probably unnecessary to check b_locked_split at all; see #14109, which I hope to get around to finishing at some point). - Make winframe_restore restore window positions for the altframe, which winframe_remove changes. This doesn't affect the prior behaviour, as we called win_comp_pos after, but as win_comp_pos only works for curtab, and winframe_remove supports non-current tabpages, we should undo it. Regardless, this should mean we don't need win_comp_pos anymore; adjust tests to check that window positions remain unchanged. I'm not sure win_comp_pos is needed after last_status anyway if it doesn't steal rows from another frame to make room for a new statusline, which shouldn't be the case after winframe_remove? To be safe, I'll leave it as is. closes: #14185 Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 12 Mar 2024 21:15:03 +0100
parents 02bd0fe77c68
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8869
b73f9ed65072 commit https://github.com/vim/vim/commit/939a1abe935a539f2d4c90a56cb0682cbaf3bbb0
Christian Brabandt <cb@256bit.org>
parents: 6855
diff changeset
1 " LogiPat: Boolean logical pattern matcher
34375
02bd0fe77c68 runtime(misc): announce adoption of various runtime files
Christian Brabandt <cb@256bit.org>
parents: 8869
diff changeset
2 " Maintainer: This runtime file is looking for a new maintainer.
02bd0fe77c68 runtime(misc): announce adoption of various runtime files
Christian Brabandt <cb@256bit.org>
parents: 8869
diff changeset
3 " Original Author: Charles E. Campbell
8869
b73f9ed65072 commit https://github.com/vim/vim/commit/939a1abe935a539f2d4c90a56cb0682cbaf3bbb0
Christian Brabandt <cb@256bit.org>
parents: 6855
diff changeset
4 " Date: Apr 04, 2016
b73f9ed65072 commit https://github.com/vim/vim/commit/939a1abe935a539f2d4c90a56cb0682cbaf3bbb0
Christian Brabandt <cb@256bit.org>
parents: 6855
diff changeset
5 " Version: 4
6855
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6 " Purpose: to do Boolean-logic based regular expression pattern matching
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7 " Copyright: Copyright (C) 1999-2011 Charles E. Campbell {{{1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
8 " Permission is hereby granted to use and distribute this code,
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
9 " with or without modifications, provided that this copyright
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
10 " notice is copied with it. Like most anything else that's free,
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
11 " LogiPat.vim is provided *as is* and comes with no warranty
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
12 " of any kind, either expressed or implied. By using this
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
13 " plugin, you agree that in no event will the copyright
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
14 " holder be liable for any damages resulting from the use
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
15 " of this software.
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
16 "
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
17 " Usage: {{{1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
18 " :LogiPat ...
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
19 "
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
20 " Boolean logic supported:
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
21 " () grouping operators
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
22 " ! not the following pattern
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
23 " | logical or
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
24 " & logical and
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
25 " "..pattern.."
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
26 " Example: {{{1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
27 " :LogiPat !("january"|"february")
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
28 " would match all strings not containing the strings january
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
29 " or february
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
30 " GetLatestVimScripts: 1290 1 :AutoInstall: LogiPat.vim
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
31 "
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
32 " Behold, you will conceive in your womb, and bring forth a son, {{{1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
33 " and will call his name Jesus. He will be great, and will be
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
34 " called the Son of the Most High. The Lord God will give him the
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
35 " throne of his father, David, and he will reign over the house of
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
36 " Jacob forever. There will be no end to his kingdom. (Luke 1:31-33 WEB)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
37
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
38 " ---------------------------------------------------------------------
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
39 " Load Once: {{{1
8869
b73f9ed65072 commit https://github.com/vim/vim/commit/939a1abe935a539f2d4c90a56cb0682cbaf3bbb0
Christian Brabandt <cb@256bit.org>
parents: 6855
diff changeset
40 if &cp || exists("loaded_logiPat")
6855
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
41 finish
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
42 endif
8869
b73f9ed65072 commit https://github.com/vim/vim/commit/939a1abe935a539f2d4c90a56cb0682cbaf3bbb0
Christian Brabandt <cb@256bit.org>
parents: 6855
diff changeset
43 let g:loaded_logiPat = "v4"
6855
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
44 let s:keepcpo = &cpo
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
45 set cpo&vim
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
46 "DechoRemOn
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
47
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
48 " ---------------------------------------------------------------------
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
49 " Public Interface: {{{1
8869
b73f9ed65072 commit https://github.com/vim/vim/commit/939a1abe935a539f2d4c90a56cb0682cbaf3bbb0
Christian Brabandt <cb@256bit.org>
parents: 6855
diff changeset
50 com! -nargs=* LogiPat call LogiPat(<q-args>,1)
b73f9ed65072 commit https://github.com/vim/vim/commit/939a1abe935a539f2d4c90a56cb0682cbaf3bbb0
Christian Brabandt <cb@256bit.org>
parents: 6855
diff changeset
51 sil! com -nargs=* LP call LogiPat(<q-args>,1)
b73f9ed65072 commit https://github.com/vim/vim/commit/939a1abe935a539f2d4c90a56cb0682cbaf3bbb0
Christian Brabandt <cb@256bit.org>
parents: 6855
diff changeset
52 sil! com -nargs=* LPR call LogiPat(<q-args>,1,"r")
b73f9ed65072 commit https://github.com/vim/vim/commit/939a1abe935a539f2d4c90a56cb0682cbaf3bbb0
Christian Brabandt <cb@256bit.org>
parents: 6855
diff changeset
53 com! -nargs=+ LPE echomsg LogiPat(<q-args>)
b73f9ed65072 commit https://github.com/vim/vim/commit/939a1abe935a539f2d4c90a56cb0682cbaf3bbb0
Christian Brabandt <cb@256bit.org>
parents: 6855
diff changeset
54 com! -nargs=+ LogiPatFlags let s:LogiPatFlags="<args>"
b73f9ed65072 commit https://github.com/vim/vim/commit/939a1abe935a539f2d4c90a56cb0682cbaf3bbb0
Christian Brabandt <cb@256bit.org>
parents: 6855
diff changeset
55 sil! com -nargs=+ LPF let s:LogiPatFlags="<args>"
6855
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
56
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
57 " =====================================================================
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
58 " Functions: {{{1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
59
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
60 " ---------------------------------------------------------------------
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
61 " LogiPat: this function interprets the boolean-logic pattern {{{2
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
62 fun! LogiPat(pat,...)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
63 " call Dfunc("LogiPat(pat<".a:pat.">)")
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
64
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
65 " LogiPat(pat,dosearch)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
66 if a:0 > 0
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
67 let dosearch= a:1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
68 else
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
69 let dosearch= 0
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
70 endif
8869
b73f9ed65072 commit https://github.com/vim/vim/commit/939a1abe935a539f2d4c90a56cb0682cbaf3bbb0
Christian Brabandt <cb@256bit.org>
parents: 6855
diff changeset
71 if a:0 >= 3
b73f9ed65072 commit https://github.com/vim/vim/commit/939a1abe935a539f2d4c90a56cb0682cbaf3bbb0
Christian Brabandt <cb@256bit.org>
parents: 6855
diff changeset
72 let s:LogiPatFlags= a:3
b73f9ed65072 commit https://github.com/vim/vim/commit/939a1abe935a539f2d4c90a56cb0682cbaf3bbb0
Christian Brabandt <cb@256bit.org>
parents: 6855
diff changeset
73 endif
6855
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
74
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
75 let s:npatstack = 0
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
76 let s:nopstack = 0
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
77 let s:preclvl = 0
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
78 let expr = a:pat
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
79
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
80 " Lexer/Parser
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
81 while expr != ""
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
82 " call Decho("expr<".expr.">")
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
83
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
84 if expr =~ '^"'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
85 " push a Pattern; accept "" as a single " in the pattern
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
86 let expr = substitute(expr,'^\s*"','','')
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
87 let pat = substitute(expr,'^\(\%([^"]\|\"\"\)\{-}\)"\([^"].*$\|$\)','\1','')
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
88 let pat = substitute(pat,'""','"','g')
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
89 let expr = substitute(expr,'^\(\%([^"]\|\"\"\)\{-}\)"\([^"].*$\|$\)','\2','')
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
90 let expr = substitute(expr,'^\s*','','')
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
91 " call Decho("pat<".pat."> expr<".expr.">")
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
92
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
93 call s:LP_PatPush('.*'.pat.'.*')
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
94
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
95 elseif expr =~ '^[!()|&]'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
96 " push an operator
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
97 let op = strpart(expr,0,1)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
98 let expr = strpart(expr,strlen(op))
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
99 " allow for those who can't resist doubling their and/or operators
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
100 if op =~ '[|&]' && expr[0] == op
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
101 let expr = strpart(expr,strlen(op))
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
102 endif
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
103 call s:LP_OpPush(op)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
104
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
105 elseif expr =~ '^\s'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
106 " skip whitespace
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
107 let expr= strpart(expr,1)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
108
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
109 else
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
110 echoerr "operator<".strpart(expr,0,1)."> not supported (yet)"
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
111 let expr= strpart(expr,1)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
112 endif
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
113
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
114 endwhile
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
115
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
116 " Final Execution
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
117 call s:LP_OpPush('Z')
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
118
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
119 let result= s:LP_PatPop(1)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
120 " call Decho("result=".result)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
121
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
122 " sanity checks and cleanup
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
123 if s:npatstack > 0
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
124 echoerr s:npatstack." patterns left on stack!"
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
125 let s:npatstack= 0
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
126 endif
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
127 if s:nopstack > 0
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
128 echoerr s:nopstack." operators left on stack!"
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
129 let s:nopstack= 0
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
130 endif
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
131
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
132 " perform the indicated search
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
133 if dosearch
8869
b73f9ed65072 commit https://github.com/vim/vim/commit/939a1abe935a539f2d4c90a56cb0682cbaf3bbb0
Christian Brabandt <cb@256bit.org>
parents: 6855
diff changeset
134 if exists("s:LogiPatFlags") && s:LogiPatFlags != ""
6855
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
135 " call Decho("search(result<".result."> LogiPatFlags<".s:LogiPatFlags.">)")
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
136 call search(result,s:LogiPatFlags)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
137 else
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
138 " call Decho("search(result<".result.">)")
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
139 call search(result)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
140 endif
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
141 let @/= result
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
142 endif
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
143
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
144 " call Dret("LogiPat ".result)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
145 return result
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
146 endfun
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
147
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
148 " ---------------------------------------------------------------------
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
149 " s:String: Vim6.4 doesn't have string() {{{2
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
150 func! s:String(str)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
151 return "'".escape(a:str, '"')."'"
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
152 endfunc
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
153
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
154 " ---------------------------------------------------------------------
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
155 " LP_PatPush: {{{2
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
156 fun! s:LP_PatPush(pat)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
157 " call Dfunc("LP_PatPush(pat<".a:pat.">)")
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
158 let s:npatstack = s:npatstack + 1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
159 let s:patstack_{s:npatstack} = a:pat
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
160 " call s:StackLook("patpush") "Decho
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
161 " call Dret("LP_PatPush : npatstack=".s:npatstack)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
162 endfun
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
163
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
164 " ---------------------------------------------------------------------
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
165 " LP_PatPop: pop a number/variable from LogiPat's pattern stack {{{2
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
166 fun! s:LP_PatPop(lookup)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
167 " call Dfunc("LP_PatPop(lookup=".a:lookup.")")
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
168 if s:npatstack > 0
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
169 let ret = s:patstack_{s:npatstack}
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
170 let s:npatstack = s:npatstack - 1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
171 else
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
172 let ret= "---error---"
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
173 echoerr "(LogiPat) invalid expression"
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
174 endif
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
175 " call s:StackLook("patpop") "Decho
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
176 " call Dret("LP_PatPop ".ret)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
177 return ret
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
178 endfun
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
179
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
180 " ---------------------------------------------------------------------
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
181 " LP_OpPush: {{{2
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
182 fun! s:LP_OpPush(op)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
183 " call Dfunc("LP_OpPush(op<".a:op.">)")
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
184
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
185 " determine new operator's precedence level
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
186 if a:op == '('
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
187 let s:preclvl= s:preclvl + 10
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
188 let preclvl = s:preclvl
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
189 elseif a:op == ')'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
190 let s:preclvl= s:preclvl - 10
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
191 if s:preclvl < 0
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
192 let s:preclvl= 0
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
193 echoerr "too many )s"
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
194 endif
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
195 let preclvl= s:preclvl
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
196 elseif a:op =~ '|'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
197 let preclvl= s:preclvl + 2
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
198 elseif a:op =~ '&'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
199 let preclvl= s:preclvl + 4
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
200 elseif a:op == '!'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
201 let preclvl= s:preclvl + 6
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
202 elseif a:op == 'Z'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
203 let preclvl= -1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
204 else
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
205 echoerr "expr<".expr."> not supported (yet)"
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
206 let preclvl= s:preclvl
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
207 endif
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
208 " call Decho("new operator<".a:op."> preclvl=".preclvl)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
209
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
210 " execute higher-precdence operators
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
211 " call Decho("execute higher-precedence operators")
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
212 call s:LP_Execute(preclvl)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
213
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
214 " push new operator onto operator-stack
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
215 " call Decho("push new operator<".a:op."> onto stack with preclvl=".preclvl." at nopstack=".(s:nopstack+1))
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
216 if a:op =~ '!'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
217 let s:nopstack = s:nopstack + 1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
218 let s:opprec_{s:nopstack} = preclvl
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
219 let s:opstack_{s:nopstack} = a:op
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
220 elseif a:op =~ '|'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
221 let s:nopstack = s:nopstack + 1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
222 let s:opprec_{s:nopstack} = preclvl
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
223 let s:opstack_{s:nopstack} = a:op
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
224 elseif a:op == '&'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
225 let s:nopstack = s:nopstack + 1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
226 let s:opprec_{s:nopstack} = preclvl
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
227 let s:opstack_{s:nopstack} = a:op
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
228 endif
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
229
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
230 " call s:StackLook("oppush") "Decho
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
231 " call Dret("LP_OpPush : s:preclvl=".s:preclvl)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
232 endfun
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
233
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
234 " ---------------------------------------------------------------------
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
235 " LP_Execute: execute operators from opstack using pattern stack {{{2
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
236 fun! s:LP_Execute(preclvl)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
237 " call Dfunc("LP_Execute(preclvl=".a:preclvl.") npatstack=".s:npatstack." nopstack=".s:nopstack)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
238
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
239 " execute all higher precedence operators
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
240 while s:nopstack > 0 && a:preclvl < s:opprec_{s:nopstack}
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
241 let op= s:opstack_{s:nopstack}
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
242 " call Decho("op<".op."> nop=".s:nopstack." [preclvl=".a:preclvl."] < [opprec_".s:nopstack."=".s:opprec_{s:nopstack}."]")
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
243
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
244 let s:nopstack = s:nopstack - 1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
245
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
246 if op == '!'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
247 let n1= s:LP_PatPop(1)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
248 call s:LP_PatPush(s:LP_Not(n1))
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
249
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
250 elseif op == '|'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
251 let n1= s:LP_PatPop(1)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
252 let n2= s:LP_PatPop(1)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
253 call s:LP_PatPush(s:LP_Or(n2,n1))
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
254
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
255 elseif op =~ '&'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
256 let n1= s:LP_PatPop(1)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
257 let n2= s:LP_PatPop(1)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
258 call s:LP_PatPush(s:LP_And(n2,n1))
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
259 endif
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
260
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
261 " call s:StackLook("execute") "Decho
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
262 endwhile
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
263
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
264 " call Dret("LP_Execute")
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
265 endfun
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
266
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
267 " ---------------------------------------------------------------------
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
268 " LP_Not: writes a logical-not for a pattern {{{2
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
269 fun! s:LP_Not(pat)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
270 " call Dfunc("LP_Not(pat<".a:pat.">)")
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
271 if a:pat =~ '^\.\*' && a:pat =~ '\.\*$'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
272 let pat= substitute(a:pat,'^\.\*\(.*\)\.\*$','\1','')
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
273 let ret= '^\%(\%('.pat.'\)\@!.\)*$'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
274 else
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
275 let ret= '^\%(\%('.a:pat.'\)\@!.\)*$'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
276 endif
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
277 " call Dret("LP_Not ".ret)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
278 return ret
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
279 endfun
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
280
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
281 " ---------------------------------------------------------------------
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
282 " LP_Or: writes a logical-or branch using two patterns {{{2
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
283 fun! s:LP_Or(pat1,pat2)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
284 " call Dfunc("LP_Or(pat1<".a:pat1."> pat2<".a:pat2.">)")
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
285 let ret= '\%('.a:pat1.'\|'.a:pat2.'\)'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
286 " call Dret("LP_Or ".ret)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
287 return ret
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
288 endfun
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
289
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
290 " ---------------------------------------------------------------------
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
291 " LP_And: writes a logical-and concat using two patterns {{{2
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
292 fun! s:LP_And(pat1,pat2)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
293 " call Dfunc("LP_And(pat1<".a:pat1."> pat2<".a:pat2.">)")
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
294 let ret= '\%('.a:pat1.'\&'.a:pat2.'\)'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
295 " call Dret("LP_And ".ret)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
296 return ret
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
297 endfun
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
298
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
299 " ---------------------------------------------------------------------
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
300 " StackLook: {{{2
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
301 fun! s:StackLook(description)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
302 " call Dfunc("StackLook(description<".a:description.">)")
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
303 let iop = 1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
304 let ifp = 1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
305 " call Decho("Pattern Operator")
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
306
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
307 " print both pattern and operator
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
308 while ifp <= s:npatstack && iop <= s:nopstack
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
309 let fp = s:patstack_{ifp}
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
310 let op = s:opstack_{iop}." (P".s:opprec_{s:nopstack}.')'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
311 let fplen= strlen(fp)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
312 if fplen < 30
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
313 let fp= fp.strpart(" ",1,30-fplen)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
314 endif
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
315 " call Decho(fp.op)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
316 let ifp = ifp + 1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
317 let iop = iop + 1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
318 endwhile
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
319
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
320 " print just pattern
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
321 while ifp <= s:npatstack
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
322 let fp = s:patstack_{ifp}
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
323 " call Decho(fp)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
324 let ifp = ifp + 1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
325 endwhile
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
326
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
327 " print just operator
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
328 while iop <= s:nopstack
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
329 let op = s:opstack_{iop}." (P".s:opprec_{s:nopstack}.')'
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
330 " call Decho(" ".op)
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
331 let iop = iop + 1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
332 endwhile
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
333 " call Dret("StackLook")
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
334 endfun
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
335
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
336 " ---------------------------------------------------------------------
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
337 " Cleanup And Modeline: {{{1
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
338 let &cpo= s:keepcpo
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
339 unlet s:keepcpo
ee45d3b0579b Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
340 " vim: ts=4 fdm=marker