[pmwiki-users] Re: emacs pmwiki-mode: getting closer

chr at home.se chr at home.se
Sun May 8 10:46:57 CDT 2005


On Sun, 8 May 2005, Orm Finnendahl wrote:

> Am 08. Mai 2005, 13:08 Uhr (+0200) schrieb Joachim Durchholz:
> >
> > You have entered http://localhost/pmwiki or http://localhost/pmwiki/, 
> > and Apache responded with a redirect to 
> > http://localhost/pmwiki/Main/HomePage.
> 
> Not really (see below). If I give the short address, emacs-pmwiki-mode
> gives an error.
> 
> > Obviously, the emacs mode isn't smart enough to properly follow 
> > redirects and gives you the error document.
> > 
> > Simply give the full URL, i.e. http://localhost/pmwiki/Main/HomePage , 
> > do avoid the problem. 
> 
> That's actually what I did. This page doesn't exist in this form,
> though. I assume it gets rewritten by apache's mod_rewrite to
> 
> http://localhost/pmwiki/pmwiki.php?n=Main.HomePage
> 
> if I understood the Clean URL script correctly.
> 
> > (You could also report the problem to the author 
> > of the emacs mode.)

Hi Orm and Joachim,

I'm the author of pmwiki-mode and know what your problem is - it's 
partly a problem with the emacs code. To be specific, in the module I 
use to get web pages which is not able to follow redirects. I didn't write 
that module and don't know (an easy way) to make it follow redirects. What 
I can do however is explain how I've worked around this problem.

It *is* documented on the wiki pages, although (ahem) not very well - it's
actually in the change log... So I'd be delighted if you afterwards could
help me write a description of how to solve this.

First of all, you should be using the latest version from CVS, see this
page:

	http://www.pmwiki.org/wiki/EmacsModes/CVS

The solution I use is to define a transformation table that pmwiki-mode
applies to the URI before using it to get a page. So what you need to do
is add something like the following to your .emacs-file:

	(set 'pmwiki-uri-transforms
	     (list
	      ;;
	      ;; Define transformation to compensate for cleanURL
	      '("http://some.site.se\\(/[A-Z]\\|\\?\\)"
		"http://some.site.se"
		"http://some.site.se/wiki/pmwiki.php")
 	      ;;
	      ;; Define transformation to add 'user:password'
	      '("http://some.site.se/"
		"http://some.site.se/"
		"http://user:password@some.site.se/")))

Just so you know what is happening here.. each transformation consists of
three parts. First a regular expression that is used to check if the
current transformation should be applied to the URI in question. Then a
string that will be matched against the URI and finally replaced by the
third string.

Also note that you should be able to define your own 'shortcuts' using 
this transformation table... this should work for instance:

	(set 'pmwiki-uri-transforms
	     (list
	      ;;
	      ;; Define transformation to compensate for cleanURL
	      '("mysite:\\([A-Z]\\|\\?\\)"
		"mysite:"
		"http://some.site.se/wiki/pmwiki.php/")))

It should let you give 'mysite:Group.Page' as the argument to pmwiki-open 
and have it open the page 
	http://some.site.se/wiki/pmwiki.php/Group/Page

So, try the above and get back to me with how it works out.

/Christian

-- 
Christian Ridderström, +46-8-768 39 44               http://www.md.kth.se/~chr





More information about the pmwiki-users mailing list