nmh-workers
[Top] [All Lists]

Re: folder-specific defaults?

2002-06-27 18:34:36
On June 27, 2002 at 15:08, Scott Blachowicz wrote:

Yeah...I'd thought of that, but the arg list parsing problem (that you
mentioned) is what made me want to check to see if anyone had done
a more general solution. Also, I kinda vaguely remembered that exmh had
something like this (folder-specific settings) and thought that it could
have enough general appeal to be a reasonable addition to nmh.

The argument list parsing is straight-forward to do.  Since I am
more comfortable doing this kind of thing in Perl, here is a stab at
it:

  #!/usr/bin/perl
  # Author: Earl Hood, <earl(_at_)earlhood(_dot_)com>

  # Pathname to MH/nmh scan program
  my $nmh_scan='/usr/bin/scan';

  # Determine which folder we are scanning
  my $folder;
  foreach (@ARGV) {
    if (/^\+/) {
      $folder = $_;
      last;
    }
  }
  my $mhpath = ($folder) ? `mhpath $folder` : `mhpath`;
  chomp $mhpath;

  # Generate pathname to folder-specific scan format file
  my $scan_format = join('/', $mhpath, 'scan.format');

  # Execute nmh scan
  if (-e $scan_format) {
    exec $nmh_scan, '-form', $scan_format, @ARGV;
  } else {
    exec $nmh_scan, @ARGV;
  }

  __END__

All we care about is any argument starting with a '+', so nothing
complex is required.

The program would be simple to modify if you prefer to group
all folder-specific scan format files in a specific directory
instead of under the mail folder itself.

--ewh


<Prev in Thread] Current Thread [Next in Thread>