[comp.mail.mh] Hierarchical folders in MH

dce@smsc.sony.com (David Elliott) (12/10/89)

One of the users here has 600 mail folders, and would like to
organize these hierarchically.  He can use mail, but is pushing
for a SparcStation so he can use mailtool (we're not exactly a
Sun shop ;-).

Is there any way to do this in MH?

-- 
David Elliott
dce@smsc.sony.com | ...!{uunet,mips}!sonyusa!dce
(408)944-4073
"It's bigger than a breadbox, and smaller than the planet Jupiter."

khera@macbeth.cs.duke.edu (Vick Khera) (12/10/89)

In article <1989Dec9.210326.5398@smsc.sony.com> dce@smsc.Sony.COM (David Elliott) writes:
>One of the users here has 600 mail folders, and would like to
>organize these hierarchically.  He can use mail, but is pushing
> ...
>Is there any way to do this in MH?

yes.  something like refile +folder/subfolder would do the trick. you would
also probably want to add the -recurse flag to the options to some of the
mh commands (such as folders) in your .mh_profile so that they will list
those sub-folders also. read the man page on "folder"

							v.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vick Khera                              Department of Computer Science
ARPA:   khera@cs.duke.edu               Duke University
UUCP:   ..!{mcnc,decvax}!duke!khera     Durham, NC 27706

treese@crltrx.crl.dec.com (Win Treese) (12/10/89)

In article <16411@duke.cs.duke.edu> khera@cs.duke.edu (Vick Khera) writes:
->In article <1989Dec9.210326.5398@smsc.sony.com> dce@smsc.Sony.COM (David Elliott) writes:
->>One of the users here has 600 mail folders, and would like to
->>organize these hierarchically.  He can use mail, but is pushing
->> ...
->>Is there any way to do this in MH?
->
->yes.  something like refile +folder/subfolder would do the trick. you would
->also probably want to add the -recurse flag to the options to some of the
->mh commands (such as folders) in your .mh_profile so that they will list
->those sub-folders also. read the man page on "folder"

And xmh in X11R4 will support subfolders as well.  It's pretty spiffy.


Win Treese						Cambridge Research Lab
treese@crl.dec.com					Digital Equipment Corp.

tchrist@convex.COM (Tom Christiansen) (12/11/89)

In article <1409@crltrx.crl.dec.com> treese@crltrx.crl.dec.com.UUCP (Win Treese) writes:
>And xmh in X11R4 will support subfolders as well.  It's pretty spiffy.

What else does xmh do in X11R4 beyond what it does now?

--tom

    Tom Christiansen                       {uunet,uiucdcs,sun}!convex!tchrist 
    Convex Computer Corporation                            tchrist@convex.COM
		 "EMACS belongs in <sys/errno.h>: Editor too big!"

jw@sics.se (Johan Widen) (12/11/89)

One thing that keeps bothering me, but which I have never got around to fix
(8-(), is that completion in the emacs mh-rmail package does not work
on subfolders. When I try to open a subfolder for the first time, name
completion does not work. When I do it a second time however, emacs will
now about the subfolder, but not about any other as yet unopened
subfolders.
--
Johan Widen
SICS, PO Box 1263, S-164 28 KISTA, SWEDEN	Internet: jw@sics.se
Tel: +46 8 752 15 32	Ttx: 812 61 54 SICS S	Fax: +46 8 751 72 30

mdb@ESD.3Com.COM (Mark D. Baushke) (12/11/89)

On 10 Dec 89 22:28:55 GMT, jw@sics.se (Johan Widen) said:

Johan> One thing that keeps bothering me, but which I have never got
Johan> around to fix (8-(), is that completion in the emacs mh-rmail
Johan> package does not work on subfolders. When I try to open a
Johan> subfolder for the first time, name completion does not work.
Johan> When I do it a second time however, emacs will now about the
Johan> subfolder, but not about any other as yet unopened subfolders.

Johan> Johan Widen
Johan> SICS, PO Box 1263, S-164 28 KISTA, SWEDEN	Internet: jw@sics.se
Johan> Tel: +46 8 752 15 32	Ttx: 812 61 54 SICS S	Fax: +46 8 751 72 30

The following may be of interest to you. I hacked it up for my own
use.

I would suggest that you save the value of the mh-folder-list as it
may take some time generate. Only do the my-mh-make-big-folder-list
when you need the list updated.

(defun my-mh-make-big-folder-list ()
  "Return a list of the user's folders.
Result is in a form suitable for completing read."
  (interactive)
  (message "Collecting folder names...")
  (save-window-excursion
    (mh-exec-cmd-quiet " *mh-temp*" "folders" "-fast" "-recurse")
    (goto-char (point-min))
    (let ((list nil))
      (while (not (eobp))
	(let ((start (point))
	      (count 0))
	  (search-forward "\n" nil t)
	  (let ((folder (buffer-substring start (- (point) 1))))
	    (mh-push (list (format "+%s" folder)) list))))
      (message "Collecting folder names...done")
      list)))

(setq mh-folder-list (my-mh-make-big-folder-list))

Enjoy!
-- 
Mark D. Baushke
Internet:   mdb@ESD.3Com.COM
UUCP:	    {3comvax,auspex,sun}!bridge2!mdb

jw@sics.se (Johan Widen) (12/11/89)

In article <MDB.89Dec10232421@kosciusko.ESD.3Com.COM> mdb@ESD.3Com.COM (Mark D. Baushke) writes:
mdb> On 10 Dec 89 22:28:55 GMT, jw@sics.se (Johan Widen) said:
Johan> One thing that keeps bothering me, but which I have never got
Johan> around to fix (8-(), is that completion in the emacs mh-rmail
Johan> package does not work on subfolders. When I try to open a

mdb> The following may be of interest to you. I hacked it up for my own
mdb> use.

mdb> I would suggest that you save the value of the mh-folder-list as it
mdb> may take some time generate. Only do the my-mh-make-big-folder-list
mdb> when you need the list updated.

Thanks, your code works like a charm. The code prompted me to look for similar
names in mh-e.el. I found a variable
	mh-recursive-folders
that by default is nil. If this variable is set to t, then mh-e will check
for subfolders:
	(setq mh-recursive-folders t)
This is in emacs 18-55. As Mark indicated, the recursive search is considerably
slower than the nonrecursive search, thus the default value of nil for
mh-recursive-folders.

My recommendation is: if you use subfolders, then turn on the variable or use
Mark's code, you will like it.
--
Johan Widen
SICS, PO Box 1263, S-164 28 KISTA, SWEDEN	Internet: jw@sics.se
Tel: +46 8 752 15 32	Ttx: 812 61 54 SICS S	Fax: +46 8 751 72 30

khera@macbeth.cs.duke.edu (Vick Khera) (12/12/89)

In article <3826@convex.UUCP> tchrist@convex.COM (Tom Christiansen) writes:
>In article <1409@crltrx.crl.dec.com> treese@crltrx.crl.dec.com.UUCP (Win Treese) writes:
>>And xmh in X11R4 will support subfolders as well.  It's pretty spiffy.
>What else does xmh do in X11R4 beyond what it does now?
>--tom

I certainly hope it will recognize the -annotate switch to repl.  i really
like this feature, and running xmh i lose it.

							v.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vick Khera                              Department of Computer Science
ARPA:   khera@cs.duke.edu               Duke University
UUCP:   ..!{mcnc,decvax}!duke!khera     Durham, NC 27706

shri@ccs1.cs.umass.edu (H.Shrikumar{shri@ncst.in}) (12/12/89)

In article <1989Dec9.210326.5398@smsc.sony.com>
     dce@smsc.Sony.COM (David Elliot t) writes:

>One of the users here has 600 mail folders, and would like to
>organize these hierarchically.  

  Yes, I do it all the time in MH. However you cant create the folder
from within MH .. the "mkdir" call inside refile fails, since it does not
recursively creat the path if more than one level is needed.

  I do a "mkdir Mail/Info/topicx" to create a new folder for each topic,
and "refile Info/topicx" works after that.

-- shrikumar ( shri@ccs1.cs.umass.edu, shri@ncst.in )

ken@cs.rochester.edu (Ken Yap) (12/15/89)

|  Yes, I do it all the time in MH. However you cant create the folder
|from within MH .. the "mkdir" call inside refile fails, since it does not
|recursively creat the path if more than one level is needed.
|
|  I do a "mkdir Mail/Info/topicx" to create a new folder for each topic,
|and "refile Info/topicx" works after that.

However you can create the intermediate folder with "folder" and then
refile to subfolders of that. Avoids having to know the MH path.

Another neat trick I do is to symlink +junk to /tmp. Now I have a scratch
folder I can burst digests in, experiment, etc.

marvit%hplpm@HPLABS.HP.COM (Peter Marvit) (12/15/89)

> >One of the users here has 600 mail folders, and would like to
> >organize these hierarchically.  

>   Yes, I do it all the time in MH. However you cant create the folder
> from within MH .. the "mkdir" call inside refile fails, since it does not
> recursively creat the path if more than one level is needed.

I have a patch which will allow recursve folder creation.  I've sent it on
to John Romnie to be incorporated into the "official" MH6.6.  If readers of
this list want the patch ahead of time, mail me.  More than 5 requests
means I'll post it.

Oh, it may have to wait till after 2 Jan, since I'm leaving on vacation in
two days ;-)

	-Peter "MH 'R Me" Marvit

: Peter Marvit   Hewlett-Packard Labs in Palo Alto, CA   (415) 567-6883    :
: Internet: <marvit@hplabs.hp.com>      uucp: {any backbone}!hplabs!marvit :

leres@ace.ee.lbl.gov (Craig Leres) (12/15/89)

Peter Marvit writes:
> I have a patch which will allow recursve folder creation.  I've sent it on
> to John Romnie to be incorporated into the "official" MH6.6.  If readers of
> this list want the patch ahead of time, mail me.  More than 5 requests
> means I'll post it.
>
> Oh, it may have to wait till after 2 Jan, since I'm leaving on vacation in
> two days ;-)

Well perhaps while we're waiting for you to post your version people
will be interested in looking at mine...

		Craig

------ sbr/makedir.c
/* @(#) $Header: makedir.c,v 1.3 89/12/14 21:13:03 leres Exp $ (LBL) */
/* makedir.c - make a directory */

#include "../h/mh.h"
#include <stdio.h>
#include <errno.h>

extern int errno;


makedir(dir)
	register char *dir;
{
	register int i, pid;
	register char *cp;
	char temp[BUFSIZ];

	m_update();
	(void) fflush(stdout);

#ifdef	BSD42
	if (getuid() == geteuid()) {
		errno = 0;
		if ((i = mkdir(dir, 0755)) < 0 && errno == ENOENT) {
			/* Attempt to create higher level directories */
			cp = strcpy(temp, dir);
			if (*cp == '/')
				++cp;
			while (cp = index(cp, '/')) {
				*cp = '\0';
				errno = 0;
				if ((i = mkdir(temp, 0755)) < 0 &&
				    errno != EEXIST)
					break;
				*cp++ = '/';
			}
			if (i >= 0)
				i = mkdir(temp, 0755);
		}
		if (i < 0) {
			advise(dir, "unable to create directory");
			return(0);
		}
	} else
#endif	BSD42
		switch (pid = vfork()) {

		case NOTOK:
			advise("fork", "unable to");
			return(0);

		case OK:
			(void) setgid(getgid());
			(void) setuid(getuid());

			execl("/bin/mkdir", "mkdir", dir, NULLCP);
			execl("/usr/bin/mkdir", "mkdir", dir, NULLCP);
			fprintf(stderr, "unable to exec ");
			perror("mkdir");
			_exit(-1);

		default:
			if (pidXwait(pid, "mkdir"))
				return(0);
			break;
		}

	if ((cp = m_find("folder-protect")) == NULL)
		cp = foldprot;
	(void) chmod(dir, atooi(cp));
	return(1);
}