Up to 2.0.6.
[packages/mutt.git] / mutt-cd.signatures_menu.patch
CommitLineData
68667aa0 1diff -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 \
11diff -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"
b324a978 31 OP_PURGE_MESSAGE "delete the current entry, bypassing the trash folder"
68667aa0 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"
44diff -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
b324a978 47@@ -1103,4 +1103,9 @@ int mutt_compose_menu (HEADER *msg, /*
68667aa0 48 break;
49
50+ case OP_COMPOSE_SIG:
51+ mutt_signature(msg->content->filename);
68667aa0 52+ mutt_update_encoding (msg->content);
53+ break;
54+
55 case OP_PIPE:
56 case OP_FILTER:
57diff -pruN2 mutt-1.3.27.orig/doc/manual.sgml.head mutt-1.3.27/doc/manual.sgml.head
68eeb855 58--- mutt-1.3.27.orig/doc/manual.xml.head Sat Jan 12 12:35:43 2002
59+++ mutt-1.3.27/doc/manual.xml.head Wed Jan 23 22:35:32 2002
68667aa0 60@@ -526,4 +526,5 @@ c edit-cc edit the
61 b edit-bcc edit the Bcc field
62 y send-message send the message
63+ESC s signature-menu select a signature and append it to your mail
64 s edit-subject edit the Subject
65 f edit-fcc specify an ``Fcc'' mailbox
66diff -pruN2 mutt-1.3.27.orig/functions.h mutt-1.3.27/functions.h
67--- mutt-1.3.27.orig/functions.h Tue Sep 11 12:51:39 2001
68+++ mutt-1.3.27/functions.h Wed Jan 23 22:35:32 2002
69@@ -309,4 +309,5 @@ struct binding_t OpCompose[] = {
70 { "send-message", OP_COMPOSE_SEND_MESSAGE, "y" },
71 { "pipe-entry", OP_PIPE, "|" },
72+ { "signature-menu", OP_COMPOSE_SIG, "\033s" },
73
74 #ifdef HAVE_PGP
75@@ -363,4 +364,17 @@ struct binding_t OpQuery[] = {
76 { "query", OP_QUERY, "Q" },
77 { "query-append", OP_QUERY_APPEND, "A" },
78+ { NULL, 0, NULL }
79+};
80+
81+/* Signature Menu */
82+struct binding_t OpSig[] = {
83+ { "next-sig", OP_NEXT_SIG, "j" },
84+ { "previous-sig", OP_PREV_SIG, "k" },
85+ { "random-sig", OP_RANDOM_SIG, "r" },
86+ { NULL, 0, NULL }
87+};
88+
89+struct binding_t OpSigDir[] = {
90+ { "search-sig", OP_SIG_SEARCH, "/" },
91 { NULL, 0, NULL }
92 };
93diff -pruN2 mutt-1.3.27.orig/globals.h mutt-1.3.27/globals.h
94--- mutt-1.3.27.orig/globals.h Thu Jan 3 21:56:46 2002
95+++ mutt-1.3.27/globals.h Wed Jan 23 22:35:32 2002
96@@ -100,4 +100,5 @@ WHERE char *Sendmail;
97 WHERE char *Shell;
98 WHERE char *Signature;
99+WHERE char *SigDirectory;
100 WHERE char *SimpleSearch;
101 WHERE char *Spoolfile;
102diff -pruN2 mutt-1.3.27.orig/init.h mutt-1.3.27/init.h
103--- mutt-1.3.27.orig/init.h Mon Dec 10 11:09:03 2001
104+++ mutt-1.3.27/init.h Wed Jan 23 22:35:32 2002
105@@ -1954,4 +1954,12 @@ struct option_t MuttVars[] = {
106 ** its stdout.
107 */
8d013520 108+ { "signatures_directory", DT_PATH, R_NONE, {.p=&SigDirectory}, {.p=""} },
68667aa0 109+ /*
110+ ** .pp
111+ ** Specifies the path where your signatures are located. In the files of
112+ ** this directory, the signatures are separated by blank lines and/or
113+ ** sig_dashes (``-- '').
114+ ** You can choose between these signatures from the compose menu.
115+ */
116 { "simple_search", DT_STR, R_NONE, UL &SimpleSearch, UL "~f %s | ~s %s" },
117 /*
118diff -pruN2 mutt-1.3.27.orig/keymap.c mutt-1.3.27/keymap.c
119--- mutt-1.3.27.orig/keymap.c Tue Oct 16 16:29:02 2001
120+++ mutt-1.3.27/keymap.c Wed Jan 23 22:35:32 2002
121@@ -50,4 +50,6 @@ struct mapping_t Menus[] = {
122
123 { "query", MENU_QUERY },
124+ { "signature", MENU_SIG },
125+ { "sig_directory", MENU_SIG_DIR },
126 { "generic", MENU_GENERIC },
127 { NULL, 0 }
128@@ -528,4 +530,6 @@ void km_init (void)
129 create_bindings (OpQuery, MENU_QUERY);
130 create_bindings (OpAlias, MENU_ALIAS);
131+ create_bindings (OpSig, MENU_SIG);
132+ create_bindings (OpSigDir, MENU_SIG_DIR);
133
134
135@@ -619,4 +623,7 @@ void km_init (void)
136 km_bindkey ("<enter>", MENU_COMPOSE, OP_VIEW_ATTACH);
137
138+ km_bindkey ("<up>", MENU_SIG, OP_PREV_SIG);
139+ km_bindkey ("<down>", MENU_SIG, OP_NEXT_SIG);
140+
141 /* edit-to (default "t") hides generic tag-entry in Compose menu
142 This will bind tag-entry to "T" in the Compose menu */
143@@ -739,4 +746,8 @@ struct binding_t *km_get_table (int menu
144 case MENU_QUERY:
145 return OpQuery;
146+ case MENU_SIG:
147+ return OpSig;
148+ case MENU_SIG_DIR:
149+ return OpSigDir;
150
151
152diff -pruN2 mutt-1.3.27.orig/keymap.h mutt-1.3.27/keymap.h
153--- mutt-1.3.27.orig/keymap.h Tue Sep 11 12:50:12 2001
154+++ mutt-1.3.27/keymap.h Wed Jan 23 22:35:32 2002
155@@ -60,4 +60,6 @@ enum
156 MENU_POST,
157 MENU_QUERY,
158+ MENU_SIG,
159+ MENU_SIG_DIR,
160
161
162@@ -102,4 +104,6 @@ extern struct binding_t OpEditor[];
163 extern struct binding_t OpQuery[];
164 extern struct binding_t OpAlias[];
165+extern struct binding_t OpSig[];
166+extern struct binding_t OpSigDir[];
167
168 #ifdef HAVE_PGP
169diff -pruN2 mutt-1.3.27.orig/protos.h mutt-1.3.27/protos.h
170--- mutt-1.3.27.orig/protos.h Wed Jan 16 21:43:58 2002
171+++ mutt-1.3.27/protos.h Wed Jan 23 22:35:32 2002
172@@ -225,4 +225,5 @@ void mutt_shell_escape (void);
173 void mutt_show_error (void);
174 void mutt_signal_init (void);
175+void mutt_signature (char *);
176 void mutt_stamp_attachment (BODY *a);
177 void mutt_tabs_to_spaces (char *);
178diff -pruN2 mutt-1.3.27.orig/signature.c mutt-1.3.27/signature.c
179--- mutt-1.3.27.orig/signature.c Thu Jan 1 01:00:00 1970
180+++ mutt-1.3.27/signature.c Wed Jan 23 22:35:32 2002
b324a978 181@@ -0,0 +1,499 @@
68667aa0 182+/*
183+ * Copyright (C) 2001 Cedric Duval <cedricduval@free.fr>
184+ *
185+ * This program is free software; you can redistribute it and/or modify
186+ * it under the terms of the GNU General Public License as published by
187+ * the Free Software Foundation; either version 2 of the License, or
188+ * (at your option) any later version.
189+ *
190+ * This program is distributed in the hope that it will be useful,
191+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
192+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
193+ * GNU General Public License for more details.
194+ *
195+ * You should have received a copy of the GNU General Public License
196+ * along with this program; if not, write to the Free Software
197+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
198+ */
199+
68eeb855 200+#if HAVE_CONFIG_H
201+# include "config.h"
202+#endif
203+
68667aa0 204+#include "mutt.h"
205+#include "mutt_menu.h"
206+#include "mapping.h"
207+#include "mutt_curses.h"
208+
209+#include <stdio.h>
210+#include <string.h>
211+#include <stdlib.h>
212+#include <dirent.h>
213+#include <sys/stat.h>
214+
215+#define SIG_DISPLAY_LINES 4
216+#define SEPARATOR(x) ((*x == '\n') || (mutt_strcmp (x, "-- \n") == 0))
217+#define SIG_ADD_LINE(x,y) mutt_add_list (x, strtok (y, "\n"))
218+
219+typedef struct sig_list
220+{
221+ struct sig_list *next;
222+ LIST *sig;
223+} SIG_LIST;
224+
225+typedef struct sig_dir
226+{
227+ struct sig_dir *next;
228+ char *name;
229+} SIG_DIR;
230+
231+typedef LIST * ENTRY;
232+
233+typedef struct entry_dir
234+{
235+ int tagged;
236+ SIG_DIR *data;
237+} ENTRY_DIR;
238+
239+static struct mapping_t SigHelp[] = {
240+ { N_("Exit"), OP_EXIT },
241+ { N_("Search"), OP_SEARCH },
242+ { N_("Random"), OP_RANDOM_SIG },
243+ { N_("Help"), OP_HELP },
244+ { NULL }
245+};
246+
247+static struct mapping_t SigDirHelp[] = {
248+ { N_("Exit"), OP_EXIT },
249+ { N_("Search signature"), OP_SIG_SEARCH },
250+ { N_("Help"), OP_HELP },
251+ { NULL }
252+};
253+
254+void menu_next_entry (MUTTMENU *menu);
255+void menu_prev_entry (MUTTMENU *menu);
256+
257+
258+static int sig_match (LIST *s, regex_t *re)
259+{
260+ while (s)
261+ {
262+ if (regexec (re, s->data, (size_t)0, NULL, (int)0) == 0)
263+ return 1;
264+ s = s->next;
265+ }
266+ return 0;
267+}
268+
269+static void read_sig_file (char *name, SIG_LIST **begin, regex_t *re)
270+{
271+ FILE *fp;
272+ char buf[STRING];
273+ LIST *sig = NULL;
274+ SIG_LIST *first, *cur;
275+ int append = 0;
276+
277+ if (!(fp = safe_fopen (name, "r")))
278+ {
279+ mutt_error (_("Can't open signature file %s"), name);
280+ return;
281+ }
282+
283+ for (first = *begin; first && first->next; first = first->next, append++)
284+ ; /* append results to an existing list */
285+ cur = first;
286+
287+ while (fgets (buf, sizeof (buf), fp))
288+ {
289+ if (buf[0] && !SEPARATOR (buf))
290+ {
291+ sig = SIG_ADD_LINE (NULL, buf);
292+
293+ while (fgets (buf, sizeof (buf), fp) && buf[0] && !SEPARATOR (buf))
294+ SIG_ADD_LINE (sig, buf);
295+
296+ if (re && !sig_match (sig, re))
297+ mutt_free_list (&sig); /* previous sig didn't match the regexp */
298+ else
299+ {
300+ /* add signature */
301+ if (first == NULL)
302+ first = cur = (SIG_LIST *) safe_calloc (1, sizeof (SIG_LIST));
303+ else
304+ {
305+ cur->next = (SIG_LIST *) safe_calloc (1, sizeof (SIG_LIST));
306+ cur = cur->next;
307+ }
308+
309+ cur->sig = sig;
310+ cur->next = NULL;
311+ }
312+ }
313+ }
314+
315+ if (!append)
316+ *begin = first;
317+
318+ safe_fclose (&fp);
319+}
320+
321+static void sig_make_entry (char *s, size_t slen, MUTTMENU *menu, int num)
322+{
323+ ENTRY *table = (ENTRY *) menu->data;
324+
325+ snprintf (s, slen, "%3d %s",
326+ num + 1,
327+ table[num]->data);
328+}
329+
330+static int sig_menu_search (MUTTMENU *menu, regex_t *re, int num)
331+{
332+ return (sig_match (((ENTRY *)menu->data)[num], re) ? 0 : REG_NOMATCH);
333+}
334+
335+static void draw_sig_frame (LIST *s)
336+{
337+ int i;
338+
339+ for (i = 1; i <= SIG_DISPLAY_LINES; i++)
340+ {
341+ if (s)
342+ {
343+ mvaddstr (i, 0, s->data);
344+ s = s->next;
345+ }
346+ else
347+ move (i, 0);
348+
349+ clrtoeol ();
350+ }
351+
352+ SETCOLOR (MT_COLOR_STATUS);
353+ mvaddstr (SIG_DISPLAY_LINES + 1, 0, _("-- Signature"));
c59ea3a3 354+ SETCOLOR (MT_COLOR_STATUS);
68667aa0 355+ clrtoeol ();
356+
c59ea3a3 357+ NORMAL_COLOR;
68667aa0 358+}
359+
360+static void free_sig_list (SIG_LIST **sigs)
361+{
362+ SIG_LIST *cur;
363+
364+ while (*sigs)
365+ {
366+ cur = *sigs;
367+ *sigs = (*sigs)->next;
368+ mutt_free_list (&cur->sig);
369+ safe_free ((void **)&cur);
370+ }
371+}
372+
373+static void append_signature (char *msg_file, LIST *s)
374+{
375+ FILE *fp;
376+
377+ if ((fp = safe_fopen (msg_file, "a")) == 0)
378+ mutt_perror (msg_file);
379+ else
380+ {
381+ if (option (OPTSIGDASHES))
382+ fputs ("\n-- \n", fp);
383+
384+ for (; s; s = s->next)
385+ fprintf (fp, "%s\n", s->data);
386+
387+ mutt_message (_("Signature appended to your mail"));
388+ safe_fclose (&fp);
389+ }
390+}
391+
392+static LIST *sig_list_menu (char *file, SIG_LIST *list)
393+{
394+ LIST *result = NULL;
395+ SIG_LIST *sigl;
396+ MUTTMENU *menu;
397+ ENTRY *SigTable;
398+ char helpstr[SHORT_STRING], title[SHORT_STRING];
399+ int i, done = 0;
400+
401+ snprintf (title, sizeof (title), _("Signature : %s"), file);
402+
b3471c65 403+ menu = mutt_new_menu (MENU_SIG);
68667aa0 404+ menu->make_entry = sig_make_entry;
405+ menu->tag = NULL;
406+ menu->search = sig_menu_search;
68667aa0 407+ menu->title = title;
408+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr),
409+ MENU_SIG, SigHelp);
410+ menu->offset = SIG_DISPLAY_LINES + 2;
411+ menu->pagelen = LINES - SIG_DISPLAY_LINES - 4;
412+
413+ for (sigl = list; sigl; sigl = sigl->next)
414+ menu->max++;
415+
416+ menu->data = SigTable = (ENTRY *) safe_calloc (menu->max, sizeof (ENTRY));
417+
418+ for (i = 0, sigl = list; sigl; i++, sigl = sigl->next)
419+ SigTable[i] = sigl->sig;
420+
421+ while (!done)
422+ {
423+ switch (mutt_menuLoop (menu))
424+ {
425+ case OP_GENERIC_SELECT_ENTRY:
426+ result = SigTable[menu->current];
427+ done = 1;
428+ break;
429+
430+ case OP_PREV_SIG:
431+ menu_prev_entry (menu);
432+ draw_sig_frame (SigTable[menu->current]);
433+ break;
434+
435+ case OP_NEXT_SIG:
436+ menu_next_entry (menu);
437+ draw_sig_frame (SigTable[menu->current]);
438+ break;
439+
440+ case OP_REDRAW:
441+ menu->offset = SIG_DISPLAY_LINES + 2;
442+ menu->pagelen = LINES - SIG_DISPLAY_LINES - 4;
443+ draw_sig_frame (SigTable[menu->current]);
444+ break;
445+
446+ case OP_RANDOM_SIG:
447+ menu->current = LRAND () % menu->max;
448+ draw_sig_frame (SigTable[menu->current]);
449+ menu->redraw |= REDRAW_MOTION;
450+ break;
451+
452+ case OP_EXIT:
68667aa0 453+ done = 1;
454+ break;
455+ }
456+ }
457+
458+ mutt_menuDestroy (&menu);
459+ safe_free ((void **)&SigTable);
460+ return result;
461+}
462+
b3471c65
JR
463+extern char* SearchBuffers[MENU_MAX];
464+
68667aa0 465+static SIG_LIST *sig_search_filter (MUTTMENU *menu, char *path)
466+{
467+ regex_t re;
468+ char buf[STRING];
469+ SIG_LIST *result = NULL;
470+ int i;
eb755509
JR
471+ char* searchBuf = menu->menu >= 0 && menu->menu < MENU_MAX ?
472+ SearchBuffers[menu->menu] : NULL;
68667aa0 473+
eb755509 474+ snprintf (buf, sizeof(buf), searchBuf ? searchBuf : "");
68667aa0 475+ if (mutt_get_field (_("Search for: "), buf,
b324a978 476+ sizeof (buf), MUTT_CLEAR) != 0 || !buf[0])
68667aa0 477+ return (NULL);
eb755509
JR
478+ if (menu->menu >= 0 && menu->menu < MENU_MAX)
479+ {
480+ mutt_str_replace (&SearchBuffers[menu->menu], buf);
481+ searchBuf = SearchBuffers[menu->menu];
482+ }
68667aa0 483+
eb755509
JR
484+ if ((i = regcomp (&re, searchBuf, REG_NOSUB | REG_EXTENDED | REG_WORDS
485+ | mutt_which_case (searchBuf))) != 0)
68667aa0 486+ {
487+ regerror (i, &re, buf, sizeof (buf));
488+ regfree (&re);
489+ mutt_error ("%s", buf);
490+ return (NULL);
491+ }
492+
493+ /* building list of sigs matching the regexp */
494+ for (i = 0; i < menu->max; i++)
495+ {
496+ /* search in every file if none is tagged */
497+ if (((ENTRY_DIR *) menu->data)[i].tagged || (menu->tagged == 0))
498+ {
499+ snprintf (buf, sizeof (buf), "%s/%s", path,
500+ ((ENTRY_DIR *) menu->data)[i].data->name);
501+ read_sig_file (buf, &result, &re);
502+ }
503+ }
504+
505+ regfree (&re);
506+ if (!result)
507+ mutt_error (_("Not found."));
508+
509+ return (result);
510+}
511+
512+/* returns the list of files in this directory */
513+static SIG_DIR *sig_directory (char *path)
514+{
515+ DIR *dp;
516+ struct dirent *de;
517+ struct stat s;
518+ SIG_DIR *first = NULL, *cur = NULL;
519+ char file[_POSIX_PATH_MAX + SHORT_STRING];
520+
521+ if ((dp = opendir (path)) == NULL)
522+ {
523+ mutt_perror (path);
524+ return (NULL);
525+ }
526+
527+ while ((de = readdir (dp)))
528+ {
529+ if ((de->d_name)[0] == '.') /* no hidden files */
530+ continue;
531+
532+ snprintf (file, sizeof (file), "%s/%s", path, de->d_name);
533+ if (lstat (file, &s) == -1)
534+ continue;
535+
536+ if ((!S_ISREG (s.st_mode)) && (!S_ISLNK (s.st_mode)))
537+ continue;
538+
539+ if (first == NULL)
540+ cur = first = safe_calloc (1, sizeof (SIG_DIR));
541+ else
542+ {
543+ cur->next = safe_calloc (1, sizeof (SIG_DIR));
544+ cur = cur->next;
545+ }
546+ cur->name = safe_strdup (de->d_name);
547+ cur->next = NULL;
548+ }
549+ closedir (dp);
550+ return first;
551+}
552+
553+static void sig_dir_make_entry (char *s, size_t slen, MUTTMENU *menu, int num)
554+{
555+ ENTRY_DIR *table = (ENTRY_DIR *) menu->data;
556+
557+ snprintf (s, slen, "%c %3d - %s",
558+ table[num].tagged ? '*' : ' ',
559+ num + 1,
560+ table[num].data->name);
561+}
562+
563+static int sig_dir_tag (MUTTMENU *menu, int n, int m)
564+{
565+ ENTRY_DIR *cur = &((ENTRY_DIR *) menu->data)[n];
566+ int ot = cur->tagged;
567+
568+ cur->tagged = m >= 0 ? m : !cur->tagged;
569+ return cur->tagged - ot;
570+
571+}
572+
573+static int sig_dir_sort (const void *a, const void *b)
574+{
575+ ENTRY_DIR *pa = (ENTRY_DIR *) a;
576+ ENTRY_DIR *pb = (ENTRY_DIR *) b;
577+
578+ return (mutt_strcmp (pa->data->name, pb->data->name));
579+}
580+
581+static int sig_dir_menu (char *path, char *msg_file)
582+{
583+ MUTTMENU *menu;
584+ SIG_LIST *sigl;
585+ LIST *result = NULL;
586+ ENTRY_DIR *FileTable;
587+ SIG_DIR *list, *files;
588+ char buf[STRING], helpstr[SHORT_STRING], title[SHORT_STRING];
589+ int i, done = 0;
590+
591+ if ((list = sig_directory (path)) == NULL)
592+ return -1;
593+
594+ snprintf (title, sizeof (title), "Signature directory : %s", path);
595+
b3471c65 596+ menu = mutt_new_menu (MENU_SIG_DIR);
68667aa0 597+ menu->make_entry = sig_dir_make_entry;
598+ menu->search = NULL; /* search within files with sig_search_filter() */
599+ menu->tag = sig_dir_tag;
68667aa0 600+ menu->title = title;
601+ menu->help = mutt_compile_help (helpstr, sizeof (helpstr),
602+ MENU_SIG_DIR, SigDirHelp);
603+
604+ for (files = list; files; files = files->next)
605+ menu->max++;
606+
607+ menu->data = FileTable = (ENTRY_DIR *) safe_calloc (menu->max,
608+ sizeof (ENTRY_DIR));
609+
610+ for (i = 0, files = list; files; i++, files = files->next)
611+ FileTable[i].data = files;
612+
613+ qsort (FileTable, menu->max, sizeof (ENTRY_DIR), sig_dir_sort);
614+
615+ while (!done)
616+ {
617+ switch (mutt_menuLoop (menu))
618+ {
619+ case OP_SIG_SEARCH:
620+ sigl = sig_search_filter (menu, path);
621+
622+ if (sigl)
623+ {
624+ if ((result = sig_list_menu (_("query results"), sigl)) != NULL)
625+ {
626+ append_signature (msg_file, result);
627+ done = 1;
628+ }
629+
68667aa0 630+ free_sig_list (&sigl);
631+ }
632+ break;
633+
634+ case OP_GENERIC_SELECT_ENTRY:
635+ snprintf (buf, sizeof (buf), "%s/%s", path,
636+ FileTable[menu->current].data->name);
637+ sigl = NULL;
638+ read_sig_file (buf, &sigl, NULL);
639+
640+ if (sigl)
641+ {
642+ if ((result = sig_list_menu (buf, sigl)) != NULL)
643+ {
644+ append_signature (msg_file, result);
645+ done = 1;
646+ }
647+
68667aa0 648+ free_sig_list (&sigl);
649+ }
650+ break;
651+
652+ case OP_EXIT:
653+ done = 1;
654+ break;
655+ }
656+ }
657+
658+ while (list)
659+ {
660+ safe_free ((void **)&list->name);
661+ files = list;
662+ list = list->next;
663+ safe_free ((void **)&files);
664+ }
665+ safe_free ((void **)&FileTable);
666+ mutt_menuDestroy (&menu);
667+ return 0;
668+}
669+
670+void mutt_signature (char *msg_file)
671+{
672+ if (!SigDirectory)
673+ {
674+ mutt_error (_("variable 'signatures_directory' is unset"));
675+ return;
676+ }
677+
678+ if (sig_dir_menu (SigDirectory, msg_file) == -1)
679+ mutt_error (_("%s: no files in this directory"), SigDirectory);
68667aa0 680+}
681diff -pruN mutt-1.3.27.orig/PATCHES mutt-1.3.27/PATCHES
682--- mutt-1.3.27.orig/PATCHES Mon Nov 26 20:16:52 2001
683+++ mutt-1.3.27/PATCHES Thu Dec 6 16:27:55 2001
c59ea3a3 684@@ -1,0 +2 @@
68667aa0 685+patch-1.3.27.cd.signatures_menu.2.1
0dd9f701
JR
686diff --git a/menu.c b/menu.c
687--- a/menu.c
688+++ b/menu.c
c59ea3a3 689@@ -642,7 +642,7 @@
0dd9f701
JR
690 mutt_error _("No entries.");
691 }
692
693-static void menu_next_entry (MUTTMENU *menu)
694+void menu_next_entry (MUTTMENU *menu)
695 {
696 if (menu->current < menu->max - 1)
697 {
c59ea3a3 698@@ -653,7 +653,7 @@
0dd9f701
JR
699 mutt_error _("You are on the last entry.");
700 }
701
702-static void menu_prev_entry (MUTTMENU *menu)
703+void menu_prev_entry (MUTTMENU *menu)
704 {
705 if (menu->current)
706 {
This page took 1.030645 seconds and 4 git commands to generate.