summaryrefslogtreecommitdiff
path: root/mail/mutt-devel/files/extra-patch-greeting
blob: a1f4bc1131567196e67e831363b05413b1c9f884 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
diff -urN mutt-1.5.19/globals.h mutt-1.5.19-vc/globals.h
--- mutt-1.5.19/globals.h	2009-01-04 01:27:10.000000000 +0200
+++ mutt-1.5.19-vc/globals.h	2009-02-09 19:30:31.000000000 +0200
@@ -52,6 +52,7 @@
 WHERE char *FolderFormat;
 WHERE char *ForwFmt;
 WHERE char *Fqdn;
+WHERE char *Greeting;
 WHERE char *HdrFmt;
 WHERE char *HistFile;
 WHERE char *Homedir;
diff -urN mutt-1.5.19/hdrline.c mutt-1.5.19-vc/hdrline.c
--- mutt-1.5.19/hdrline.c	2009-01-05 21:20:53.000000000 +0200
+++ mutt-1.5.19-vc/hdrline.c	2009-02-09 19:30:31.000000000 +0200
@@ -741,3 +741,62 @@
 {
   mutt_FormatString (dst, dstlen, 0, s, hdr_format_str, (unsigned long) hfi, flags);
 }
+
+/* %n = recipient name
+ * %u = user (login) name of recipient
+ * %v = first name of recipient	*/
+const char *
+greeting_string (char *dest,
+		size_t destlen,
+		size_t col,
+		char op,
+		const char *src,
+		const char *prefix,
+		const char *ifstring,
+		const char *elsestring,
+		unsigned long data,
+		format_flag flags)
+{
+  HEADER *hdr = (HEADER *)data;
+  char *p, buf2[SHORT_STRING];
+
+  dest[0] = '\0';
+  switch (op)
+  {
+    case 'n':
+      mutt_format_s (dest, destlen, prefix, mutt_get_name (hdr->env->to));
+      break;
+
+    case 'u':
+      if (hdr->env->to)
+      {
+	strfcpy (buf2, mutt_addr_for_display (hdr->env->to), sizeof (buf2));
+	if ((p = strpbrk (buf2, "%@")))
+	  *p = '\0';
+      }
+      else
+	buf2[0] = '\0';
+      mutt_format_s (dest, destlen, prefix, buf2);
+      break;
+
+    case 'v':
+      if (hdr->env->to)
+	mutt_format_s (buf2, sizeof (buf2), prefix, mutt_get_name (hdr->env->to));
+      else if (hdr->env->cc)
+	mutt_format_s (buf2, sizeof (buf2), prefix, mutt_get_name (hdr->env->cc));
+      else
+	*buf2 = '\0';
+      if ((p = strpbrk (buf2, " %@")))
+	*p = '\0';
+      mutt_format_s (dest, destlen, prefix, buf2);
+      break;
+
+    default:
+      snprintf (dest, destlen, "%%%s%c", prefix, op);
+      break;
+  }
+  if (flags & M_FORMAT_OPTIONAL)
+    mutt_FormatString (dest, destlen, col, elsestring, greeting_string, data, flags);
+
+  return(src);
+}
diff -urN mutt-1.5.19/init.h mutt-1.5.19-vc/init.h
--- mutt-1.5.19/init.h	2009-01-05 21:20:53.000000000 +0200
+++ mutt-1.5.19-vc/init.h	2009-02-09 19:30:31.000000000 +0200
@@ -745,6 +745,22 @@
   ** .pp
   ** This setting defaults to the contents of the environment variable \fC$$$EMAIL\fP.
   */
+  { "greeting",		DT_STR,	 R_NONE, UL &Greeting, UL "" },
+  /*
+  ** .pp
+  ** When set, this is the string that will precede every message as a
+  ** greeting phrase to the recipients.
+  ** .pp
+  ** ``Format strings'' are similar to the strings used in the ``C''
+  ** function printf to format output (see the man page for more detail).
+  ** The following sequences are defined in Mutt:
+  ** .pp
+  ** .dl
+  ** .dt %n .dd recipient name
+  ** .dt %u .dd user (login) name of recipient
+  ** .dt %v .dd first name of recipient
+  ** .de
+  */
   { "gecos_mask",	DT_RX,	 R_NONE, UL &GecosMask, UL "^[^,]*" },
   /*
   ** .pp
diff -urN mutt-1.5.19/PATCHES mutt-1.5.19-vc/PATCHES
--- mutt-1.5.19/PATCHES	2008-03-19 22:07:06.000000000 +0200
+++ mutt-1.5.19-vc/PATCHES	2009-02-09 19:30:31.000000000 +0200
@@ -0,0 +1 @@
+vc.greeting
diff -urN mutt-1.5.19/protos.h mutt-1.5.19-vc/protos.h
--- mutt-1.5.19/protos.h	2009-01-05 21:20:53.000000000 +0200
+++ mutt-1.5.19-vc/protos.h	2009-02-09 19:32:15.000000000 +0200
@@ -526,6 +526,9 @@
 void ci_bounce_message (HEADER *, int *);
 int ci_send_message (int, HEADER *, char *, CONTEXT *, HEADER *);
 
+const char *greeting_string (char *, size_t, size_t, char, const char *, const char *,
+		const char *, const char *, unsigned long, format_flag);
+
 /* prototypes for compatibility functions */
 
 #ifndef HAVE_SETENV
diff -urN mutt-1.5.19/send.c mutt-1.5.19-vc/send.c
--- mutt-1.5.19/send.c.orig	2010-09-17 16:49:09.000000000 +0200
+++ mutt-1.5.19-vc/send.c	2010-09-17 16:53:15.000000000 +0200
@@ -469,6 +469,18 @@
   }
 }
 
+void mutt_make_greeting (HEADER *hdr, FILE *out, int flags)
+{
+  char buffer[STRING];
+  if (Greeting)
+  {
+    mutt_FormatString(buffer, sizeof(buffer), 0, Greeting, greeting_string,
+		      (unsigned long) hdr, flags);
+    fputs(buffer, out);
+    fputc ('\n', out);
+  }
+}
+
 void mutt_make_post_indent (CONTEXT *ctx, HEADER *cur, FILE *out)
 {
   char buffer[STRING];
@@ -1003,7 +1015,6 @@
   }
 }
 
-
 /* look through the recipients of the message we are replying to, and if
    we find an address that matches $alternates, we use that as the default
    from field */
@@ -1439,6 +1450,8 @@
     if (option (OPTHDRS))
       process_user_header (msg->env);
 
+    mutt_make_greeting(msg, tempfp, flags);
+
     if (flags & SENDBATCH)
        mutt_copy_stream (stdin, tempfp);