[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nmh-workers] refile and moving sequences with messages

From: Kevin Layer
Subject: Re: [Nmh-workers] refile and moving sequences with messages
Date: Thu, 14 Mar 2013 11:21:32 -0700

OK, got it working.  I don't handle all sequences, just the one I care
about (important).

Below is the code, in case it helps someone else.

.mh_profile gets this addition:

ref-hook: /home/layer/mail/ref-hook.sh

and /home/layer/mail/ref-hook.sh contains:

#! /bin/bash
# Use the refile hook to make sure messages moved in the `important' sequence
# retain membership in that sequence in their destination folder.

prefix=$(mhpath +inbox | sed 's,/inbox$,,')

to=$(echo $2 | sed -e "s|^$prefix/||")

case $to in
    *trash*) ;;
    *)  from=$(echo $1 | sed -e "s|^$prefix/||")

        fromf=$(echo $from | sed -e 's,\(.*\)/\(.*\),\1,')
        tof=$(echo $to | sed -e 's,\(.*\)/\(.*\),\1,')

        # In the case of a repack, sequences are handled properly, so exit
        if [ "$fromf" = "$tof" ]; then
            exit 0

        fromm=$(echo $from | sed -e 's,\(.*\)/\(.*\),\2,')
        tom=$(echo $to | sed -e 's,\(.*\)/\(.*\),\2,')

        if pick +$fromf important -list 2>&1 | egrep -q "^${fromm}\$"; then
            mark +$tof $tom -add -sequence important
            # Need to set the current folder back to $fromf!
            folder +$fromf > /dev/null

reply via email to

[Prev in Thread] Current Thread [Next in Thread]