Re: Adding a custom header to existing mail - Mutt

This is a discussion on Re: Adding a custom header to existing mail - Mutt ; Thanks for the help everyone. I ended up using a combination of the edit command (mentioned by Lech) and the shell script (mentioned by Alan). Remember, this was my question: > In mutt, how do I add a header to ...

+ Reply to Thread
Results 1 to 4 of 4

Re: Adding a custom header to existing mail

  1. Default Re: Adding a custom header to existing mail

    Thanks for the help everyone. I ended up using a combination of the
    edit command (mentioned by Lech) and the shell script (mentioned by
    Alan).

    Remember, this was my question:

    > In mutt, how do I add a header to an existing e-mail?
    > I would like to do this to categorize my mail. So, while browsing
    > mail in mutt, I'd like to hit a key to add a custom header to a
    > particular e-mail to indicate that it's, for example, related to
    > project foo. Then I can later filter on this header to see only mail
    > related to project foo.


    Here's what I did. I added the following line (broken up here for
    clarity) to muttrc:

    macro index <f2> "
    <enter-command>set editor='~/.mutt/markproj.sh foo'<enter>
    <edit>
    <enter-command>set editor='vi'<enter>"

    What this line does is, when F2 is hit, it sets the mutt editor to
    "markproj.sh foo", where markproj.sh is a script that adds a header to
    the e-mail (see below) and foo is the project I want to mark this
    e-mail as. Then it edits the file, which causes mutt to call the
    script with the project name (foo) as the first parameter and the file
    containing the e-mail as the second parameter.

    A stripped down version of markproj.sh looks like this:

    proj=$1
    file=$2
    formail -A "X-Project: $proj" < $file > $file.tmp
    mv $file.tmp $file
    sleep 1
    touch $file

    This uses formail to add the X-Project line to the e-mail. The last
    two lines are needed to ensure that mutt sees a change in the write
    timestamp of the file and realizes that the file has changed.

    I still have a question about mutt:

    - How do I remember/restore the old value of a variable? (It would be
    nice if I could store the value of the editor variable somewhere,
    change it, and reset it back to the original value.) Mutt doesn't seem
    to support custom variables. Is there any plan of adding custom
    variables?

  2. Default Re: Adding a custom header to existing mail

    On 31 Mar 2004 22:08:51 -0800, Jake <jakelundy@hotmail.com> wrote:
    >
    >
    > Thanks for the help everyone. I ended up using a combination of the
    > edit command (mentioned by Lech) and the shell script (mentioned by
    > Alan).
    >


    <snip>

    > I still have a question about mutt:
    >
    > - How do I remember/restore the old value of a variable? (It would be
    > nice if I could store the value of the editor variable somewhere,
    > change it, and reset it back to the original value.) Mutt doesn't seem
    > to support custom variables. Is there any plan of adding custom
    > variables?


    Good of you to post this for the Archives...

    As for storing the variable, you probably need to do that in a file called
    ~/.muttvar or something. Just add a line to the script like:

    echo $var > ~/.muttvar

    and it will overwrite the previous value.

    AC


  3. Default Re: Adding a custom header to existing mail

    Alan Connor <zzzzzz@xxx.yyy> wrote in message news:<Z_Qac.10733$lt2.7037@newsread1.news.pas.earthlink.net>...

    > > - How do I remember/restore the old value of a variable? (It would be
    > > nice if I could store the value of the editor variable somewhere,
    > > change it, and reset it back to the original value.) Mutt doesn't seem
    > > to support custom variables. Is there any plan of adding custom
    > > variables?

    >
    > As for storing the variable, you probably need to do that in a file called
    > ~/.muttvar or something. Just add a line to the script like:
    >
    > echo $var > ~/.muttvar
    >
    > and it will overwrite the previous value.


    From what I understand, "$var" above is a shell environment variable.
    I want "$var" to be a mutt variable. So I'd like to call a script
    *from mutt*, and pass mutt variable values to the script. Is this
    possible?

  4. Default Re: Adding a custom header to existing mail

    On 2 Apr 2004 21:39:08 -0800, Jake <jakelundy@hotmail.com> wrote:
    >
    >
    > Alan Connor <zzzzzz@xxx.yyy> wrote in message news:<Z_Qac.10733$lt2.7037@newsread1.news.pas.earthlink.net>...
    >
    >> > - How do I remember/restore the old value of a variable? (It would be
    >> > nice if I could store the value of the editor variable somewhere,
    >> > change it, and reset it back to the original value.) Mutt doesn't seem
    >> > to support custom variables. Is there any plan of adding custom
    >> > variables?

    >>
    >> As for storing the variable, you probably need to do that in a file called
    >> ~/.muttvar or something. Just add a line to the script like:
    >>
    >> echo $var > ~/.muttvar
    >>
    >> and it will overwrite the previous value.

    >
    > From what I understand, "$var" above is a shell environment variable.


    Not an environment variable, just a shell variable.

    Environment variables are things like $EDITOR and $PATH and $DISPLAY...


    > I want "$var" to be a mutt variable. So I'd like to call a script
    > *from mutt*, and pass mutt variable values to the script. Is this
    > possible?


    Don't know, Jake, but someone around here will, I would think.

    A lot of Mutt's variables are fixed, so those can just be copied.

    As for calling a script from Mutt, you can use the "!" command to
    do that, invoking it from a keyboard macro to save a keystroke
    or two.

    These call fetchmail from Mutt with a capital F.

    macro index F "!fetchmail^M"
    macro pager F "!fetchmail^M"

    Wish I could be of more help.

    AC


+ Reply to Thread

Similar Threads

  1. Adding a custom header to the response
    By Application Development in forum DOTNET
    Replies: 1
    Last Post: 10-31-2007, 10:53 AM
  2. Adding new methods to existing classes
    By Application Development in forum Javascript
    Replies: 18
    Last Post: 08-28-2007, 02:11 PM
  3. Adding an existing IRA account
    By Application Development in forum Microsoft Money
    Replies: 1
    Last Post: 06-24-2007, 05:11 PM
  4. Adding a custom header to all outgoing messages
    By Application Development in forum Pegasus
    Replies: 2
    Last Post: 05-27-2006, 06:00 PM
  5. Importing existing mail from Outlook2002 or Eudora 6 to Pegasus-mail?
    By Application Development in forum Pegasus
    Replies: 7
    Last Post: 09-27-2003, 10:19 AM