2 chat-completion.c : irssi
4 Copyright (C) 1999-2000 Timo Sirainen
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "servers-setup.h"
31 #include "channels-setup.h"
35 #include "completion.h"
36 #include "window-items.h"
38 static int keep_privates_count, keep_publics_count;
39 static int completion_lowercase;
40 static const char *completion_char, *cmdchars;
41 static GSList *global_lastmsgs;
42 static int completion_auto, completion_strict;
44 #define SERVER_LAST_MSG_ADD(server, nick) \
45 last_msg_add(&((MODULE_SERVER_REC *) MODULE_DATA(server))->lastmsgs, \
46 nick, TRUE, keep_privates_count)
48 #define CHANNEL_LAST_MSG_ADD(channel, nick, own) \
49 last_msg_add(&((MODULE_CHANNEL_REC *) MODULE_DATA(channel))->lastmsgs, \
50 nick, own, keep_publics_count)
52 static LAST_MSG_REC *last_msg_find(GSList *list, const char *nick)
54 while (list != NULL) {
55 LAST_MSG_REC *rec = list->data;
57 if (g_strcasecmp(rec->nick, nick) == 0)
65 static void last_msg_dec_owns(GSList *list)
69 while (list != NULL) {
71 if (rec->own) rec->own--;
77 static void last_msg_add(GSList **list, const char *nick, int own, int max)
81 rec = last_msg_find(*list, nick);
83 /* msg already exists, update it */
84 *list = g_slist_remove(*list, rec);
90 rec = g_new(LAST_MSG_REC, 1);
91 rec->nick = g_strdup(nick);
93 if ((int)g_slist_length(*list) == max) {
94 *list = g_slist_remove(*list,
95 g_slist_last(*list)->data);
98 rec->own = own ? max : 0;
100 rec->time = time(NULL);
102 last_msg_dec_owns(*list);
104 *list = g_slist_prepend(*list, rec);
107 static void last_msg_destroy(GSList **list, LAST_MSG_REC *rec)
109 *list = g_slist_remove(*list, rec);
115 void completion_last_message_add(const char *nick)
117 g_return_if_fail(nick != NULL);
119 last_msg_add(&global_lastmsgs, nick, TRUE, keep_privates_count);
122 void completion_last_message_remove(const char *nick)
126 g_return_if_fail(nick != NULL);
128 rec = last_msg_find(global_lastmsgs, nick);
129 if (rec != NULL) last_msg_destroy(&global_lastmsgs, rec);
132 void completion_last_message_rename(const char *oldnick, const char *newnick)
136 g_return_if_fail(oldnick != NULL);
137 g_return_if_fail(newnick != NULL);
139 rec = last_msg_find(global_lastmsgs, oldnick);
142 rec->nick = g_strdup(newnick);
146 static void sig_message_public(SERVER_REC *server, const char *msg,
147 const char *nick, const char *address,
150 CHANNEL_REC *channel;
153 channel = channel_find(server, target);
154 if (channel != NULL) {
155 own = nick_match_msg(channel, msg, server->nick);
156 CHANNEL_LAST_MSG_ADD(channel, nick, own);
160 static void sig_message_join(SERVER_REC *server, const char *channel,
161 const char *nick, const char *address)
163 CHANNEL_REC *chanrec;
165 chanrec = channel_find(server, channel);
167 CHANNEL_LAST_MSG_ADD(chanrec, nick, FALSE);
170 static void sig_message_private(SERVER_REC *server, const char *msg,
171 const char *nick, const char *address)
173 g_return_if_fail(server != NULL);
174 g_return_if_fail(nick != NULL);
176 SERVER_LAST_MSG_ADD(server, nick);
179 static void sig_message_own_public(SERVER_REC *server, const char *msg,
180 const char *target, const char *origtarget)
182 CHANNEL_REC *channel;
186 g_return_if_fail(server != NULL);
187 g_return_if_fail(msg != NULL);
188 if (target == NULL) return;
190 channel = channel_find(server, target);
194 /* channel msg - if first word in line is nick,
195 add it to lastmsgs */
196 p = strchr(msg, ' ');
197 if (p != NULL && p != msg) {
198 msgnick = g_strndup(msg, (int) (p-msg));
199 nick = nicklist_find(channel, msgnick);
200 if (nick == NULL && msgnick[1] != '\0') {
201 /* probably ':' or ',' or some other
202 char after nick, try without it */
203 msgnick[strlen(msgnick)-1] = '\0';
204 nick = nicklist_find(channel, msgnick);
207 if (nick != NULL && nick != channel->ownnick)
208 CHANNEL_LAST_MSG_ADD(channel, nick->nick, TRUE);
212 static void sig_message_own_private(SERVER_REC *server, const char *msg,
213 const char *target, const char *origtarget)
215 g_return_if_fail(server != NULL);
216 g_return_if_fail(target != NULL);
218 if (target != NULL && query_find(server, target) == NULL)
219 SERVER_LAST_MSG_ADD(server, target);
222 static void sig_nick_removed(CHANNEL_REC *channel, NICK_REC *nick)
224 MODULE_CHANNEL_REC *mchannel;
227 mchannel = MODULE_DATA(channel);
228 rec = last_msg_find(mchannel->lastmsgs, nick->nick);
229 if (rec != NULL) last_msg_destroy(&mchannel->lastmsgs, rec);
232 static void sig_nick_changed(CHANNEL_REC *channel, NICK_REC *nick,
235 MODULE_CHANNEL_REC *mchannel;
238 mchannel = MODULE_DATA(channel);
239 rec = last_msg_find(mchannel->lastmsgs, oldnick);
242 rec->nick = g_strdup(nick->nick);
246 static int last_msg_cmp(LAST_MSG_REC *m1, LAST_MSG_REC *m2)
248 return m1->time < m2->time ? 1 : -1;
251 /* Complete /MSG from specified server, or from
252 global_lastmsgs if server is NULL */
253 static void completion_msg_server(GSList **list, SERVER_REC *server,
254 const char *nick, const char *prefix)
260 g_return_if_fail(nick != NULL);
263 tmp = server == NULL ? global_lastmsgs :
264 ((MODULE_SERVER_REC *) MODULE_DATA(server))->lastmsgs;
265 for (; tmp != NULL; tmp = tmp->next) {
266 LAST_MSG_REC *rec = tmp->data;
268 if (len != 0 && g_strncasecmp(rec->nick, nick, len) != 0)
271 msg = g_new(LAST_MSG_REC, 1);
272 msg->time = rec->time;
273 msg->nick = prefix == NULL || *prefix == '\0' ?
274 g_strdup(rec->nick) :
275 g_strconcat(prefix, " ", rec->nick, NULL);
276 *list = g_slist_insert_sorted(*list, msg,
277 (GCompareFunc) last_msg_cmp);
281 /* convert list of LAST_MSG_REC's to list of char* nicks. */
282 static GList *convert_msglist(GSList *msglist)
287 while (msglist != NULL) {
288 LAST_MSG_REC *rec = msglist->data;
290 list = g_list_append(list, rec->nick);
291 msglist = g_slist_remove(msglist, rec);
298 /* Complete /MSG - if `find_server' is NULL, complete nicks from all servers */
299 static GList *completion_msg(SERVER_REC *win_server,
300 SERVER_REC *find_server,
301 const char *nick, const char *prefix)
306 g_return_val_if_fail(nick != NULL, NULL);
307 if (servers == NULL) return NULL;
310 if (find_server != NULL) {
311 completion_msg_server(&list, find_server, nick, prefix);
312 return convert_msglist(list);
315 completion_msg_server(&list, NULL, nick, prefix);
316 for (tmp = servers; tmp != NULL; tmp = tmp->next) {
317 SERVER_REC *rec = tmp->data;
319 if (rec == win_server)
320 newprefix = g_strdup(prefix);
322 newprefix = prefix == NULL ?
323 g_strdup_printf("-%s", rec->tag) :
324 g_strdup_printf("%s -%s", prefix, rec->tag);
327 completion_msg_server(&list, rec, nick, newprefix);
328 g_free_not_null(newprefix);
331 return convert_msglist(list);
334 static void complete_from_nicklist(GList **outlist, CHANNEL_REC *channel,
335 const char *nick, const char *suffix)
337 MODULE_CHANNEL_REC *mchannel;
343 /* go through the last x nicks who have said something in the channel.
344 nicks of all the "own messages" are placed before others */
347 mchannel = MODULE_DATA(channel);
348 for (tmp = mchannel->lastmsgs; tmp != NULL; tmp = tmp->next) {
349 LAST_MSG_REC *rec = tmp->data;
351 if (g_strncasecmp(rec->nick, nick, len) == 0 &&
352 glist_find_icase_string(*outlist, rec->nick) == NULL) {
353 str = g_strconcat(rec->nick, suffix, NULL);
354 if (completion_lowercase) g_strdown(str);
356 ownlist = g_list_append(ownlist, str);
358 *outlist = g_list_append(*outlist, str);
362 *outlist = g_list_concat(ownlist, *outlist);
365 static GList *completion_nicks_nonstrict(CHANNEL_REC *channel,
371 char *tnick, *str, *in, *out;
372 int len, str_len, tmplen;
374 g_return_val_if_fail(channel != NULL, NULL);
378 /* get all nicks from current channel, strip non alnum chars,
379 compare again and add to completion list on matching */
381 nicks = nicklist_getnicks(channel);
383 str_len = 80; str = g_malloc(str_len+1);
384 for (tmp = nicks; tmp != NULL; tmp = tmp->next) {
385 NICK_REC *rec = tmp->data;
387 tmplen = strlen(rec->nick);
388 if (tmplen > str_len) {
390 str = g_realloc(str, str_len+1);
393 /* remove non alnum chars from nick */
394 in = rec->nick; out = str;
395 while (*in != '\0') {
402 /* add to list if 'cleaned' nick matches */
403 if (g_strncasecmp(str, nick, len) == 0) {
404 tnick = g_strconcat(rec->nick, suffix, NULL);
405 if (completion_lowercase)
408 if (glist_find_icase_string(list, tnick) == NULL)
409 list = g_list_append(list, tnick);
421 static GList *completion_channel_nicks(CHANNEL_REC *channel, const char *nick,
429 g_return_val_if_fail(channel != NULL, NULL);
430 g_return_val_if_fail(nick != NULL, NULL);
431 if (*nick == '\0') return NULL;
433 if (suffix != NULL && *suffix == '\0')
436 /* put first the nicks who have recently said something */
438 complete_from_nicklist(&list, channel, nick, suffix);
440 /* and add the rest of the nicks too */
442 nicks = nicklist_getnicks(channel);
443 for (tmp = nicks; tmp != NULL; tmp = tmp->next) {
444 NICK_REC *rec = tmp->data;
446 if (g_strncasecmp(rec->nick, nick, len) == 0 &&
447 rec != channel->ownnick) {
448 str = g_strconcat(rec->nick, suffix, NULL);
449 if (completion_lowercase)
451 if (glist_find_icase_string(list, str) == NULL)
452 list = g_list_append(list, str);
459 /* remove non alphanum chars from nick and search again in case
460 list is still NULL ("foo<tab>" would match "_foo_" f.e.) */
461 if (!completion_strict)
462 list = g_list_concat(list, completion_nicks_nonstrict(channel, nick, suffix));
466 /* append all strings in list2 to list1 that already aren't there and
468 static GList *completion_joinlist(GList *list1, GList *list2)
473 while (list2 != NULL) {
474 if (!glist_find_icase_string(list1, list2->data))
475 list1 = g_list_append(list1, list2->data);
486 GList *completion_get_channels(SERVER_REC *server, const char *word)
492 g_return_val_if_fail(word != NULL, NULL);
493 g_return_val_if_fail(*word != '\0', NULL);
498 /* first get the joined channels */
499 tmp = server == NULL ? NULL : server->channels;
500 for (; tmp != NULL; tmp = tmp->next) {
501 CHANNEL_REC *rec = tmp->data;
503 if (g_strncasecmp(rec->name, word, len) == 0)
504 list = g_list_append(list, g_strdup(rec->name));
507 /* get channels from setup */
508 for (tmp = setupchannels; tmp != NULL; tmp = tmp->next) {
509 CHANNEL_SETUP_REC *rec = tmp->data;
511 if (g_strncasecmp(rec->name, word, len) == 0 &&
512 glist_find_icase_string(list, rec->name) == NULL)
513 list = g_list_append(list, g_strdup(rec->name));
520 static void complete_window_nicks(GList **list, WINDOW_REC *window,
521 const char *word, const char *linestart)
523 CHANNEL_REC *channel;
526 const char *nicksuffix;
528 nicksuffix = *linestart != '\0' ? NULL : completion_char;
530 channel = CHANNEL(window->active);
532 /* first the active channel */
533 if (channel != NULL) {
534 tmplist = completion_channel_nicks(channel, word, nicksuffix);
535 *list = completion_joinlist(*list, tmplist);
538 if (nicksuffix != NULL) {
539 /* completing nick at the start of line - probably answering
540 to some other nick, don't even try to complete from
541 non-active channels */
546 for (tmp = window->items; tmp != NULL; tmp = tmp->next) {
547 channel = CHANNEL(tmp->data);
548 if (channel != NULL && tmp->data != window->active) {
549 tmplist = completion_channel_nicks(channel, word,
551 *list = completion_joinlist(*list, tmplist);
556 static void sig_complete_word(GList **list, WINDOW_REC *window,
557 const char *word, const char *linestart,
561 CHANNEL_REC *channel;
565 g_return_if_fail(list != NULL);
566 g_return_if_fail(window != NULL);
567 g_return_if_fail(word != NULL);
568 g_return_if_fail(linestart != NULL);
570 server = window->active_server;
571 if (server == NULL && servers != NULL)
572 server = servers->data;
574 if (server != NULL && server_ischannel(server, word)) {
575 /* probably completing a channel name */
576 *list = completion_get_channels(window->active_server, word);
580 server = window->active_server;
581 if (server == NULL || !server->connected)
584 if (*linestart == '\0' && *word == '\0') {
585 /* pressed TAB at the start of line - add /MSG */
586 prefix = g_strdup_printf("%cmsg", *cmdchars);
587 *list = completion_msg(server, NULL, "", prefix);
589 *list = g_list_append(*list, g_strdup(prefix));
596 channel = CHANNEL(window->active);
597 query = QUERY(window->active);
598 if (channel == NULL && query != NULL &&
599 g_strncasecmp(word, query->name, strlen(word)) == 0) {
600 /* completion in query */
601 *list = g_list_append(*list, g_strdup(query->name));
602 } else if (channel != NULL) {
603 /* nick completion .. we could also be completing a nick
604 after /MSG from nicks in channel */
605 complete_window_nicks(list, window, word, linestart);
608 if (*list != NULL) signal_stop();
611 static SERVER_REC *line_get_server(const char *line)
616 g_return_val_if_fail(line != NULL, NULL);
617 if (*line != '-') return NULL;
619 /* -option found - should be server tag */
620 tag = g_strdup(line+1);
621 ptr = strchr(tag, ' ');
622 if (ptr != NULL) *ptr = '\0';
624 server = server_find_tag(tag);
630 static void sig_complete_msg(GList **list, WINDOW_REC *window,
631 const char *word, const char *line,
634 SERVER_REC *server, *msgserver;
636 g_return_if_fail(list != NULL);
637 g_return_if_fail(word != NULL);
638 g_return_if_fail(line != NULL);
640 server = window->active_server;
641 if (server == NULL || !server->connected)
644 msgserver = line_get_server(line);
645 *list = completion_msg(server, msgserver, word, NULL);
646 if (*list != NULL) signal_stop();
649 static void sig_erase_complete_msg(WINDOW_REC *window, const char *word,
653 MODULE_SERVER_REC *mserver;
656 server = line_get_server(line);
658 server = window->active_server;
666 /* check from global list */
667 completion_last_message_remove(word);
669 /* check from server specific list */
670 if (server != NULL) {
671 mserver = MODULE_DATA(server);
672 for (tmp = mserver->lastmsgs; tmp != NULL; tmp = tmp->next) {
673 LAST_MSG_REC *rec = tmp->data;
675 if (g_strcasecmp(rec->nick, word) == 0) {
676 last_msg_destroy(&mserver->lastmsgs, rec);
684 GList *completion_get_chatnets(const char *word)
690 g_return_val_if_fail(word != NULL, NULL);
695 for (tmp = chatnets; tmp != NULL; tmp = tmp->next) {
696 CHATNET_REC *rec = tmp->data;
698 if (g_strncasecmp(rec->name, word, len) == 0)
699 list = g_list_append(list, g_strdup(rec->name));
705 GList *completion_get_servers(const char *word)
711 g_return_val_if_fail(word != NULL, NULL);
716 for (tmp = setupservers; tmp != NULL; tmp = tmp->next) {
717 SERVER_SETUP_REC *rec = tmp->data;
719 if (g_strncasecmp(rec->address, word, len) == 0)
720 list = g_list_append(list, g_strdup(rec->address));
726 static void sig_complete_connect(GList **list, WINDOW_REC *window,
727 const char *word, const char *line,
730 g_return_if_fail(list != NULL);
731 g_return_if_fail(word != NULL);
733 *list = completion_get_chatnets(word);
734 *list = g_list_concat(*list, completion_get_servers(word));
735 if (*list != NULL) signal_stop();
738 static void sig_complete_topic(GList **list, WINDOW_REC *window,
739 const char *word, const char *line,
744 g_return_if_fail(list != NULL);
745 g_return_if_fail(word != NULL);
747 if (*word == '\0' && IS_CHANNEL(window->active)) {
748 topic = CHANNEL(window->active)->topic;
750 *list = g_list_append(NULL, g_strdup(topic));
756 /* expand \n, \t and \\ */
757 static char *expand_escapes(const char *line, SERVER_REC *server,
763 ret = ptr = g_malloc(strlen(line)+1);
764 for (; *line != '\0'; line++) {
776 chr = expand_escape(&line);
777 if (chr == '\r' || chr == '\n') {
778 /* newline .. we need to send another "send text"
779 event to handle it (or actually the text before
783 signal_emit("send text", 3, ret, server, item);
786 } else if (chr != -1) {
787 /* escaping went ok */
790 /* unknown escape, add it as-is */
800 static char *auto_complete(CHANNEL_REC *channel, const char *line)
806 p = strstr(line, completion_char);
810 nick = g_strndup(line, (int) (p-line));
813 if (nicklist_find(channel, nick) == NULL) {
814 /* not an exact match, use the first possible completion */
815 comp = completion_channel_nicks(channel, nick, NULL);
817 ret = g_strconcat(comp->data, p, NULL);
818 g_list_foreach(comp, (GFunc) g_free, NULL);
828 static void event_text(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
832 g_return_if_fail(data != NULL);
833 if (item == NULL) return;
835 line = settings_get_bool("expand_escapes") ?
836 expand_escapes(data, server, item) : g_strdup(data);
838 /* check for automatic nick completion */
839 if (completion_auto && IS_CHANNEL(item)) {
840 str = auto_complete(CHANNEL(item), line);
847 str = g_strdup_printf(IS_CHANNEL(item) ? "-channel %s %s" :
848 IS_QUERY(item) ? "-nick %s %s" : "%s %s",
851 signal_emit("command msg", 3, str, server, item);
859 static void sig_server_disconnected(SERVER_REC *server)
861 MODULE_SERVER_REC *mserver;
863 g_return_if_fail(server != NULL);
865 mserver = MODULE_DATA(server);
866 while (mserver->lastmsgs)
867 last_msg_destroy(&mserver->lastmsgs, mserver->lastmsgs->data);
870 static void sig_channel_destroyed(CHANNEL_REC *channel)
872 MODULE_CHANNEL_REC *mchannel;
874 g_return_if_fail(channel != NULL);
876 mchannel = MODULE_DATA(channel);
877 while (mchannel->lastmsgs != NULL) {
878 last_msg_destroy(&mchannel->lastmsgs,
879 mchannel->lastmsgs->data);
883 static void read_settings(void)
885 keep_privates_count = settings_get_int("completion_keep_privates");
886 keep_publics_count = settings_get_int("completion_keep_publics");
887 completion_lowercase = settings_get_bool("completion_nicks_lowercase");
888 completion_char = settings_get_str("completion_char");
889 cmdchars = settings_get_str("cmdchars");
890 completion_auto = settings_get_bool("completion_auto");
891 completion_strict = settings_get_bool("completion_strict");
893 if (*completion_char == '\0') {
894 /* this would break.. */
895 completion_auto = FALSE;
899 void chat_completion_init(void)
901 settings_add_str("completion", "completion_char", ":");
902 settings_add_bool("completion", "completion_auto", FALSE);
903 settings_add_int("completion", "completion_keep_publics", 50);
904 settings_add_int("completion", "completion_keep_privates", 10);
905 settings_add_bool("completion", "expand_escapes", FALSE);
906 settings_add_bool("completion", "completion_nicks_lowercase", FALSE);
907 settings_add_bool("completion", "completion_strict", FALSE);
910 signal_add("complete word", (SIGNAL_FUNC) sig_complete_word);
911 signal_add("complete command msg", (SIGNAL_FUNC) sig_complete_msg);
912 signal_add("complete command query", (SIGNAL_FUNC) sig_complete_msg);
913 signal_add("complete erase command msg", (SIGNAL_FUNC) sig_erase_complete_msg);
914 signal_add("complete erase command query", (SIGNAL_FUNC) sig_erase_complete_msg);
915 signal_add("complete command connect", (SIGNAL_FUNC) sig_complete_connect);
916 signal_add("complete command server", (SIGNAL_FUNC) sig_complete_connect);
917 signal_add("complete command topic", (SIGNAL_FUNC) sig_complete_topic);
918 signal_add("message public", (SIGNAL_FUNC) sig_message_public);
919 signal_add("message join", (SIGNAL_FUNC) sig_message_join);
920 signal_add("message private", (SIGNAL_FUNC) sig_message_private);
921 signal_add("message own_public", (SIGNAL_FUNC) sig_message_own_public);
922 signal_add("message own_private", (SIGNAL_FUNC) sig_message_own_private);
923 signal_add("nicklist remove", (SIGNAL_FUNC) sig_nick_removed);
924 signal_add("nicklist changed", (SIGNAL_FUNC) sig_nick_changed);
925 signal_add("send text", (SIGNAL_FUNC) event_text);
926 signal_add("server disconnected", (SIGNAL_FUNC) sig_server_disconnected);
927 signal_add("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
928 signal_add("setup changed", (SIGNAL_FUNC) read_settings);
931 void chat_completion_deinit(void)
933 while (global_lastmsgs != NULL)
934 last_msg_destroy(&global_lastmsgs, global_lastmsgs->data);
936 signal_remove("complete word", (SIGNAL_FUNC) sig_complete_word);
937 signal_remove("complete command msg", (SIGNAL_FUNC) sig_complete_msg);
938 signal_remove("complete command query", (SIGNAL_FUNC) sig_complete_msg);
939 signal_remove("complete erase command msg", (SIGNAL_FUNC) sig_erase_complete_msg);
940 signal_remove("complete erase command query", (SIGNAL_FUNC) sig_erase_complete_msg);
941 signal_remove("complete command connect", (SIGNAL_FUNC) sig_complete_connect);
942 signal_remove("complete command server", (SIGNAL_FUNC) sig_complete_connect);
943 signal_remove("complete command topic", (SIGNAL_FUNC) sig_complete_topic);
944 signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
945 signal_remove("message join", (SIGNAL_FUNC) sig_message_join);
946 signal_remove("message private", (SIGNAL_FUNC) sig_message_private);
947 signal_remove("message own_public", (SIGNAL_FUNC) sig_message_own_public);
948 signal_remove("message own_private", (SIGNAL_FUNC) sig_message_own_private);
949 signal_remove("nicklist remove", (SIGNAL_FUNC) sig_nick_removed);
950 signal_remove("nicklist changed", (SIGNAL_FUNC) sig_nick_changed);
951 signal_remove("send text", (SIGNAL_FUNC) event_text);
952 signal_remove("server disconnected", (SIGNAL_FUNC) sig_server_disconnected);
953 signal_remove("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
954 signal_remove("setup changed", (SIGNAL_FUNC) read_settings);