<<< Date Index >>>     <<< Thread Index >>>

related to a patch to bug 624 (was: Re: #2192: mutt save does not use alias names?)



Hi mutt developers,
* Mutt <fleas@xxxxxxxx> [08. Aug. 2010]:
> #2192: mutt save does not use alias names?
> ---------------------------------+------------------------------------------
>  Reporter:  zimcomm@â            |       Owner:  mutt-dev                  
>      Type:  enhancement          |      Status:  new                       
>  Priority:  trivial              |   Milestone:                            
> Component:  mutt                 |     Version:  Mutt 1.4.2.1i (2004-02-12)
>  Keywords:                       |  
> ---------------------------------+------------------------------------------
> Changes (by me):
> 
>   * type:  defect => enhancement
> 
> 
> Old description:
> 
>> {{{
>> A potential switcher from elm (yes I am a dinosaur).
>>
>> There is only one thing I can't figure out...
>>
>> In elm, if you have
>>
>> alias bob bob.barker@xxxxxxxx
>>
>> and bob sends you mail.. when you save that mail it is saved by default a
>> a folder using the alias name (bob), not bob.barker.
>>
>> I can find no such config value to tickle for mutt that will permit the
>> same.  So far every attempt I have made to save mail in mutt ignores the
>> concept that I have aliases defined for these people because I want to
>> save the typing.  Outgoing mail to pp with aliases seems to work fine.
>>
>> >How-To-Repeat:
>> >Fix:
>> Unknown
>> }}}

The attached patch clarifies usage of the %F expando and provides
a new %R expando which expands to the recipients full name.  It
consults alternates and expands aliases.  I use this patch since
years to fcc-save messages according to recipient names.  It
would be great if this functionality would become mainline.  But
I do not rely on this kind of sorted storing of messages any more
since I search for messages via mairix.

The patch still applies on current mutt sources (current as in
debian sid).

Ciao, Gregor



diff -Nur mutt-1.5.17-orig/hdrline.c mutt-1.5.17/hdrline.c
--- mutt-1.5.17-orig/hdrline.c  2007-10-31 18:48:52.000000000 +0100
+++ mutt-1.5.17/hdrline.c       2008-01-10 21:03:05.000000000 +0100
@@ -127,6 +127,31 @@
     *buf = 0;
 }
 
+/* analog to "make_from" but generates "Real Name" of recipient without 
preceding "To "
+ * don't know why original name is "make_from" so name it make_from_without_to
+ */
+static void make_from_without_to (ENVELOPE *hdr, char *buf, size_t len, int 
do_lists)
+{
+  int me;
+  me = mutt_addr_is_user (hdr->from);
+  if (do_lists || me)
+  {
+    if (check_for_mailing_list (hdr->to, "", buf, len))
+      return;
+    if (check_for_mailing_list (hdr->cc, "", buf, len))
+      return;
+  }
+
+  if (me && hdr->to)
+    snprintf (buf, len, "%s", mutt_get_name (hdr->to));
+  else if (me && hdr->cc)
+    snprintf (buf, len, "%s", mutt_get_name (hdr->cc));
+  else if (hdr->from)
+    strfcpy (buf, mutt_get_name (hdr->from), len);
+  else
+    *buf = 0;
+}
+
 static void make_from_addr (ENVELOPE *hdr, char *buf, size_t len, int do_lists)
 {
   int me;
@@ -546,6 +571,25 @@
       strfcpy(dest, NONULL(hfi->pager_progress), destlen);
       break;
 
+/* analog to 'n' but generates "Real Name" of recipient
+ */
+    case 'r':
+      mutt_format_s (dest, destlen, prefix, mutt_get_name (hdr->env->to));
+      break;
+
+/* analog to 'F' but calls "make_from_without_to" and so
+ * generates "Real Name" of recipient without preceding "To "
+ */
+    case 'R':
+      if (!optional)
+      {
+       make_from_without_to (hdr->env, buf2, sizeof (buf2), 0);
+       mutt_format_s (dest, destlen, prefix, buf2);
+      }
+      else if (mutt_addr_is_user (hdr->env->from))
+       optional = 0;
+      break;
+
     case 's':
       
       if (flags & M_FORMAT_TREE && !hdr->collapsed)
diff -Nur mutt-1.5.17-orig/init.h mutt-1.5.17/init.h
--- mutt-1.5.17-orig/init.h     2008-01-10 21:06:57.000000000 +0100
+++ mutt-1.5.17/init.h  2008-01-10 21:05:14.000000000 +0100
@@ -1023,7 +1023,8 @@
   ** .dt %e .dd current message number in thread
   ** .dt %E .dd number of messages in current thread
   ** .dt %f .dd sender (address + real name), either From: or Return-Path:
-  ** .dt %F .dd author name, or recipient name if the message is from you
+  ** .dt %F .dd author's real name, or "To real name" of recipient if the 
message
+  **            is from you (or address if no real name) (consults 
``alternates'')
   ** .dt %H .dd spam attribute(s) of this message
   ** .dt %i .dd message-id of the current message
   ** .dt %l .dd number of lines in the message (does not work with maildir,
@@ -1038,6 +1039,9 @@
   ** .dt %O .dd (_O_riginal save folder)  Where mutt would formerly have
   **            stashed the message: list name or recipient name if no list
   ** .dt %P .dd progress indicator for the builtin pager (how much of the file 
has been displayed)
+  ** .dt %R .dd "Real Name" of author, or of recipient if the message is from 
you
+  **            (or address if real name is missing) (consults ``alternates'')
+  ** .dt %r .dd recipient's real name (or address if missing)
   ** .dt %s .dd subject of the message
   ** .dt %S .dd status of the message (N/D/d/!/r/\(as)
   ** .dt %t .dd `to:' field (recipients)
diff -Nur mutt-1.5.17-orig/PATCHES mutt-1.5.17/PATCHES
--- mutt-1.5.17-orig/PATCHES    2007-03-21 19:26:38.000000000 +0100
+++ mutt-1.5.17/PATCHES 2008-01-10 21:06:09.000000000 +0100
@@ -0,0 +1 @@
+100_patch-mutt-1.5.17.grfz.fcc-save-correspondent.4
diff -Nur mutt-1.5.17-orig/hdrline.c mutt-1.5.17/hdrline.c
--- mutt-1.5.17-orig/hdrline.c  2007-10-31 18:48:52.000000000 +0100
+++ mutt-1.5.17/hdrline.c       2008-01-10 21:03:05.000000000 +0100
@@ -127,6 +127,31 @@
     *buf = 0;
 }
 
+/* analog to "make_from" but generates "Real Name" of recipient without 
preceding "To "
+ * don't know why original name is "make_from" so name it make_from_without_to
+ */
+static void make_from_without_to (ENVELOPE *hdr, char *buf, size_t len, int 
do_lists)
+{
+  int me;
+  me = mutt_addr_is_user (hdr->from);
+  if (do_lists || me)
+  {
+    if (check_for_mailing_list (hdr->to, "", buf, len))
+      return;
+    if (check_for_mailing_list (hdr->cc, "", buf, len))
+      return;
+  }
+
+  if (me && hdr->to)
+    snprintf (buf, len, "%s", mutt_get_name (hdr->to));
+  else if (me && hdr->cc)
+    snprintf (buf, len, "%s", mutt_get_name (hdr->cc));
+  else if (hdr->from)
+    strfcpy (buf, mutt_get_name (hdr->from), len);
+  else
+    *buf = 0;
+}
+
 static void make_from_addr (ENVELOPE *hdr, char *buf, size_t len, int do_lists)
 {
   int me;
@@ -546,6 +571,25 @@
       strfcpy(dest, NONULL(hfi->pager_progress), destlen);
       break;
 
+/* analog to 'n' but generates "Real Name" of recipient
+ */
+    case 'r':
+      mutt_format_s (dest, destlen, prefix, mutt_get_name (hdr->env->to));
+      break;
+
+/* analog to 'F' but calls "make_from_without_to" and so
+ * generates "Real Name" of recipient without preceding "To "
+ */
+    case 'R':
+      if (!optional)
+      {
+       make_from_without_to (hdr->env, buf2, sizeof (buf2), 0);
+       mutt_format_s (dest, destlen, prefix, buf2);
+      }
+      else if (mutt_addr_is_user (hdr->env->from))
+       optional = 0;
+      break;
+
     case 's':
       
       if (flags & M_FORMAT_TREE && !hdr->collapsed)
diff -Nur mutt-1.5.17-orig/init.h mutt-1.5.17/init.h
--- mutt-1.5.17-orig/init.h     2008-01-10 21:06:57.000000000 +0100
+++ mutt-1.5.17/init.h  2008-01-10 21:05:14.000000000 +0100
@@ -1023,7 +1023,8 @@
   ** .dt %e .dd current message number in thread
   ** .dt %E .dd number of messages in current thread
   ** .dt %f .dd sender (address + real name), either From: or Return-Path:
-  ** .dt %F .dd author name, or recipient name if the message is from you
+  ** .dt %F .dd author's real name, or "To real name" of recipient if the 
message
+  **            is from you (or address if no real name) (consults 
``alternates'')
   ** .dt %H .dd spam attribute(s) of this message
   ** .dt %i .dd message-id of the current message
   ** .dt %l .dd number of lines in the message (does not work with maildir,
@@ -1038,6 +1039,9 @@
   ** .dt %O .dd (_O_riginal save folder)  Where mutt would formerly have
   **            stashed the message: list name or recipient name if no list
   ** .dt %P .dd progress indicator for the builtin pager (how much of the file 
has been displayed)
+  ** .dt %R .dd "Real Name" of author, or of recipient if the message is from 
you
+  **            (or address if real name is missing) (consults ``alternates'')
+  ** .dt %r .dd recipient's real name (or address if missing)
   ** .dt %s .dd subject of the message
   ** .dt %S .dd status of the message (N/D/d/!/r/\(as)
   ** .dt %t .dd `to:' field (recipients)
diff -Nur mutt-1.5.17-orig/PATCHES mutt-1.5.17/PATCHES
--- mutt-1.5.17-orig/PATCHES    2007-03-21 19:26:38.000000000 +0100
+++ mutt-1.5.17/PATCHES 2008-01-10 21:06:09.000000000 +0100
@@ -0,0 +1 @@
+100_patch-mutt-1.5.17.grfz.fcc-save-correspondent.4