Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: MAIL, MAILPATH and maildir support



Oliver Kiddle wrote:
> Bart Schaefer wrote:
> > 
> > Perhaps checkmailpath is a candidate for some kind of loadable module ...
> 
> In my opinion, it would be useful to put all of the mail related
> handling in a loadable module and then make that module quite powerful
> (with lots of mush style commands etc). I think it would complement
> stuff like the zftp module very well. I suggested writing such a module
> about 2 years ago and got a mostly negative response. What does anyone
> think?

A module with more powerful mail commands is a reasonable idea, but I have
some reservations.  First, if this is going to be a largish add-on, basic
UNIX mail-file checking (as it currently exists) should probably stay in
the basic shell, since pretty much everybody (? I presume) uses that ---
hence exporting it just gets you all the stuff in the module and doesn't in
practice save anything.  Second, with the plethora of mail systems (the
maildir one is just one example), a general module for mail handling is a
big undertaking.  Third, anybody who wants to use individual commands
rather than a monolothic program to get at the mail is probably well
advised to use MH or some other existing system (the problem with mainting
a connection that made zftp useful as a module doesn't exist).
Nonetheless, if you've got some good ideas for what should go in such a
module --- or even some code --- it would be interesting to see them.

As for things like the patch that started all this: it looks to me like it
could be written efficiently enough as a shell function to be run from one
of the functions periodic or precmd.  You could even divide it into two
parts: first, shell code to replace the checkmailpath() functionality,
which is pretty simple (apart from recursive directory checking, but you
can use **/*(.mm???) to get regular files modified in the last ???  minutes
--- maybe (ms???) should work too, but it doesn't at the moment); second,
any ad-hoc functions to be called for special mail systems.  The only
difficulty with implementing mailstat() in that way is that looping over a
lot of files is slow in zsh functions, but I don't think you need to: if
you're just looking for the most recently modified/accessed file, *(om[1])
and *(oa[1]) are efficient (or will be when 3.1.6 appears), and if you want
the total size (do you? checkmailpath() simply looks to see if it's
non-zero),
    ls -l new/* cur/* | awk '{ tot += $5 } END { print tot }'
works (maybe $4 for BSD).  Such functions could certainly be distributed
with the source.

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



Messages sorted by: Reverse Date, Date, Thread, Author