1 diff -pruN2 mutt-1.3.27.orig/Makefile.am mutt-1.3.27/Makefile.am
2 --- mutt-1.3.27.orig/Makefile.am Fri Nov 9 01:18:28 2001
3 +++ mutt-1.3.27/Makefile.am Wed Jan 23 22:35:32 2002
4 @@ -25,5 +25,5 @@ mutt_SOURCES = $(BUILT_SOURCES) \
5 postpone.c query.c recvattach.c recvcmd.c \
6 rfc822.c rfc1524.c rfc2047.c rfc2231.c \
7 - score.c send.c sendlib.c signal.c sort.c \
8 + score.c send.c sendlib.c signal.c signature.c sort.c \
9 status.c system.c thread.c charset.c history.c lib.c \
10 muttlib.c editmsg.c utf8.c mbyte.c wcwidth.c \
11 diff -pruN2 mutt-1.3.27.orig/OPS mutt-1.3.27/OPS
12 --- mutt-1.3.27.orig/OPS Tue Sep 11 12:50:50 2001
13 +++ mutt-1.3.27/OPS Wed Jan 23 22:35:32 2002
14 @@ -37,4 +37,5 @@ OP_COMPOSE_POSTPONE_MESSAGE "save this m
15 OP_COMPOSE_RENAME_FILE "rename/move an attached file"
16 OP_COMPOSE_SEND_MESSAGE "send the message"
17 +OP_COMPOSE_SIG "choose a signature"
18 OP_COMPOSE_TOGGLE_DISPOSITION "toggle disposition between inline/attachment"
19 OP_COMPOSE_TOGGLE_UNLINK "toggle whether to delete file after sending it"
20 @@ -126,4 +127,5 @@ OP_NEXT_ENTRY "move to the next entry"
21 OP_NEXT_LINE "scroll down one line"
22 OP_NEXT_PAGE "move to the next page"
23 +OP_NEXT_SIG "move to the next signature"
24 OP_PAGER_BOTTOM "jump to the bottom of the message"
25 OP_PAGER_HIDE_QUOTED "toggle display of quoted text"
26 @@ -134,9 +136,11 @@ OP_PREV_ENTRY "move to the previous entr
27 OP_PREV_LINE "scroll up one line"
28 OP_PREV_PAGE "move to the previous page"
29 +OP_PREV_SIG "move to the previous signature"
30 OP_PRINT "print the current entry"
31 OP_PURGE_MESSAGE "really delete the current entry, bypassing the trash folder"
32 OP_QUERY "query external program for addresses"
33 OP_QUERY_APPEND "append new query results to current results"
34 OP_QUIT "save changes to mailbox and quit"
35 +OP_RANDOM_SIG "pick a signature at random"
36 OP_RECALL_MESSAGE "recall a postponed message"
37 OP_REDRAW "clear and redraw the screen"
38 @@ -150,4 +154,5 @@ OP_SEARCH_OPPOSITE "search for next matc
39 OP_SEARCH_TOGGLE "toggle search pattern coloring"
40 OP_SHELL_ESCAPE "invoke a command in a subshell"
41 +OP_SIG_SEARCH "search signatures matching a pattern"
42 OP_SORT "sort messages"
43 OP_SORT_REVERSE "sort messages in reverse order"
44 diff -pruN2 mutt-1.3.27.orig/compose.c mutt-1.3.27/compose.c
45 --- mutt-1.3.27.orig/compose.c Mon Dec 3 11:17:57 2001
46 +++ mutt-1.3.27/compose.c Wed Jan 23 22:35:32 2002
47 @@ -1103,4 +1103,10 @@ int mutt_compose_menu (HEADER *msg, /*
50 + case OP_COMPOSE_SIG:
51 + mutt_signature(msg->content->filename);
52 + MAYBE_REDRAW (menu->redraw);
53 + mutt_update_encoding (msg->content);
58 diff -pruN2 mutt-1.3.27.orig/doc/manual.sgml.head mutt-1.3.27/doc/manual.sgml.head
59 --- mutt-1.3.27.orig/doc/manual.sgml.head Sat Jan 12 12:35:43 2002
60 +++ mutt-1.3.27/doc/manual.sgml.head Wed Jan 23 22:35:32 2002
61 @@ -526,4 +526,5 @@ c edit-cc edit the
62 b edit-bcc edit the Bcc field
63 y send-message send the message
64 +ESC s signature-menu select a signature and append it to your mail
65 s edit-subject edit the Subject
66 f edit-fcc specify an ``Fcc'' mailbox
67 diff -pruN2 mutt-1.3.27.orig/functions.h mutt-1.3.27/functions.h
68 --- mutt-1.3.27.orig/functions.h Tue Sep 11 12:51:39 2001
69 +++ mutt-1.3.27/functions.h Wed Jan 23 22:35:32 2002
70 @@ -309,4 +309,5 @@ struct binding_t OpCompose[] = {
71 { "send-message", OP_COMPOSE_SEND_MESSAGE, "y" },
72 { "pipe-entry", OP_PIPE, "|" },
73 + { "signature-menu", OP_COMPOSE_SIG, "\033s" },
76 @@ -363,4 +364,17 @@ struct binding_t OpQuery[] = {
77 { "query", OP_QUERY, "Q" },
78 { "query-append", OP_QUERY_APPEND, "A" },
83 +struct binding_t OpSig[] = {
84 + { "next-sig", OP_NEXT_SIG, "j" },
85 + { "previous-sig", OP_PREV_SIG, "k" },
86 + { "random-sig", OP_RANDOM_SIG, "r" },
90 +struct binding_t OpSigDir[] = {
91 + { "search-sig", OP_SIG_SEARCH, "/" },
94 diff -pruN2 mutt-1.3.27.orig/globals.h mutt-1.3.27/globals.h
95 --- mutt-1.3.27.orig/globals.h Thu Jan 3 21:56:46 2002
96 +++ mutt-1.3.27/globals.h Wed Jan 23 22:35:32 2002
97 @@ -100,4 +100,5 @@ WHERE char *Sendmail;
99 WHERE char *Signature;
100 +WHERE char *SigDirectory;
101 WHERE char *SimpleSearch;
102 WHERE char *Spoolfile;
103 diff -pruN2 mutt-1.3.27.orig/init.h mutt-1.3.27/init.h
104 --- mutt-1.3.27.orig/init.h Mon Dec 10 11:09:03 2001
105 +++ mutt-1.3.27/init.h Wed Jan 23 22:35:32 2002
106 @@ -1954,4 +1954,12 @@ struct option_t MuttVars[] = {
109 + { "signatures_directory", DT_PATH, R_NONE, UL &SigDirectory, UL "" },
112 + ** Specifies the path where your signatures are located. In the files of
113 + ** this directory, the signatures are separated by blank lines and/or
114 + ** sig_dashes (``-- '').
115 + ** You can choose between these signatures from the compose menu.
117 { "simple_search", DT_STR, R_NONE, UL &SimpleSearch, UL "~f %s | ~s %s" },
119 diff -pruN2 mutt-1.3.27.orig/keymap.c mutt-1.3.27/keymap.c
120 --- mutt-1.3.27.orig/keymap.c Tue Oct 16 16:29:02 2001
121 +++ mutt-1.3.27/keymap.c Wed Jan 23 22:35:32 2002
122 @@ -50,4 +50,6 @@ struct mapping_t Menus[] = {
124 { "query", MENU_QUERY },
125 + { "signature", MENU_SIG },
126 + { "sig_directory", MENU_SIG_DIR },
127 { "generic", MENU_GENERIC },
129 @@ -528,4 +530,6 @@ void km_init (void)
130 create_bindings (OpQuery, MENU_QUERY);
131 create_bindings (OpAlias, MENU_ALIAS);
132 + create_bindings (OpSig, MENU_SIG);
133 + create_bindings (OpSigDir, MENU_SIG_DIR);
136 @@ -619,4 +623,7 @@ void km_init (void)
137 km_bindkey ("<enter>", MENU_COMPOSE, OP_VIEW_ATTACH);
139 + km_bindkey ("<up>", MENU_SIG, OP_PREV_SIG);
140 + km_bindkey ("<down>", MENU_SIG, OP_NEXT_SIG);
142 /* edit-to (default "t") hides generic tag-entry in Compose menu
143 This will bind tag-entry to "T" in the Compose menu */
144 @@ -739,4 +746,8 @@ struct binding_t *km_get_table (int menu
153 diff -pruN2 mutt-1.3.27.orig/keymap.h mutt-1.3.27/keymap.h
154 --- mutt-1.3.27.orig/keymap.h Tue Sep 11 12:50:12 2001
155 +++ mutt-1.3.27/keymap.h Wed Jan 23 22:35:32 2002
156 @@ -60,4 +60,6 @@ enum
163 @@ -102,4 +104,6 @@ extern struct binding_t OpEditor[];
164 extern struct binding_t OpQuery[];
165 extern struct binding_t OpAlias[];
166 +extern struct binding_t OpSig[];
167 +extern struct binding_t OpSigDir[];
170 diff -pruN2 mutt-1.3.27.orig/protos.h mutt-1.3.27/protos.h
171 --- mutt-1.3.27.orig/protos.h Wed Jan 16 21:43:58 2002
172 +++ mutt-1.3.27/protos.h Wed Jan 23 22:35:32 2002
173 @@ -225,4 +225,5 @@ void mutt_shell_escape (void);
174 void mutt_show_error (void);
175 void mutt_signal_init (void);
176 +void mutt_signature (char *);
177 void mutt_stamp_attachment (BODY *a);
178 void mutt_tabs_to_spaces (char *);
179 diff -pruN2 mutt-1.3.27.orig/signature.c mutt-1.3.27/signature.c
180 --- mutt-1.3.27.orig/signature.c Thu Jan 1 01:00:00 1970
181 +++ mutt-1.3.27/signature.c Wed Jan 23 22:35:32 2002
184 + * Copyright (C) 2001 Cedric Duval <cedricduval@free.fr>
186 + * This program is free software; you can redistribute it and/or modify
187 + * it under the terms of the GNU General Public License as published by
188 + * the Free Software Foundation; either version 2 of the License, or
189 + * (at your option) any later version.
191 + * This program is distributed in the hope that it will be useful,
192 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
193 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
194 + * GNU General Public License for more details.
196 + * You should have received a copy of the GNU General Public License
197 + * along with this program; if not, write to the Free Software
198 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
202 +#include "mutt_menu.h"
203 +#include "mapping.h"
204 +#include "mutt_curses.h"
210 +#include <sys/stat.h>
212 +#define SIG_DISPLAY_LINES 4
213 +#define SEPARATOR(x) ((*x == '\n') || (mutt_strcmp (x, "-- \n") == 0))
214 +#define SIG_ADD_LINE(x,y) mutt_add_list (x, strtok (y, "\n"))
216 +typedef struct sig_list
218 + struct sig_list *next;
222 +typedef struct sig_dir
224 + struct sig_dir *next;
228 +typedef LIST * ENTRY;
230 +typedef struct entry_dir
236 +static struct mapping_t SigHelp[] = {
237 + { N_("Exit"), OP_EXIT },
238 + { N_("Search"), OP_SEARCH },
239 + { N_("Random"), OP_RANDOM_SIG },
240 + { N_("Help"), OP_HELP },
244 +static struct mapping_t SigDirHelp[] = {
245 + { N_("Exit"), OP_EXIT },
246 + { N_("Search signature"), OP_SIG_SEARCH },
247 + { N_("Help"), OP_HELP },
251 +void menu_next_entry (MUTTMENU *menu);
252 +void menu_prev_entry (MUTTMENU *menu);
255 +static int sig_match (LIST *s, regex_t *re)
259 + if (regexec (re, s->data, (size_t)0, NULL, (int)0) == 0)
266 +static void read_sig_file (char *name, SIG_LIST **begin, regex_t *re)
271 + SIG_LIST *first, *cur;
274 + if (!(fp = safe_fopen (name, "r")))
276 + mutt_error (_("Can't open signature file %s"), name);
280 + for (first = *begin; first && first->next; first = first->next, append++)
281 + ; /* append results to an existing list */
284 + while (fgets (buf, sizeof (buf), fp))
286 + if (buf[0] && !SEPARATOR (buf))
288 + sig = SIG_ADD_LINE (NULL, buf);
290 + while (fgets (buf, sizeof (buf), fp) && buf[0] && !SEPARATOR (buf))
291 + SIG_ADD_LINE (sig, buf);
293 + if (re && !sig_match (sig, re))
294 + mutt_free_list (&sig); /* previous sig didn't match the regexp */
297 + /* add signature */
299 + first = cur = (SIG_LIST *) safe_calloc (1, sizeof (SIG_LIST));
302 + cur->next = (SIG_LIST *) safe_calloc (1, sizeof (SIG_LIST));
318 +static void sig_make_entry (char *s, size_t slen, MUTTMENU *menu, int num)
320 + ENTRY *table = (ENTRY *) menu->data;
322 + snprintf (s, slen, "%3d %s",
327 +static int sig_menu_search (MUTTMENU *menu, regex_t *re, int num)
329 + return (sig_match (((ENTRY *)menu->data)[num], re) ? 0 : REG_NOMATCH);
332 +static void draw_sig_frame (LIST *s)
336 + for (i = 1; i <= SIG_DISPLAY_LINES; i++)
340 + mvaddstr (i, 0, s->data);
349 + SETCOLOR (MT_COLOR_STATUS);
350 + mvaddstr (SIG_DISPLAY_LINES + 1, 0, _("-- Signature"));
351 + BKGDSET (MT_COLOR_STATUS);
354 + BKGDSET (MT_COLOR_NORMAL);
355 + SETCOLOR (MT_COLOR_NORMAL);
358 +static void free_sig_list (SIG_LIST **sigs)
365 + *sigs = (*sigs)->next;
366 + mutt_free_list (&cur->sig);
367 + safe_free ((void **)&cur);
371 +static void append_signature (char *msg_file, LIST *s)
375 + if ((fp = safe_fopen (msg_file, "a")) == 0)
376 + mutt_perror (msg_file);
379 + if (option (OPTSIGDASHES))
380 + fputs ("\n-- \n", fp);
382 + for (; s; s = s->next)
383 + fprintf (fp, "%s\n", s->data);
385 + mutt_message (_("Signature appended to your mail"));
390 +static LIST *sig_list_menu (char *file, SIG_LIST *list)
392 + LIST *result = NULL;
396 + char helpstr[SHORT_STRING], title[SHORT_STRING];
399 + snprintf (title, sizeof (title), _("Signature : %s"), file);
401 + menu = mutt_new_menu ();
402 + menu->make_entry = sig_make_entry;
404 + menu->search = sig_menu_search;
405 + menu->menu = MENU_SIG;
406 + menu->title = title;
407 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr),
408 + MENU_SIG, SigHelp);
409 + menu->offset = SIG_DISPLAY_LINES + 2;
410 + menu->pagelen = LINES - SIG_DISPLAY_LINES - 4;
412 + for (sigl = list; sigl; sigl = sigl->next)
415 + menu->data = SigTable = (ENTRY *) safe_calloc (menu->max, sizeof (ENTRY));
417 + for (i = 0, sigl = list; sigl; i++, sigl = sigl->next)
418 + SigTable[i] = sigl->sig;
422 + switch (mutt_menuLoop (menu))
424 + case OP_GENERIC_SELECT_ENTRY:
425 + result = SigTable[menu->current];
430 + menu_prev_entry (menu);
431 + draw_sig_frame (SigTable[menu->current]);
435 + menu_next_entry (menu);
436 + draw_sig_frame (SigTable[menu->current]);
440 + menu->offset = SIG_DISPLAY_LINES + 2;
441 + menu->pagelen = LINES - SIG_DISPLAY_LINES - 4;
442 + draw_sig_frame (SigTable[menu->current]);
445 + case OP_RANDOM_SIG:
446 + menu->current = LRAND () % menu->max;
447 + draw_sig_frame (SigTable[menu->current]);
448 + menu->redraw |= REDRAW_MOTION;
452 + set_option (OPTNEEDREDRAW);
458 + mutt_menuDestroy (&menu);
459 + safe_free ((void **)&SigTable);
463 +static SIG_LIST *sig_search_filter (MUTTMENU *menu, char *path)
467 + SIG_LIST *result = NULL;
470 + snprintf (buf, sizeof(buf), menu->searchBuf ? menu->searchBuf : "");
471 + if (mutt_get_field (_("Search for: "), buf,
472 + sizeof (buf), M_CLEAR) != 0 || !buf[0])
474 + mutt_str_replace (&menu->searchBuf, buf);
476 + if ((i = regcomp (&re, menu->searchBuf, REG_NOSUB | REG_EXTENDED | REG_WORDS
477 + | mutt_which_case (menu->searchBuf))) != 0)
479 + regerror (i, &re, buf, sizeof (buf));
481 + mutt_error ("%s", buf);
485 + /* building list of sigs matching the regexp */
486 + for (i = 0; i < menu->max; i++)
488 + /* search in every file if none is tagged */
489 + if (((ENTRY_DIR *) menu->data)[i].tagged || (menu->tagged == 0))
491 + snprintf (buf, sizeof (buf), "%s/%s", path,
492 + ((ENTRY_DIR *) menu->data)[i].data->name);
493 + read_sig_file (buf, &result, &re);
499 + mutt_error (_("Not found."));
504 +/* returns the list of files in this directory */
505 +static SIG_DIR *sig_directory (char *path)
510 + SIG_DIR *first = NULL, *cur = NULL;
511 + char file[_POSIX_PATH_MAX + SHORT_STRING];
513 + if ((dp = opendir (path)) == NULL)
515 + mutt_perror (path);
519 + while ((de = readdir (dp)))
521 + if ((de->d_name)[0] == '.') /* no hidden files */
524 + snprintf (file, sizeof (file), "%s/%s", path, de->d_name);
525 + if (lstat (file, &s) == -1)
528 + if ((!S_ISREG (s.st_mode)) && (!S_ISLNK (s.st_mode)))
532 + cur = first = safe_calloc (1, sizeof (SIG_DIR));
535 + cur->next = safe_calloc (1, sizeof (SIG_DIR));
538 + cur->name = safe_strdup (de->d_name);
545 +static void sig_dir_make_entry (char *s, size_t slen, MUTTMENU *menu, int num)
547 + ENTRY_DIR *table = (ENTRY_DIR *) menu->data;
549 + snprintf (s, slen, "%c %3d - %s",
550 + table[num].tagged ? '*' : ' ',
552 + table[num].data->name);
555 +static int sig_dir_tag (MUTTMENU *menu, int n, int m)
557 + ENTRY_DIR *cur = &((ENTRY_DIR *) menu->data)[n];
558 + int ot = cur->tagged;
560 + cur->tagged = m >= 0 ? m : !cur->tagged;
561 + return cur->tagged - ot;
565 +static int sig_dir_sort (const void *a, const void *b)
567 + ENTRY_DIR *pa = (ENTRY_DIR *) a;
568 + ENTRY_DIR *pb = (ENTRY_DIR *) b;
570 + return (mutt_strcmp (pa->data->name, pb->data->name));
573 +static int sig_dir_menu (char *path, char *msg_file)
577 + LIST *result = NULL;
578 + ENTRY_DIR *FileTable;
579 + SIG_DIR *list, *files;
580 + char buf[STRING], helpstr[SHORT_STRING], title[SHORT_STRING];
583 + if ((list = sig_directory (path)) == NULL)
586 + snprintf (title, sizeof (title), "Signature directory : %s", path);
588 + menu = mutt_new_menu ();
589 + menu->make_entry = sig_dir_make_entry;
590 + menu->search = NULL; /* search within files with sig_search_filter() */
591 + menu->tag = sig_dir_tag;
592 + menu->menu = MENU_SIG_DIR;
593 + menu->title = title;
594 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr),
595 + MENU_SIG_DIR, SigDirHelp);
597 + for (files = list; files; files = files->next)
600 + menu->data = FileTable = (ENTRY_DIR *) safe_calloc (menu->max,
601 + sizeof (ENTRY_DIR));
603 + for (i = 0, files = list; files; i++, files = files->next)
604 + FileTable[i].data = files;
606 + qsort (FileTable, menu->max, sizeof (ENTRY_DIR), sig_dir_sort);
610 + switch (mutt_menuLoop (menu))
612 + case OP_SIG_SEARCH:
613 + sigl = sig_search_filter (menu, path);
617 + if ((result = sig_list_menu (_("query results"), sigl)) != NULL)
619 + append_signature (msg_file, result);
623 + MAYBE_REDRAW (menu->redraw);
624 + free_sig_list (&sigl);
628 + case OP_GENERIC_SELECT_ENTRY:
629 + snprintf (buf, sizeof (buf), "%s/%s", path,
630 + FileTable[menu->current].data->name);
632 + read_sig_file (buf, &sigl, NULL);
636 + if ((result = sig_list_menu (buf, sigl)) != NULL)
638 + append_signature (msg_file, result);
642 + MAYBE_REDRAW (menu->redraw);
643 + free_sig_list (&sigl);
655 + safe_free ((void **)&list->name);
658 + safe_free ((void **)&files);
660 + safe_free ((void **)&FileTable);
661 + mutt_menuDestroy (&menu);
665 +void mutt_signature (char *msg_file)
669 + mutt_error (_("variable 'signatures_directory' is unset"));
673 + if (sig_dir_menu (SigDirectory, msg_file) == -1)
674 + mutt_error (_("%s: no files in this directory"), SigDirectory);
676 + set_option (OPTNEEDREDRAW);
678 diff -pruN mutt-1.3.27.orig/PATCHES mutt-1.3.27/PATCHES
679 --- mutt-1.3.27.orig/PATCHES Mon Nov 26 20:16:52 2001
680 +++ mutt-1.3.27/PATCHES Thu Dec 6 16:27:55 2001
682 +patch-1.3.27.cd.signatures_menu.2.1