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:LyXers@wiki.lyx.org")
	      ))

In the example, pmwiki-uri-transforms is assigned a list with two transformations. Each transformation consists of three entries:

  1. A regular expression that the URI must match in order for the transformation to be applied.
  2. A string that will be searched for in the URI and
  3. 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

http://wiki.lyx.org\(/[A-Z]\|/?\?\)

which in practice matches URIs such as these

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:LyXers@wiki.lyx.org")

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