Hi Tim,

Tim Chase schrieb am 27.09.2023 21:36:57:
> Does anyone have any suggestions/mappings that might make it easier
> to add/manage add/manage these headers rather than hand-entering
> them with {edit-headers} in the message-compose menu? 

If you use vim you could use imap in ~/.vim/ftplugin/mail.vim:
imap .urg Priority: urgent<CR>
Typing .urg would then fill write the header at this point. (given that
you have “set edit_headers=yes”

> Preferrably picking from a list rather than remembering the exact
> text/number for each header.

You could refine the attached script I use to set X-Label which uses
formail and bash to create such a “user interface”.
It can be used by binding a key like this:

macro compose P "<enter-command>set 
editor=\"~/.mutt/editlabel\"<enter><edit><enter-command>set editor=vim<enter>" 
"Change label"

This sets the editor to your “Priority” script and then resets it back
to your favourite editor.

Best Regards,
PM

#!/bin/bash
# Hiermit kann man E-Mail aus Mutt heraus labeln
# Folgender vereinfachter Dialog soll angezeigt werden:
#
#[1] Label1     (+)
#[2] Label2     (+)
#[3] Label3     (+)
#[4] Label4     (+)
#[c] Clear All
#[x] Do Nothing

# $1 is the filename

# Konsole reinigen
clear

# Configuration
# this file contains one valid label per line
LFILE="$HOME/.mutt/labels"

FNAME="$1"
NFNAME="/tmp/editlabels-`basename "$1"`.$$"


# Start
# multiline variablen imm mit Anführungszeichen (echo "$existLabels") ausgeben
existLabels=`formail -c -z -x X-Label < "$FNAME" | sed 's/ /\n/g'`
stdLabels=`cat $LFILE`
allLabels=`echo "${stdLabels}"$'\n'"${existLabels}" | sort | uniq`

# Anzeige generieren
i=1;
for label in $allLabels 
do
  del=`grep $label <(echo "$existLabels") | wc -l`
  if [ $del -eq 1 ]; then
    echo -e "\e[1;31m[$i]\e[0m $label"$'\t'"\e[1;31m(-)\e[0m";
  else
    echo -e "\e[1;32m[$i]\e[0m $label"$'\t'"\e[1;32m(+)\e[0m";
  fi
  i=$(($i+1));
done

echo -e "\e[1;31m[c] Clear All\e[0m";
echo -e "[*] Do Nothing";


# Input lesen
read -n 1 choice 

# Input auswerten
re='[0-9]'
if [ "$choice" == "c" ]; then
  # Alles Tags löschen
  echo OK $choice
  formail -I "X-Label:" < "$FNAME" > "$NFNAME"
elif [[ "$choice" =~ $re ]]; then
  # Nummerneingabe prüfen

  i=1;
  for label in $allLabels 
  do
    if [ $i -eq $choice  ]; then
        del=`grep $label <(echo $existLabels) | wc -l`
        if [ $del -gt 0 ]; then
                # Entfernen
                new=`echo "X-Label: $existLabels" | tr '\n' ' ' | sed 
"s/$label//g" | sed "s/[ ]*$//g"`
                #echo löschen \"$new\"
                formail -I "$new" < "$FNAME" > "$NFNAME"
        else
                # Hinzufügen 
                new=`echo "X-Label: $existLabels $label" | tr '\n' ' ' | sed 
"s/[ ]*$//g"`
                #echo hinzufügen \"$new\"
                formail -I "$new" < "$FNAME" > "$NFNAME"
        fi
    fi 

    i=$(($i+1));
  done


else
        exit
fi

# Abspeichern sofern formail eine neue Datei geschrieben hat
if [ -f "$NFNAME" ]; then
        mv "$NFNAME" "$FNAME"
fi

# Konsole reinigen
clear

Reply via email to