vile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vile] minor TCL syntax filter


From: Wayne Cuddy
Subject: Re: [vile] minor TCL syntax filter
Date: Tue, 6 Dec 2016 21:04:10 -0500
User-agent: Mutt/1.5.23 (2014-03-12)

On Sun, Dec 04, 2016 at 04:19:34PM -0500, Thomas Dickey wrote:
> On Fri, Dec 02, 2016 at 07:09:41PM -0500, Wayne Cuddy wrote:
> > I've attached a small image as that was the easiest way to convey this
> > syntax issue.
> 
> hmm - a text-file helps too.  I typed in what I see on the picture,
> but there's some difference near the end (attached).

Haha, yea I should have attached that as well I guess, sorry about that.
I'd be glad to attach the full source but I seem to have found that the
glitch occurs on 9.8o, where I happened to be developing, but not 9.8r.

> > 
> > The line causing the issue is:
> > 
> > 177                 set ts \[clock format \[clock seconds]\
> 
> by the way, what is "]\" ?

The ']' portion is the closing brace for the [clock seconds] command and
the '\' is the usual line continuation character.

The reason for the all "\[" occurrences is because I'm delaying
command expansion until later. The foreach lvl loop is defining
a log procedure for each log level. $ts is assigned when the LogProc_X
is called instead of when LogProc_X is defined.

There are better ways to do this. I wrote this code almost 5 years ago,
it does what it needs to and I'm lazy :( But I'm in there now so I might
as well balance the \[ and \].

In case it's not clear... or if it makes a difference to the vile TCL
filter:

set var [wayne]

Sets variable var to the command result of a proc called wayne.

set var \[wayne]
set var \[wayne\]

Both set var to the string "[wayne]". The first one is just not as clear
because the '\' is not balanced... and of course that is what I used
in my code :) 

> 
> > 178                         -format {%Y-%m-%d %H:%M:%S} -gmt 1]
> > 
> > There are 2 ways to modify the file that maintains TCL semantics and
> > gets the highlighter to work past this block.
> > 
> > 1) Wrap the $ts command expansion in double quotes.
> > 177                 set ts "\[clock format \[clock seconds]\
> > 178                         -format {%Y-%m-%d %H:%M:%S} -gmt 1]"
> > 
> > 1) Balance the escape '\' when terminating command expansions, I
> > usually don't do this since the TCL interpreter allows it but I
> > prabably should for consitency.
> > 177                 set ts \[clock format \[clock seconds\]\
> > 178                         -format {%Y-%m-%d %H:%M:%S} -gmt 1\]
> > 
> > 
> > Since there is a work around and I don't believe this is an easy fix
> > there's really no reason to tackle it... I just figured I'd throw it out
> > there.
> 
> I'll take a look - was in the middle of an upgrade for the sh-filter...

So since this works in 9.8r as you have found, I don't think you
need to spend any time on it.... but thank you for looking.

Wayne



reply via email to

[Prev in Thread] Current Thread [Next in Thread]