URI transforms
<< Tips | Pages | Screenshots >>
This page documents how you can use the feature of pmwiki-mode that
automatically transforms URI's that you use together with for instance the
command pmwiki-open.
pmwiki-mode uses a variable called pmwiki-uri-transforms that
contains instructions on how to transform a URI given to
pmwiki-open. Here is an example pmwiki-uri-transforms taken from
pmwiki-mode.el:
(set 'pmwiki-uri-transforms
(list
'("http://wiki.lyx.org\\(/[A-Z]\\|/?\\?\\)"
"http://wiki.lyx.org"
"http://wiki.lyx.org/pmwiki.php")
'("http://wiki.lyx.org/pmwiki.php"
"http://wiki.lyx.org"
"http://chr:[email protected]")
))
In the example, pmwiki-uri-transforms is assigned a list with two
transformations. Each transformation consists of three entries:
- A regular expression that the URI must match in order for the transformation to be applied.
- A string that will be searched for in the URI and
- A third string that will replace the second string in the URI.
Let's now study the first transformation:
'("http://wiki.lyx.org\\(/[A-Z]\\|/?\\?\\)"
"http://wiki.lyx.org"
"http://wiki.lyx.org/pmwiki.php")
The first part requires the URI to match the regular expression
which in practice matches URIs such as these
- http://wiki.lyx.org/Group/Page
- http://wiki.lyx.org/?pagename=Group.Page
The second part will search for http://wiki.lyx.org in the URI, and the
third part replaces it with http://wiki.lyx.org/pmwiki.php. The net
result of this transformation is to recognize "clean URIs" and replace them
with a URI that points to pmwiki.php (with the pagename etc appended of
course).
Let's now study the second transformation:
'("http://wiki.lyx.org/pmwiki.php"
"http://wiki.lyx.org"
"http://chr:[email protected]")
This transformation simply inserts username and password into the URI because the requires a password in order to edit pages. (The password doesn't hurt even when just opening a page).