Popup to snippet to repetition problem

14 views
Skip to first unread message

Ouroubouros

unread,
Jan 30, 2011, 11:14:57 AM1/30/11
to xptemplate
Using the technique detailed in the "Place holder to popup to snippet
or second popup?" thread, I've constructed the following snippets:

XPT foo
`...abc^`xyz^`...abc^

XPT parent
`_parent_popup^
XSET _parent_popup=Choose([ 'a', 'b' ])
XSET _parent_popup|post=Build( '`:' . ( ( { "a" : "foo", "b" :
"bar" } )[ V() ] ) . ':^' )

The "foo" snippet works as expected by itself (that is, it shows the
"...abc" place holder, and allows me to expand it and repeat it as
necessary).

But, when I execute the "parent" snippet and select "a" from the popup
menu, instead of seeing just "...abc", I see: "...abcxyz...abc".

What's going wrong?

Ouroubouros

unread,
Jan 30, 2011, 11:23:34 AM1/30/11
to xptemplate
After playing around a bit with this, I've decided that this is some
kind of quoting problem. I'm not sure how to fix it, though.

I've tried putting in various combinations of ` and ^ around the place
holders in "foo", but without success.

dr-dr xp

unread,
Jan 30, 2011, 11:32:43 AM1/30/11
to xptem...@googlegroups.com
Sorry but It's a bug..
runtime inclusion does not parse repetition. If you have triggered once "foo" the "parent" works well.

Let me see what I can do to it.


--
You received this message because you are subscribed to the Google Groups "xptemplate" group.
To post to this group, send email to xptem...@googlegroups.com.
To unsubscribe from this group, send email to xptemplate+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xptemplate?hl=en.




--
要了几天饱饭就不记得西北风啥味了

Ouroubouros

unread,
Jan 30, 2011, 12:26:59 PM1/30/11
to xptemplate
On Jan 30, 11:32 am, dr-dr xp <drdr...@gmail.com> wrote:
>
> Sorry but It's a bug..
> runtime inclusion does not parse repetition. If you have triggered
> once "foo" the "parent" works well.
>
> Let me see what I can do to it.

You may also want to look at inclusion of expandable snippets:

XPT foo
``...abc^`xyz^`...abc^

XPT bar
``ddd...{{^`eee^`}}^

XPT parent
`_parent_popup^
XSET _parent_popup=Choose([ 'a', 'b' ])
XSET _parent_popup|post=Build( '`:' . ( ( { "a" : "foo", "b" :
"bar" } )[ V() ] ) . ':^' )

Here, the "bar" snippet works fine by itself (showing the "ddd..."
place holder and allowing that to be expanded, as usual).

But when I open the "parent" snippet and select "b" from the popup
menu, I see: "ddd...{{eee}}"

dr-dr xp

unread,
Jan 30, 2011, 12:29:16 PM1/30/11
to xptem...@googlegroups.com
Yeah these are from the same bug. tomorrow I'm going to give a patch. Also you can get the fixed version from git.


--
You received this message because you are subscribed to the Google Groups "xptemplate" group.
To post to this group, send email to xptem...@googlegroups.com.
To unsubscribe from this group, send email to xptemplate+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xptemplate?hl=en.




--
要了几天饱饭就不记得西北风啥味了

dr-dr xp

unread,
Jan 31, 2011, 2:02:40 PM1/31/11
to xptem...@googlegroups.com
the bug is fixed. I've updated both GIT/master and SVN/trunk repository. check it.

2011/1/31 dr-dr xp <drd...@gmail.com>



--
要了几天饱饭就不记得西北风啥味了

Ouroubouros

unread,
Jan 31, 2011, 4:59:37 PM1/31/11
to xptemplate
On Jan 31, 2:02 pm, dr-dr xp <drdr...@gmail.com> wrote:
>
> the bug is fixed. I've updated both
> GIT/master and SVN/trunk repository. check it.

Thank you, but I'm a little confused as to which to use.

I don't normally use git or svn, so maybe that's why I'm confused.

To get the git tree, I did:

git clone git://github.com/vim-scripts/xptemplate.git

which gave me a 1.1 megabyte directory.

To get the svn tree, I did:

svn checkout http://xptemplate.googlecode.com/svn/trunk/ xptemplate-
read-only

Which gave me a 9.1 megabyte directory, containing the following
subdirectories:

dist (size: 2.1 MB)
resource (size: 88 K)
src (size: 6.9 MB)

Obviously, "resource" is not the directory I want to use.

That leaves me with "dist", "src", and the tree I got from git. They
all have different sizes, yet apparently somewhat similar content.

Which directory should I be using? And what's the difference between
them?

Also, just so you know, neither of the following places mention how to
do a checkout from the git tree, so I had to dig around a bit to
figure it out:

* http://www.vim.org/scripts/script.php?script_id=2611
* the README on https://github.com/vim-scripts/xptemplate

Ouroubouros

unread,
Jan 31, 2011, 8:55:02 PM1/31/11
to xptemplate
On Jan 31, 4:59 pm, Ouroubouros <deepru...@gmail.com> wrote:
>
> Which directory should I be using? And what's the difference between
> them?

Well, I just tried out the "dist" directory from svn, and the bug
described above seems to be fixed.

But, I think I may have just found another one:

""""""""""""""""""""""""""""""""""""""""""""""""""""

XPT a
`x...{{^`:b:^`}}^

XPT b
`...y^` `zzz^` `...y^

""""""""""""""""""""""""""""""""""""""""""""""""""""

In the above code, the "b" snippet works like it should, but opening
the "a" snippet and hitting TAB on the "x..." place holder shows:

...y zzz ...y

And here's a more complex test case, which also fails:

""""""""""""""""""""""""""""""""""""""""""""""""""""

XPT a
`x...{{^`:b:^`}}^

XPT b
`...y^` `:c:^` `...y^

XPT c
`popup^
XSET popup=ChooseStr( '1', '2', '3' )

""""""""""""""""""""""""""""""""""""""""""""""""""""
In the code above, both the "b" and "c" snippets work fine, but when I
open the "a" snippet and hit TAB on the "x..." place holder, it
expands to:

...y popup ...y

dr-dr xp

unread,
Jan 31, 2011, 11:35:26 PM1/31/11
to xptem...@googlegroups.com
Well yes it is a little problem: 

double brackets "{{" syntax and "...y" syntax are actually the same thing implementing expandable and repetition, but with different syntax. And they should not be used together.

XPT parses "{{" first and then "...y" so that if there is nested "...y" inside "{{", the inside one will be ignored.

You can try this:

XPT a
`x...{{^`:b:^`}}^

XPT b
`y...{{^` `:c:^` `y...^`}}^

XPT c
`popup^
XSET popup=ChooseStr( '1', '2', '3' )


Regards

--
You received this message because you are subscribed to the Google Groups "xptemplate" group.
To post to this group, send email to xptem...@googlegroups.com.
To unsubscribe from this group, send email to xptemplate+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xptemplate?hl=en.




--
要了几天饱饭就不记得西北风啥味了

dr-dr xp

unread,
Jan 31, 2011, 11:40:58 PM1/31/11
to xptem...@googlegroups.com
SVN/trunk and GIT/master is the main stream. They have the same contents.
/src is source directory with a lot debug statements
/dist is built directory with compacted codes

Normally you should use either SVN/trunk/dist or GIT/master/dist




--
You received this message because you are subscribed to the Google Groups "xptemplate" group.
To post to this group, send email to xptem...@googlegroups.com.
To unsubscribe from this group, send email to xptemplate+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xptemplate?hl=en.




--
要了几天饱饭就不记得西北风啥味了
Reply all
Reply to author
Forward
0 new messages