Backslashes in placeholders

6 views
Skip to first unread message

Ouroubouros

unread,
Dec 1, 2011, 4:24:01 AM12/1/11
to xptemplate
In the Scheme programming language, the string "hello" can be created
using the following expression:

(string #\h #\e #\l #\l #\o)

where each character is prefixed by #\

I'd like to use xptemplate to make typing these characters easier, by
taking out the need to type #\ in front of each character.

The following snippet almost does what I want:


XPT string " (string #\a #\b #\c ...)
(string` #-`char^` `more...^` #-`char^` `more...^)


Except here I'm using a dash instead of a backslash, because
xptemplate does not allow backslashes in placeholders.

What I'd really like to be able to do is use backslashes, like this:

XPT string " (string #\a #\b #\c ...)
(string` #\`char^` `more...^` #\`char^` `more...^)

But I can't, because xptemplate does not allow backslashes in
placeholders.

According to the documentation,

Note The placeholder can't contain any backslashes (\). If the
default
value should contain any items which need to be escaped (like
brackets
or you want to use backslashes directly), use the following
syntax
(see |xpt-placeholder-default-value| for more information): >
`name^value with \() here^

I tried using the "`name^value with \() here^" syntax, but that
doesn't seem to do what I want either. And I don't really understand
how I could use xpt-placeholder-default-value to solve this problem
either.

Is there any other way to get around the xptemplate limitation of not
allowing backslashes in placeholders?

dr-dr xp

unread,
Dec 20, 2011, 11:57:31 PM12/20/11
to xptem...@googlegroups.com
Not sure if it's enough for you:

XPT string " (string #\a #\b #\c ...)
XSET s|post=substitute( V(), '.', ' #\\&', 'g' )
(string `s^)

This translate the string user-typed in to "#\<char>" form. And this transform happens just before moving to next place holder.

A "post-filter" does this. See: 
:help xpt-snippet-post-filter



--
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