1 x-face patch for Mutt 1.5.6
3 Copied from Debian's slrnface package:
5 http://dave.willfork.com/slrnface/
6 Upstream Author: Drazen Kacar <dave@arsdigita.com>
7 Copyright: /usr/share/common-licenses/GPL
10 --- mutt-1.4./README.xface Thu Jan 1 01:00:00 1970
11 +++ mutt-1.4/README.xface Sat Aug 24 02:29:23 2002
13 +This is slrnface, a small helper utility which displays X-Faces on behalf
14 +of programs like slrn and mutt when they are run in the X11 terminal
20 +b) Terminal emulator which sets WINDOWID environment variable. Most of the
21 + ones in common use will set it. If you're using some terminal emulator
22 + which doesn't have this capability, you'll have to set it yourself.
26 +a) Install libcompface. I recommend getting the source from the nearest
27 + Debian GNU/Linux mirror because there's a patch which adds the
28 + ability to output XBM image, as well as the historic brain dead
29 + format. Slrnface doesn't use that feature, but it might be handy for
36 +d) Install with "make install".
38 +Upgrading from version 1.x:
40 + If you have used one of the older versions of slrnface, you probably
41 + have .slrnface file in your home directory. You can delete it, because
42 + the new version doesn't use it any more. Instead, the pipes will be
43 + created in $HOME/.slrnfaces directory. There are no other user visible
46 +Using slrnface with slrn:
48 + This version requires S-Lang 1.4 or later and slrn 0.9.7.4. It might
49 + work with slrn 0.9.7.3, but I haven't tested that configuration. It
50 + will not work properly with older versions.
52 + In case you can't or won't upgrade, take a look at the slrnface home
53 + page. You'll find older versions which might work with what you have.
55 + Take a look at slrnface.sl, edit if you want and then include it in
56 + your .slrnrc, like this:
58 + interpret slrnface.sl
62 +Using slrnface with mutt:
64 + Mutt doesn't have a way to use some kind of embeded interpreter, like
65 + S-Lang. Since Mutt's current capabilities are not good enough for our
66 + purposes, a patch for the source is provided. It has been tested with
67 + mutt 1.4, but it should work with the 1.3.x series, if x is high
70 + Uncompress mutt 1.4 source and apply mutt.patch from the slrnface
73 + Compile mutt as usual.
75 + Edit your ~/.muttrc and add:
81 +If you think X-Faces are not placed at the appropriate location on your
82 +terminal emulator window or you don't like the colors, set some X resources.
83 +Read the man page for more information. Additional documentation is in the
86 +Licence: GPL. See file called COPYING.
88 +Special thanks to Mark R. Bowyer for proofreading the man page.
90 +Home page: http://dave.willfork.com/slrnface/
93 diff -urp ../MUTT/mutt/PATCHES mutt/PATCHES
94 --- ../MUTT/mutt/PATCHES 2002-12-09 18:44:54.000000000 +0100
95 +++ mutt/PATCHES 2004-07-21 16:02:16.000000000 +0200
97 +patch-1.5.6.cb.xface.1
98 diff -urp ../MUTT/mutt/globals.h mutt/globals.h
99 --- ../MUTT/mutt/globals.h.orig 2007-03-26 14:49:03.226880430 +0200
100 +++ mutt/globals.h 2007-03-26 14:51:13.227945753 +0200
102 WHERE ALIAS *Aliases INITVAL (0);
103 WHERE LIST *UserHeader INITVAL (0);
105 +WHERE int slrnface_fd INITVAL (-1);
107 /*-- formerly in pgp.h --*/
108 WHERE REGEXP PgpGoodSign;
109 WHERE char *PgpSignAs;
110 diff -urp ../MUTT/mutt/init.c mutt/init.c
111 --- ../MUTT/mutt/init.c 2004-07-18 01:25:28.000000000 +0200
112 +++ mutt/init.c 2004-07-21 13:33:47.000000000 +0200
115 #include <sys/utsname.h>
117 +#include <sys/types.h>
119 #include <sys/wait.h>
121 void toggle_quadoption (int opt)
122 @@ -2356,3 +2358,130 @@ int mutt_get_hook_type (const char *name
126 +void mutt_start_slrnface(void)
129 + int pathlen, status;
133 + if (!option(OPTXFACE))
137 + * If we don't have display, there's no point. The user probably knows,
138 + * so fail silently.
140 + if (!getenv("DISPLAY"))
142 + /* If there is no WINDOWID, complain. */
143 + if (!getenv ("WINDOWID"))
145 + mutt_error (_("Cannot run slrnface: WINDOWID not found in environment."));
150 + pathlen = strlen (Homedir) + sizeof("/.slrnfaces/")
151 + + strlen (u.nodename) + 30;
152 + fifo = safe_malloc (pathlen);
153 + sprintf (fifo, "%s/.slrnfaces", Homedir);
154 + if (mkdir (fifo, 0700))
156 + if (errno != EEXIST)
158 + mutt_error (_("Cannot run slrnface: failed to create %s: %s."),
159 + fifo, strerror(errno));
167 + /* We'll abuse fifo filename memory here. It's long enough. */
168 + sprintf (fifo, "%s/.slrnfaces/README", Homedir);
169 + if ((fp = fopen (fifo, "w")) != NULL)
172 +"This directory is used to create named pipes for communication between\n"
173 +"slrnface and its parent process. It should normally be empty because\n"
174 +"the pipe is deleted right after it has been opened by both processes.\n\n"
175 +"File names generated by slrnface have the form \"hostname.pid\". It is\n"
176 +"probably an error if they linger here longer than a fraction of a second.\n\n"
177 +"However, if the directory is mounted from an NFS server, you might see\n"
178 +"special files created by your NFS server while slrnface is running.\n"
179 +"Do not try to remove them.\n"), fp);
184 + status = snprintf (fifo, pathlen, "%s/.slrnfaces/%s.%ld", Homedir,
185 + u.nodename, (long)getpid());
190 + if (mkfifo (fifo, 0600) < 0)
192 + mutt_error (_("Cannot run slrnface, failed to create %s: %s."), fifo,
201 + case 0: execlp ("slrnface", "slrnface", fifo, (char *)0);
202 + /* This is child, exit on error. */
205 + pidst = waitpid (pid, &status, 0);
206 + } while (pidst == -1 && errno == EINTR);
208 + if (!WIFEXITED (status))
209 + mutt_error (_("Slrnface abnormaly exited, code %d."), status);
214 + switch (WEXITSTATUS (status))
216 + case 0: /* All fine, open the pipe */
217 + slrnface_fd = open (fifo, O_WRONLY, 0600);
218 + write (slrnface_fd, "start\n", sizeof "start");
220 + case 1: message = "couldn't connect to display";
222 + case 2: message = "WINDOWID not found in environment";
224 + case 3: message = "couldn't find controlling terminal";
226 + case 4: message = "terminal doesn't export width and height";
228 + case 5: message = "cannot open FIFO";
230 + case 6: message = "fork() failed";
232 + case 10: message = "executable not found";
234 + default: message = "unknown error";
236 + mutt_error (_("Slrnface failed: %s."), message);
245 +void mutt_stop_slrnface(void)
247 + if (slrnface_fd >= 0)
248 + close(slrnface_fd);
251 + /* FIFO has been unlinked in the startup function. */
253 diff -urp ../MUTT/mutt/init.h mutt/init.h
254 --- ../MUTT/mutt/init.h 2004-07-21 13:33:02.000000000 +0200
255 +++ mutt/init.h 2004-07-21 13:33:47.000000000 +0200
256 @@ -2736,6 +2736,12 @@ struct option_t MuttVars[] = {
257 ** Controls whether mutt writes out the Bcc header when preparing
258 ** messages to be sent. Exim users may wish to use this.
260 + { "xface", DT_BOOL, R_NONE, OPTXFACE, 0 },
263 + ** Controls whether mutt uses slrnface to display X-Faces when run
264 + ** in an X11 terminal emulator.
269 diff -urp ../MUTT/mutt/main.c mutt/main.c
270 --- ../MUTT/mutt/main.c 2004-06-18 17:24:22.000000000 +0200
271 +++ mutt/main.c 2004-07-21 13:33:47.000000000 +0200
272 @@ -905,6 +905,8 @@ int main (int argc, char **argv)
274 mutt_folder_hook (folder);
276 + mutt_start_slrnface();
278 Context = mx_open_mailbox (mutt_b2s (folder),
279 ((flags & MUTT_RO) || option (OPTREADONLY)) ? MUTT_READONLY : 0,
281 @@ -913,6 +915,8 @@ int main (int argc, char **argv)
284 exit_endwin_msg = Errorbuf;
286 + mutt_stop_slrnface();
290 diff -urp ../MUTT/mutt/mutt.h mutt/mutt.h
291 --- ../MUTT/mutt/mutt.h 2004-07-21 13:33:02.000000000 +0200
292 +++ mutt/mutt.h 2004-07-21 13:33:47.000000000 +0200
293 @@ -435,6 +435,7 @@ enum
296 OPTWRITEBCC, /* write out a bcc header? */
301 @@ -577,6 +578,7 @@ typedef struct envelope
303 LIST *references; /* message references (in reverse order) */
304 LIST *in_reply_to; /* in-reply-to header content */
305 + LIST *x_face; /* X-Face header content */
306 LIST *userhdrs; /* user defined headers */
309 diff -urp ../MUTT/mutt/muttlib.c mutt/muttlib.c
310 --- ../MUTT/mutt/muttlib.c 2004-07-18 01:25:28.000000000 +0200
311 +++ mutt/muttlib.c 2004-07-21 13:33:47.000000000 +0200
312 @@ -651,6 +651,7 @@ void mutt_free_envelope (ENVELOPE **p)
314 mutt_free_list (&(*p)->references);
315 mutt_free_list (&(*p)->in_reply_to);
316 + mutt_free_list (&(*p)->x_face);
317 mutt_free_list (&(*p)->userhdrs);
320 diff -urp ../MUTT/mutt/pager.c mutt/pager.c
321 --- ../MUTT/mutt/pager.c 2004-07-18 01:25:28.000000000 +0200
322 +++ mutt/pager.c 2004-07-21 13:36:34.000000000 +0200
323 @@ -1527,6 +1527,66 @@ upNLines (int nlines, struct line_t *inf
328 +mutt_display_xface (HEADER *hdr)
333 + if (slrnface_fd < 0)
339 + face = hdr->env->x_face;
341 + if (face == NULL || face->data == NULL)
342 + write(slrnface_fd, "clear\n", sizeof "clear");
347 + len = snprintf (buf, sizeof (buf), "xface %s\n", face->data);
348 + if (len <= sizeof (buf))
350 + write (slrnface_fd, buf, len);
354 + * slrnface will ignore X-Faces larger than approx. 2000 chars, so
355 + * try the next one, if it exists.
357 + } while (face = face->next);
361 +mutt_clear_xface (void)
363 + if (slrnface_fd < 0)
366 + write(slrnface_fd, "clear\n", sizeof "clear");
370 +mutt_suppress_xface (void)
372 + if (slrnface_fd < 0)
375 + write(slrnface_fd, "suppress\n", sizeof "suppress");
379 +mutt_show_xface (void)
381 + if (slrnface_fd < 0)
384 + write(slrnface_fd, "show\n", sizeof "show");
387 static const struct mapping_t PagerHelp[] = {
388 { N_("Exit"), OP_EXIT },
389 { N_("PrevPg"), OP_PREV_PAGE },
390 @@ -1545,6 +1605,9 @@ mutt_pager (const char *banner, const ch
391 snprintf (helpstr, sizeof (helpstr), "%s %s", tmphelp, buffer);
394 + if (IsHeader (extra))
395 + mutt_display_xface(extra->hdr);
400 @@ -2067,7 +2130,9 @@ search_next:
404 + mutt_suppress_xface ();
405 mutt_help (MENU_PAGER);
406 + mutt_show_xface ();
407 pager_menu->redraw = REDRAW_FULL;
410 @@ -2649,7 +2649,9 @@
412 CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
414 + mutt_suppress_xface();
415 ci_send_message (0, NULL, NULL, extra->ctx, NULL);
417 pager_menu->redraw = REDRAW_FULL;
420 @@ -2662,6 +2664,7 @@
422 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
424 + mutt_suppress_xface();
426 replyflags = SENDREPLY |
427 (ch == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
428 @@ -2673,6 +2676,7 @@
429 extra->bdy, replyflags);
431 ci_send_message (replyflags, NULL, NULL, extra->ctx, extra->hdr);
433 pager_menu->redraw = REDRAW_FULL;
436 @@ -2680,19 +2684,23 @@
437 case OP_RECALL_MESSAGE:
438 CHECK_MODE(IsHeader (extra) && !IsAttach(extra));
440 + mutt_suppress_xface();
441 ci_send_message (SENDPOSTPONED, NULL, NULL, extra->ctx, extra->hdr);
443 pager_menu->redraw = REDRAW_FULL;
446 case OP_FORWARD_MESSAGE:
447 CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
449 + mutt_suppress_xface();
450 if (IsMsgAttach (extra))
451 mutt_attach_forward (extra->fp, extra->hdr, extra->actx,
454 ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr);
455 pager_menu->redraw = REDRAW_FULL;
459 case OP_DECRYPT_SAVE:
460 @@ -2485,7 +2562,9 @@ CHECK_IMAP_ACL(IMAP_ACL_WRITE);
463 case OP_SHELL_ESCAPE:
464 + mutt_suppress_xface ();
465 mutt_shell_escape ();
466 + mutt_show_xface ();
470 @@ -2644,5 +2723,6 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE);
471 FREE (&rd.pager_status_window);
472 FREE (&rd.pager_window);
474 + mutt_clear_xface ();
475 return (rc != -1 ? rc : 0);
477 diff -urp ../MUTT/mutt/parse.c mutt/parse.c
478 --- ../MUTT/mutt/parse.c 2004-07-21 13:33:02.000000000 +0200
479 +++ mutt/parse.c 2004-07-21 13:33:47.000000000 +0200
480 @@ -85,6 +85,27 @@ static char *read_rfc822_line (FILE *f,
484 +static LIST *mutt_add_x_face (LIST *lst, char *face)
488 + n = safe_malloc(sizeof(LIST));
489 + n->data = safe_strdup(face);
496 + for(l = lst; l->next; l = l->next);
505 static LIST *mutt_parse_references (char *s, int in_reply_to)
507 LIST *t, *lst = NULL;
508 @@ -1231,6 +1252,11 @@ int mutt_parse_rfc822_line (ENVELOPE *e,
509 e->x_label = safe_strdup(p);
512 + else if (ascii_strcasecmp (line+1, "-face") == 0)
514 + e->x_face = mutt_add_x_face (e->x_face, p);
520 diff -urp ../MUTT/mutt/sendlib.c mutt/sendlib.c
521 --- ../MUTT/mutt/sendlib.c 2004-07-21 13:33:02.000000000 +0200
522 +++ mutt/sendlib.c 2004-07-21 13:37:16.000000000 +0200
523 @@ -1697,6 +1697,15 @@ int mutt_write_rfc822_header (FILE *fp,
527 + /* Add X-Face headers */
532 + for (face = env->x_face; face; face = face->next)
533 + fprintf (fp, "X-Face: %s\n", face->data);
536 if (mode == MUTT_WRITE_HEADER_NORMAL && !privacy &&
537 option (OPTXMAILER) && !has_agent)