Subject: [sup-talk] Tilde in maildir/mbox paths

From: [email-masked] (Magnus Therning)
Date: Fri, 7 Sep 2007 08:37:21 +0100

I find it useful to be able to stick '~' in paths so here's an attempt
at a patch that allows a source with the URI maildir:~/mail/in.

Two comments:

 1. I didn't really know where to stick expand_uri so it's duplicated in
    Maildir and Mbox.  This is far from ideal.  Please tell me where it
    belongs.

 2. Parsing URIs of the form maildir://~/mail/in seems to be
    problematic:

      irb(main):001:0> require 'uri'
      => true
      irb(main):002:0> URI('maildir://~/mail/in')
      URI::InvalidURIError: the scheme maildir does not accept registry part: ~ (or bad hostname?)
              from /usr/lib/ruby/1.8/uri/generic.rb:195:in `initialize'
              from /usr/lib/ruby/1.8/uri/common.rb:492:in `new'
              from /usr/lib/ruby/1.8/uri/common.rb:492:in `parse'
              from /usr/lib/ruby/1.8/uri/common.rb:608:in `URI'
              from (irb):2
              from :0

    I don't know how to get around this so I changed the help text for
    sup-add.

/M

-- 
Magnus Therning                             (OpenPGP: 0xAB4DFBA4)
magnus?therning?org             Jabber: magnus?therning?gmail?com
http://therning.org/magnus

As we enjoy great advantages from the inventions of others we should
be glad of an opportunity to serve others by any invention of
ours, and this we should do freely and generously.
     -- Benjamin Franklin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sup_514-1.diff
Type: text/x-diff
Size: 2454 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20070907/6f68e559/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20070907/6f68e559/attachment-0001.bin

---

From: [email-masked] (Magnus Therning)
Date: Fri, 07 Sep 2007 19:47:59 +0100

Excerpts from Magnus Therning's message of Fri Sep 07 10:21:09 +0100 2007:
> On Fri, Sep 07, 2007 at 08:37:21 +0100, Magnus Therning wrote:
> An obvious place would of course be the parent class Source.  For some
> strange reason that didn't enter my mind while I was hacking on this.

A modified patch is attached.

What if I don't want to obey the laws? Do they throw me in jail with
the other bad monads?
     -- Daveman
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sup_514-2.diff
Type: application/octet-stream
Size: 2273 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20070907/4d16512d/attachment.obj

---

From: [email-masked] (William Morgan)
Date: Thu, 13 Sep 2007 19:45:56 -0700

Hi Magnus,

> at a patch that allows a source with the URI maildir:~/mail/in.

Thanks for the patch! What about modifying this slightly so that the
~-expansion is done at the string level instead of the URI level, in a
method called Source#expand_filesystem_uri or something. Then Maildir
and MBox::Loader sticks the output of that method into URI.

I think that change will solve two problems: it will make clear that the
expansion method is filesystem-specific (i.e. even though the method is
in Source, only filesystem sources want to call it), and it will allow
us to support URIs the "right way", without the weird #opaque stuff and
without dropping all mbox:// and maildir:// URLs. What do you think?

-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (Magnus Therning)
Date: Fri, 14 Sep 2007 22:38:23 +0100

On Thu, Sep 13, 2007 at 19:45:56 -0700, William Morgan wrote:
>I think that change will solve two problems: it will make clear that
>the expansion method is filesystem-specific (i.e. even though the
>method is in Source, only filesystem sources want to call it), and it
>will allow us to support URIs the "right way", without the weird
>#opaque stuff and without dropping all mbox:// and maildir:// URLs.
>What do you think?

File.expand_path requires the tilde to be at the start of its argument,
so that prompted the strange #opaque stuff.  I made some changes and
stuck a modified patch in the attachment.  Let me know what you think.

/M

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20070914/f67d4866/attachment.bin

---

From: [email-masked] (Magnus Therning)
Date: Fri, 14 Sep 2007 23:44:26 +0100

>stuck a modified patch in the attachment.  Let me know what you think.

This time with the attachment...

/M

Of course I laugh at my own jokes. You can't trust strangers.
     -- Phyllis Diller
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sup_529-1.diff
Type: text/x-diff
Size: 1444 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20070914/79e8f0e8/attachment-0002.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20070914/79e8f0e8/attachment-0003.bin

---

From: [email-masked] (William Morgan)
Date: Fri, 14 Sep 2007 20:41:28 -0700

> This time with the attachment...

Time to turn on :confirm_no_attachments!

I've applied your patch, with a couple changes. Thanks!

---

From: [email-masked] (Magnus Therning)
Date: Sat, 15 Sep 2007 11:19:16 +0100

>I've applied your patch, with a couple changes. Thanks!

I really should have found String::gsub myself.  I was just so confused
by the existence of String::replace and what it does...

One thing though.  You've moved the expansion of tilde so that the
expanded URI is passed to Source and it ends up in .sup/sources.yaml.
My intention was to have the tilde unexpanded in .sup/sources.yaml.
This would allow sharing of sup configuration between different
accounts, as long as the locations of mail boxes are the same relative
to the home directory.

The reason is again my own mail set-up.  Mutt takes paths to mail boxes
and expands tilde.  This allows me to have identical Mutt configurations
on machines where I have different login names (at some places I don't
have the luxury of getting to choose my own login, e.g. at work).

I've attached a patch that moves the expansion back to the sub-classes
again.

/M

-------------- next part --------------
A non-text attachment was scrubbed...
Name: sup_537-1.patch
Type: text/x-diff
Size: 1595 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20070915/ea163096/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20070915/ea163096/attachment-0001.bin

---

From: [email-masked] (William Morgan)
Date: Mon, 17 Sep 2007 10:30:02 -0700

> I've attached a patch that moves the expansion back to the sub-classes

Applied, thanks!