Re: Setting X-Priority/Priority/Important headers more easiliy?

2023-09-28 Thread P. Mazart
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
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 "set 
editor=\"~/.mutt/editlabel\"set editor=vim" 
"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


Re: Setting X-Priority/Priority/Important headers more easiliy?

2023-09-27 Thread raf via Mutt-users
On Wed, Sep 27, 2023 at 02:36:57PM -0500, Tim Chase  
wrote:

> Howdy,
> 
> RFC-2156[1] specifies ways to use the headers
> 
>  Importance: {low, normal, high}
>  Priority: {normal, non-urgent, urgent}
>  Sensitivity: {Personal, Private, Company-Confidential}
> 
> and I've also seen the non-standard
> 
>  X-Priority: 1 (Highest)
>  X-MSMail-Priority: High
> 
> (with X-Priority ranging from 1 (Highest) to 5 (lowest)) in the
> wild to convey meta-information about the message.
> 
> 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?  Preferrably
> picking from a list rather than remembering the exact text/number
> for each header.
> 
> Thanks!
> 
> -tkc
> 
> [1] https://datatracker.ietf.org/doc/html/rfc2156

You can define a macro that uses my_hdr for each such header.
Then each one can be a single keystroke.

cheers,
raf