Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] zyodl.vim: Fix nested parentheses
- X-seq: zsh-workers 35809
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] zyodl.vim: Fix nested parentheses
- Date: Thu, 16 Jul 2015 23:36:13 +0000
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=3yh zTngDwXFjdIhuJU77nPU0sFk=; b=rQ3/i78c75Fwx1ee9crI/nw2RZ/CSd4hOzx 7K5TJM5jn5a9Uor3746diWDiigYnq6GxIFkaipjWoK22+/n0LNlJ4BXtKDOqI+cB 32ATyzF943wIiTKzZ5PgmwzHrSWSWvgf8cKW1MsE+3KwtzCzxo452ioLCG7BJv61 pmgi/p6c=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=3y hzTngDwXFjdIhuJU77nPU0sFk=; b=Ob9nzqN4nVevET695Auyy3/oh71y8x/6Pj y0fk+JupaP0CxTaEqeu37ljaB3sFM/35T1dIvpP/IA6DN7nrTZd5ztEvKmUmKyhN lzJRlSKvY1ksx5pN6JXjIh2G9c+MPeztLyAtPp0tOv2EMy6jJWLUpHGK4VEqU3J5 HHoUX+UsM=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
---
This seems to work. Adding "contains=zyodlParenthetical" to
zyodlSItemArg2 made the latter match too much, so I settled for
a "skip=" instead, which ought to be good enough in practice.
(The difference is whether nested parentheticals inside a zyodlSItemArg2
would be highlighted correctly, similarly to the new 'chapter(...)'
testcase.)
Daniel
diff --git a/Util/zyodl.vim b/Util/zyodl.vim
index 94efb29..b67bfa5 100644
--- a/Util/zyodl.vim
+++ b/Util/zyodl.vim
@@ -22,8 +22,13 @@
" example(print *.c+LPAR()#q:s/#%+LPAR()#b+RPAR()s+LPAR()*+RPAR().c/'S${match[1]}.C'/+RPAR())
" ifzman(zmanref(zshmisc))ifnzman(noderef(Redirection))
" LPAR()foo 42 foo+RPAR()
+" chapter(foo (foo) foo)
+" chapter(foo (foo (foo) foo) foo) bar
+"
+" # intentionally doubled
+" sitem(foo)(foo (foo) foo)
+" sitem(foo)(foo (foo) foo)
"
-" chapter(foo (foo) foo) # nested parentheses
" sitem(foo)(foo tt(foo) foo) # nested underline
if exists("b:current_syntax")
@@ -33,25 +38,28 @@ endif
"" Syntax groups:
syn clear
syn cluster zyodlInline contains=zyodlTt,zyodlVar,zyodlBold,zyodlEmph,zyodlCond
-syn region zyodlTt start="\<tt(" end=")" contains=zyodlSpecial
-syn region zyodlVar start="\<var(" end=")" contains=zyodlSpecial
-syn region zyodlBold start="\<bf(" end=")" contains=zyodlSpecial
-syn region zyodlEmph start="\<em(" end=")" contains=zyodlSpecial
+syn region zyodlTt start="\<tt(" end=")" contains=zyodlSpecial,zyodlParenthetical
+syn region zyodlVar start="\<var(" end=")" contains=zyodlSpecial,zyodlParenthetical
+syn region zyodlBold start="\<bf(" end=")" contains=zyodlSpecial,zyodlParenthetical
+syn region zyodlEmph start="\<em(" end=")" contains=zyodlSpecial,zyodlParenthetical
syn region zyodlIndex start="\<.index(" end=")" contains=zyodlSpecial
syn match zyodlSpecial "+\?\<\(LPAR\|RPAR\|PLUS\)()"
syn match zyodlNumber "\d\+"
syn region zyodlItem start="\<xitem(" end=")" contains=zyodlSpecial,@zyodlInline
syn region zyodlItem start="\<item(" end=")" contains=zyodlSpecial,@zyodlInline
syn region zyodlExample start="\<example(" end=")" contains=zyodlSpecial
-syn region zyodlTitle start="\<\(chapter\|subsect\|sect\)(" end=")" contains=zyodlSpecial,@zyodlInline
+syn region zyodlTitle start="\<\(chapter\|subsect\|sect\)(" end=")" contains=zyodlSpecial,@zyodlInline,zyodlParenthetical
syn match zyodlTitle "^texinode(.*$"
+syn region zyodlParenthetical start="\w\@<!(" end=")" transparent contained contains=zyodlParenthetical
+" zyodlCond doesn't contain zyodlParenthetical, since section names (probably) don't have parentheticals.
syn region zyodlCond start="\<\(ifzman\|ifnzman\)(" end=")" contains=zyodlRef,zyodlSpecial,@zyodlInline
syn region zyodlRef start="\<\(zmanref\|noderef\)(" end=")"
+" zyodlSItemArg2 should use zyodlParenthetical instead of the 'skip='
syn keyword zyodlKeyword sitem nextgroup=zyodlSItemArg1
syn region zyodlSItemArg1 oneline start="(" end=")" contains=zyodlSpecial,@zyodlInline nextgroup=zyodlSItemArg2 contained
-syn region zyodlSItemArg2 start="(" end=")" contains=zyodlSpecial,@zyodlInline contained
+syn region zyodlSItemArg2 start="(" end=")" contains=zyodlSpecial,@zyodlInline contained skip="\w\@<!([^)]*)"
"" Highlight groups:
hi def link zyodlTt Constant
Messages sorted by:
Reverse Date,
Date,
Thread,
Author