Re: Can mutt prefetch mail

2017-05-15 Thread Yubin Ruan
On Tue, May 16, 2017 at 12:42:32PM +1000, Cameron Simpson wrote:
> On 16May2017 16:14, Yubin Ruan  wrote:
> >On Sun, May 14, 2017 at 09:33:46AM +1000, Cameron Simpson wrote:
> >>The other common solution for IMAP mail accounts is offlineimap, which will
> >>mirror IMAP accounts to local storage.
> [...]
> >Yes offlineimap _is_ very tricky to setup. It cannot handle non-ascii
> >characters correctly. I have several folders on the Gamil server whose name 
> >is in Chinese.
> >I setup a `nametrans' in the .offlineimaprc:
> >   nametrans = lambda foldername: 
> > foldername.decode('imap4-utf-7').encode('utf-8')
> 
> You also have a reverse name trans, yes? Both are needed. And one should
> take care that they really are the reverse of each other.

Hmm...turns out that I have too many accounts set up so that I forget one of the
reverse namestrans.

> 
> >it works great in the first download, but will throw some encoding/decoding 
> >errors
> >in the sync afterwards:
> >   'ascii' codec can't decode byte 0xe9 in position 8: ordinal not in 
> > range(128)
> >
> >I don't know why a software would only support ascii in the 21st century...
> 
> The offlineimap authors are definitely not pure Western
> can-get-by-with-ASCII people, so I expect they're aware of this shortcoming.
> 
> Is imap4-utf-7 a known encoding? My local Python 3 says:
> 
>  % python3 -c 'print(repr(b"foo".decode("imap4-utf-7")))'
>  Traceback (most recent call last):
>File "", line 1, in 
>LookupError: unknown encoding: imap4-utf-7
> 
> It is possible that your exception above comes from another part of the
> code; what is the stack trace? It would also be useful to hack things to
> print the repr of the undecodable string: do you know it is a mailbox name?
> 
> IIRC offlineimap uses python 2, which is a bit vague in distinguishing
> strings and bytes.

Here is the encode/decode python script I use currently:
https://gist.github.com/gauteh/5402888

--
Yubin


Re: Can mutt prefetch mail

2017-05-15 Thread Cameron Simpson

On 16May2017 16:14, Yubin Ruan  wrote:

On Sun, May 14, 2017 at 09:33:46AM +1000, Cameron Simpson wrote:

The other common solution for IMAP mail accounts is offlineimap, which will
mirror IMAP accounts to local storage.

[...]
Yes offlineimap _is_ very tricky to setup. It cannot handle non-ascii 
characters correctly. I have several folders on the Gamil server whose name is in Chinese.

I setup a `nametrans' in the .offlineimaprc:
   nametrans = lambda foldername: 
foldername.decode('imap4-utf-7').encode('utf-8')


You also have a reverse name trans, yes? Both are needed. And one should take 
care that they really are the reverse of each other.



it works great in the first download, but will throw some encoding/decoding 
errors
in the sync afterwards:
   'ascii' codec can't decode byte 0xe9 in position 8: ordinal not in 
   range(128)


I don't know why a software would only support ascii in the 21st century...


The offlineimap authors are definitely not pure Western can-get-by-with-ASCII 
people, so I expect they're aware of this shortcoming.


Is imap4-utf-7 a known encoding? My local Python 3 says:

 % python3 -c 'print(repr(b"foo".decode("imap4-utf-7")))'
 Traceback (most recent call last):
   File "", line 1, in 
   LookupError: unknown encoding: imap4-utf-7

It is possible that your exception above comes from another part of the code; 
what is the stack trace? It would also be useful to hack things to print the 
repr of the undecodable string: do you know it is a mailbox name?


IIRC offlineimap uses python 2, which is a bit vague in distinguishing strings 
and bytes.


Cheers,
Cameron Simpson 


Re: Can mutt prefetch mail

2017-05-15 Thread Yubin Ruan
On Sun, May 14, 2017 at 09:33:46AM +1000, Cameron Simpson wrote:
> On 13May2017 17:32, Yubin Ruan  wrote:
> >I am wondering whether it is possible to tell mutt to prefetch mails folder 
> >by
> >folder so that I can read mails more quickly without waiting for the 
> >"Fetching
> >mails..." every time.
> >
> >I have set up mutt's cache, so it helps a little, but it is still slow 
> >because I
> >have to fetch the mails before mutt can cache them.
> >
> >I know there is something like `fetchmail', but, setting up it is tricky,
> >especially with a IMAP server (or, do you have good references?)
> 
> The other common solution for IMAP mail accounts is offlineimap, which will
> mirror IMAP accounts to local storage.
> 
> Because mutt is single threaded, all "prefetch" arrangements tend to store
> the mail locally. This is several advantages:
> 
>  - you don't need to configure mutt to access a remote mailbox
> 
>  - if you're offline all your mail is still there (as of the last update)
> 
>  - access is _very_ fast, because it is local file access
> 
>  - if you run a local mail system, you can reply to email even when offline;
> it will queue locally on your machine until there is network access.
>I find this great for train trips. This also means you don't need mutt to
> know SMTP settings; just deliver locally via the "sendmail" command.
> 
> The advantage of offlineimap is that (by default) it mirrors your IMAP
> account, keeping a local set of mail folders matching upstream. This means:
> 
>  - you can still access you imap account (eg through a phone or other device)
> 
>  - changes you make locally via mutt, such as deletions of moving messages
> ormarking them read etc, are pushed upstream to your IMAP account for
> you
> 
> Offlineimap _is_ a little tricky to set up, but once running you can let it
> look after the mirroring in the background.

Yes offlineimap _is_ very tricky to setup. It cannot handle non-ascii characters
correctly. I have several folders on the Gamil server whose name is in Chinese.
I setup a `nametrans' in the .offlineimaprc:

nametrans = lambda foldername: 
foldername.decode('imap4-utf-7').encode('utf-8')

it works great in the first download, but will throw some encoding/decoding 
errors
in the sync afterwards:

'ascii' codec can't decode byte 0xe9 in position 8: ordinal not in 
range(128)

I don't know why a software would only support ascii in the 21st century...

--
Yubin