bmc@sei.cmu.edu (Brian M. Clapper) (06/08/89)
When I first started using MH, I established a catch-all folder for those messages I couldn't or wouldn't categorize properly. This folder became the place to throw anything miscellaneous -- in effect, my default folder. However, I could find no way to tell refile that it was to place messages in this folder if I didn't explicitly specify one. When I found the source, I made a quick hack allowing me to specify a single default folder in an environment variable. One can undoubtedly enhance this idea, but I stopped there, since this solution was more than sufficient for my needs. To my knowledge, no one has added this feature to the latest releases, so I'm posting the patch for it, as well as appropriate diffs to the manual page. Use it if you're interested; ignore it if you're not. :^) There may be better ways to accomplish this; as I said, I'm not intimate with the MH source. However, I've been using my local refile variant for several months now with no trouble. The patch should work for 6.5 and 6.6. Brian Clapper Software Engineering Institute Pittsburgh, PA 15213 -------------------------- refile.c patch - CUT HERE -------------------------- *** refile.c.old Thu Oct 29 18:02:41 1987 --- refile.c Wed Jun 7 12:35:33 1989 *************** *** 8,13 /* */ static struct swit switches[] = { #define DRAFTSW 0 "draft", 0, --- 8,15 ----- /* */ + #define DEF_FOLDER_ENV_VAR "REFILE_DEFAULT" + static struct swit switches[] = { #define DRAFTSW 0 "draft", 0, *************** *** 64,69 i, msgnum; char *cp, *folder = NULL, buf[100], **ap, --- 66,72 ----- i, msgnum; char *cp, + *s, *folder = NULL, buf[100], **ap, *************** *** 150,157 if (!m_find ("path")) free (path ("./", TFOLDER)); ! if (foldp == 0) ! adios (NULLCP, "no folder specified"); #ifdef WHATNOW if (!msgp && !filep && (cp = getenv ("mhdraft")) && *cp) --- 153,171 ----- if (!m_find ("path")) free (path ("./", TFOLDER)); ! if (foldp == 0) { ! /* Check the environment for a default folder specification. */ ! if ( ((s = getenv (DEF_FOLDER_ENV_VAR)) == NULL) || ! (strlen (s) == 0) ) ! adios (NULLCP, "no folder specified"); ! else { ! folders[foldp].f_name = ! path (s + 1, *s == '+' ? TFOLDER : TSUBCWF); ! (void) printf ("Assuming default target folder of \"%s\"\n", ! folders[foldp].f_name); ! foldp++; ! } ! } #ifdef WHATNOW if (!msgp && !filep && (cp = getenv ("mhdraft")) && *cp) -------------------------- refile.1 patch - CUT HERE -------------------------- *** refile.1 Thu Apr 21 10:19:54 1988 --- /usr/users/bmc/man/man1/refile.1 Fri Feb 24 16:37:16 1989 *************** *** 49,54 If a destination folder doesn't exist, \fIrefile\fR will ask if you want to create it. A negative response will abort the file operation. The option `\-link' preserves the source folder copy of the message (i.e., it does a \fIln\fR(1) rather than a \fImv\fR(1)), whereas, --- 49,58 ----- If a destination folder doesn't exist, \fIrefile\fR will ask if you want to create it. A negative response will abort the file operation. + If you don't specify a destination folder, \fIrefile\fR will examine + environment variable \fBREFILE_DEFAULT\fR to see if one is specified there. + \fBREFILE_DEFAULT\fR may contain only one folder name; this name should + be specified in the same way as it would be on the command line. The option `\-link' preserves the source folder copy of the message (i.e., it does a \fIln\fR(1) rather than a \fImv\fR(1)), whereas,
trost@reed.UUCP (Bill Trost) (06/09/89)
[I cross-posted this to local.computing because enough Reedies use mh that they may find this useful. Check followup Newsgroups: fields carefully.] In article <3462@dx.sei.cmu.edu> bmc@sei.cmu.edu (Brian M. Clapper) writes: >When I first started using MH, I established a catch-all folder for those >messages I couldn't or wouldn't categorize properly. This folder became >the place to throw anything miscellaneous -- in effect, my default folder. >However, I could find no way to tell refile that it was to place messages >in this folder if I didn't explicitly specify one. >When I found the source, I made a quick hack allowing me to specify a single >default folder in an environment variable. This, actually, is unnecessary, at least in mh6.5. Simple add the line refile: +catch-all to your .mh_profile, and refile will use that as the default folder. Not only already there, but it avoids introducing yet another environment variable as well. This sort of trick can be used to your advantage elsewhere as well. For instance, I have a symlink to scan called "inbox" in my path. In my .mh_profile, I have the line inbox: +inbox which lets simply type "inbox" to get the scan listing of my inbox. (Say "nifty" :-) ). -- Whaddya mean, these are *my* opinions?? I never wrote that! Bill Trost trost@reed.bitnet, but probably ...!tektronix!reed!trost
bmc@sei.cmu.edu (Brian M. Clapper) (06/09/89)
In article <12841@reed.UUCP> trost@reed.UUCP (Bill Trost) writes: > >This, actually, is unnecessary, at least in mh6.5. Simple add the line > > refile: +catch-all > >to your .mh_profile, and refile will use that as the default folder. Not >only already there, but it avoids introducing yet another environment >variable as well. I tried this before I ever patched refile, and I just tried it again to make sure I didn't screw up the first time. Verdict: Nope, this doesn't do what I want. What I want is for refile to use my default folder only if I don't specify one on the command line. If I specify one, I want that one used instead, hence the use of the term 'default'. Doing what you suggest results in the correct behavior when I don't specify a folder on the command line. However, if I *do* specify one, my letter gets refiled in two places: the so-called default specified in .mh_profile *and* the one I specified. I'd love not to have had to screw around with the source, but I could think of no other way to do what I wanted. Nice try, though. -- Brian M. Clapper Software Engineering Institute <bmc@sei.cmu.edu> Pittsburgh, PA 15213 "I was trying to daydream, but my mind kept wandering." -- S. Wright
mpf@csli.Stanford.EDU (Michael Frank) (06/11/89)
Impressive work, that refile patch. I had the same complaint about refile. I'm not a UNIX hacker, though, so I tackled this problem from the average user's point of view: I wrote an alias. Other clueless users like me may want to use this in their .cshrc instead of recompiling their refile program: alias rfm 'refile +misc' Where misc is the name of my folder for miscellaneous uncategorizable junk. So, it's not elegant, and it's slower, but hey, it's easy. -- Michael Frank "The Ear-God" Undergrad, Symbolic Systems. Life is good. mpf@csli.stanford.edu *8^} Looking forward to summer: friends, family, (415) EAR-0-GOD "I listen." trips, AI, beach, juggling, swimming, parties... After 6/15: use that date as area code, and dial FIG-WIGS. (Family's house.)
mcgrew@ichthous.Sun.COM (Darin McGrew) (06/13/89)
In article <9370@csli.Stanford.EDU>, mpf@csli.stanford.edu (Michael Frank) writes: >alias rfm 'refile +misc' Another approach is to create a symlink to refile called rfm, and then add "rfm: +misc" to your .mh_profile. Darin McGrew mcgrew@Sun.COM
gregg@cbnewsc.ATT.COM (gregg.g.wonderly) (06/14/89)
For those thinking about adding certain defaults to MH, please keep them in the .mh_profile file. Use m_find() instead of getenv(). They both return (char *). m_find() searches both .mh_profile, and the {path}/context file, so beware of using something that might exist in {path}/context. For the refile(1) example, something like if (folder == NULL) folder = m_find ("refile-default"); seems appropriate. Then you can add the line refile-default: +misc to your .mh_profile. I am not sure whether I prefer the symlink to another command name in this case or not. For the next release of MH, I would like to see a new program incorporated which allows use/manipulation of the {path}/context and .mh_profile entries. I have written one such program which I called, mhcontext. It has the options -delete, -component and -text. When envoked with '-comp string', it prints the value of that entry on stdout. E.g. $ mhcontext -comp Unseen-sequence unread $ This gives shell script front ends half a change at being portable given the flexibility that MH provides. $ mhcontext -comp oFolder-stack -text "`mhcontext -comp folder-stack`" $ alias popfs 'mhcontext -comp folder-stack -text \ "`mhcontext -comp ofolder-stack`"' $ mhcontext -comp Folder-Stack -text "`seq unread`" Allows me to use my seq(1) program (which I described here previously, to 1) Save the previous folder stack. 2) Create an alias which allows me to restore the saved value 3) Create a new folder stack containing the folders with messages having the 'unread' sequence set. There are many other possibilities, I won't enumerate them here. The -delete switch allows you to delete a component from the {path}/context file (attempts to delete something from .mh_profile yield an interesting message). This options intended usage is to allow the context file to be accessed by scripts which will maintain their own information there. Comments? -- ----- gregg.g.wonderly@att.com (AT&T bell laboratories)