annotate lisp/net/rcirc.el @ 67579:f9d4aaef32b2

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Wed, 14 Dec 2005 20:11:11 +0000
parents d3d8e2bcfa98
children 7e0fcbf84eb8 69e184bbba16
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; rcirc.el --- default, simple IRC client.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 2005 Free Software Foundation, Inc.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Ryan Yeske
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; URL: http://www.nongnu.org/rcirc
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Keywords: comm
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
66272
79d2a5d86ee4 Now part of GNU Emacs. Update FSF's address.
Romain Francoise <romain@orebokech.com>
parents: 66258
diff changeset
9 ;; This file is part of GNU Emacs.
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; This file is free software; you can redistribute it and/or modify
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; any later version.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; This file is distributed in the hope that it will be useful,
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
66272
79d2a5d86ee4 Now part of GNU Emacs. Update FSF's address.
Romain Francoise <romain@orebokech.com>
parents: 66258
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
79d2a5d86ee4 Now part of GNU Emacs. Update FSF's address.
Romain Francoise <romain@orebokech.com>
parents: 66258
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
79d2a5d86ee4 Now part of GNU Emacs. Update FSF's address.
Romain Francoise <romain@orebokech.com>
parents: 66258
diff changeset
24 ;; Boston, MA 02110-1301, USA.
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
28 ;; Internet Relay Chat (IRC) is a form of instant communication over
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
29 ;; the Internet. It is mainly designed for group (many-to-many)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
30 ;; communication in discussion forums called channels, but also allows
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
31 ;; one-to-one communication.
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
33 ;; Rcirc has simple defaults and clear and consistent behaviour.
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
34 ;; Message arrival timestamps, activity notification on the modeline,
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
35 ;; message filling, nick completion, and keepalive pings are all
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
36 ;; enabled by default, but can easily be adjusted or turned off. Each
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
37 ;; discussion takes place in its own buffer and there is a single
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
38 ;; server buffer per connection.
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; Open a new irc connection with:
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; M-x irc RET
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;;; Code:
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 (require 'ring)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 (require 'time-date)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 (eval-when-compile (require 'cl))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
49 (defgroup rcirc nil
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
50 "Simple IRC client."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
51 :version "22.1"
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
52 :prefix "rcirc"
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
53 :group 'applications)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
55 (defcustom rcirc-server "irc.freenode.net"
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
56 "The default server to connect to."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
57 :type 'string
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
58 :group 'rcirc)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
60 (defcustom rcirc-port 6667
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
61 "The default port to connect to."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
62 :type 'integer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
63 :group 'rcirc)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
65 (defcustom rcirc-nick (user-login-name)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
66 "Your nick."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
67 :type 'string
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
68 :group 'rcirc)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
70 (defcustom rcirc-user-name (user-login-name)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
71 "Your user name sent to the server when connecting."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
72 :type 'string
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
73 :group 'rcirc)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
74
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
75 (defcustom rcirc-user-full-name (if (string= (user-full-name) "")
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 rcirc-user-name
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (user-full-name))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
78 "The full name sent to the server when connecting."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
79 :type 'string
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
80 :group 'rcirc)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
82 (defcustom rcirc-startup-channels-alist nil
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 "Alist of channels to join at startup.
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
84 Each element looks like (SERVER-REGEXP . CHANNEL-LIST)."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
85 :type '(alist :key-type string :value-type (repeat string))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
86 :group 'rcirc)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
88 (defcustom rcirc-fill-flag t
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
89 "*Non-nil means line-wrap messages printed in channel buffers."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
90 :type 'boolean
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
91 :group 'rcirc)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
93 (defcustom rcirc-fill-column nil
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
94 "*Column beyond which automatic line-wrapping should happen.
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
95 If nil, use value of `fill-column'. If frame-width, use the
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
96 maximum frame width."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
97 :type '(choice (const :tag "Value of `fill-column'")
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
98 (const :tag "Full frame width" frame-width)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
99 (integer :tag "Number of columns"))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
100 :group 'rcirc)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
102 (defcustom rcirc-fill-prefix nil
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 "*Text to insert before filled lines.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 If nil, calculate the prefix dynamically to line up text
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
105 underneath each nick."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
106 :type '(choice (const :tag "Dynamic" nil)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
107 (string :tag "Prefix text"))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
108 :group 'rcirc)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
110 (defvar rcirc-ignore-buffer-activity-flag nil
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
111 "If non-nil, ignore activity in this buffer.")
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
112 (make-variable-buffer-local 'rcirc-ignore-buffer-activity-flag)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
114 (defcustom rcirc-ignore-all-activity-flag nil
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
115 "*Non-nil means do not indicate any activity in the modeline."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
116 :type 'boolean
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
117 :group 'rcirc)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
119 (defcustom rcirc-time-format "%H:%M "
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 "*Describes how timestamps are printed.
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
121 Used as the first arg to `format-time-string'."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
122 :type 'string
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
123 :group 'rcirc)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
125 (defcustom rcirc-input-ring-size 1024
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
126 "*Size of input history ring."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
127 :type 'integer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
128 :group 'rcirc)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
130 (defcustom rcirc-read-only-flag t
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
131 "*Non-nil means make text in irc buffers read-only."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
132 :type 'boolean
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
133 :group 'rcirc)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
135 (defcustom rcirc-buffer-maximum-lines nil
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 "*The maximum size in lines for rcirc buffers.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 Channel buffers are truncated from the top to be no greater than this
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
138 number. If zero or nil, no truncating is done."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
139 :type '(choice (const :tag "No truncation" nil)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
140 (integer :tag "Number of lines"))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
141 :group 'rcirc)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
143 (defcustom rcirc-authinfo-file-name
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 "~/.rcirc-authinfo"
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 "File containing rcirc authentication passwords.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 The file consists of a single list, with each element itself a
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 list with a SERVER-REGEXP string, a NICK-REGEXP string, a METHOD
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 and the remaining method specific ARGUMENTS. The valid METHOD
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 symbols are `nickserv', `chanserv' and `bitlbee'.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 The required ARGUMENTS for each METHOD symbol are:
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 `nickserv': PASSWORD
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 `chanserv': CHANNEL PASSWORD
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 `bitlbee': PASSWORD
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 Example:
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 ((\"freenode\" \"bob\" nickserv \"p455w0rd\")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 (\"freenode\" \"bob\" chanserv \"#bobland\" \"passwd99\")
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
159 (\"bitlbee\" \"robert\" bitlbee \"sekrit\"))"
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
160 :type 'string
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
161 :group 'rcirc)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
163 (defcustom rcirc-auto-authenticate-flag (file-readable-p rcirc-authinfo-file-name)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
164 "*Non-nil means automatically send authentication string to server.
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
165 See also `rcirc-authinfo-file-name'."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
166 :type 'boolean
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
167 :group 'rcirc)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
169 (defcustom rcirc-prompt "> "
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 "Prompt string to use in irc buffers.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 The following replacements are made:
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 %n is your nick.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 %s is the server.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 %t is the buffer target, a channel or a user.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
177 Setting this alone will not affect the prompt;
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
178 use either M-x customize or also call `rcirc-update-prompt'."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
179 :type 'string
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
180 :set 'rcirc-set-changed
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
181 :initialize 'custom-initialize-default
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
182 :group 'rcirc)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
183
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
184 (defcustom rcirc-print-hooks nil
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
185 "Hook run after text is printed.
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
186 Called with 5 arguments, PROCESS, SENDER, RESPONSE, TARGET and TEXT."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
187 :type 'hook
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
188 :group 'rcirc)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (defvar rcirc-prompt-start-marker nil)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 (defvar rcirc-prompt-end-marker nil)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 (defvar rcirc-nick-table nil)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
195 ;; each process has an alist of (target . buffer) pairs
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
196 (defvar rcirc-buffer-alist nil)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
197
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (defvar rcirc-activity nil
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 "List of channels with unviewed activity.")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 (defvar rcirc-activity-string ""
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 "String displayed in modeline representing `rcirc-activity'.")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 (put 'rcirc-activity-string 'risky-local-variable t)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 (defvar rcirc-process nil
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 "The server process associated with this buffer.")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 (defvar rcirc-target nil
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 "The channel or user associated with this buffer.")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 (defvar rcirc-urls nil
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 "List of urls seen in the current buffer.")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 (defvar rcirc-keepalive-seconds 60
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 "Number of seconds between keepalive pings.")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
217 (defconst rcirc-id-string (concat "rcirc on GNU Emacs " emacs-version))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (defvar rcirc-startup-channels nil)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 ;;;###autoload
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (defun rcirc (&optional server port nick channels)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 "Connect to IRC.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 If any of the the optional SERVER, PORT, NICK or CHANNELS are not
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 supplied, they are taken from the variables `rcirc-server',
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
226 `rcirc-port', `rcirc-nick', and `rcirc-startup-channels-alist',
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 respectively."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (interactive (list (read-string "IRC Server: " rcirc-server)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (read-string "IRC Port: " (number-to-string rcirc-port))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (read-string "IRC Nick: " rcirc-nick)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 (or server (setq server rcirc-server))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 (or port (setq port rcirc-port))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (or nick (setq nick rcirc-nick))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (or channels
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 (setq channels
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (if (interactive-p)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
237 (split-string
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
238 (read-string "Channels: "
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
239 (mapconcat 'identity
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
240 (rcirc-startup-channels server)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
241 " "))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
242 "[, ]+" t)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (rcirc-startup-channels server))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (or global-mode-string (setq global-mode-string '("")))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 (and (not (memq 'rcirc-activity-string global-mode-string))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 (setq global-mode-string
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 (append global-mode-string '(rcirc-activity-string))))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
248 (add-hook 'window-configuration-change-hook
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
249 'rcirc-window-configuration-change)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 (rcirc-connect server port nick rcirc-user-name rcirc-user-full-name
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 channels))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 ;;;###autoload
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 (defalias 'irc 'rcirc)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 (defvar rcirc-process-output nil)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 (defvar rcirc-topic nil)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 (defvar rcirc-keepalive-timer nil)
67014
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
260 (defvar rcirc-last-server-message-time nil)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (defun rcirc-connect (server port nick user-name full-name startup-channels)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 "Return a connection to SERVER on PORT.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 User will identify using the values of NICK, USER-NAME and
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 FULL-NAME. The variable list of channel names in
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 STARTUP-CHANNELS will automatically be joined on startup."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 (save-excursion
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 (message "Connecting to %s..." server)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (let* ((inhibit-eol-conversion)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 (port-number (if (stringp port)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 (string-to-number port)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 port))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (process (open-network-stream server nil server port-number)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 ;; set up process
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (set-process-coding-system process 'raw-text 'raw-text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 (set-process-filter process 'rcirc-filter)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
277 (switch-to-buffer (rcirc-generate-new-buffer-name process nil))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (set-process-buffer process (current-buffer))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 (set-process-sentinel process 'rcirc-sentinel)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 (rcirc-mode process nil)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
281 (make-local-variable 'rcirc-buffer-alist)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
282 (setq rcirc-buffer-alist nil)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (make-local-variable 'rcirc-nick-table)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 (setq rcirc-nick-table (make-hash-table :test 'equal))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 (make-local-variable 'rcirc-server)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 (setq rcirc-server server)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 (make-local-variable 'rcirc-nick)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 (setq rcirc-nick nick)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 (make-local-variable 'rcirc-process-output)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 (setq rcirc-process-output nil)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 (make-local-variable 'rcirc-startup-channels)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (setq rcirc-startup-channels startup-channels)
67014
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
293 (make-local-variable 'rcirc-last-server-message-time)
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
294 (setq rcirc-last-server-message-time (current-time))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 ;; identify
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (rcirc-send-string process (concat "NICK " nick))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (rcirc-send-string process (concat "USER " user-name
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 " hostname servername :"
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 full-name))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 ;; setup ping timer if necessary
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 (unless rcirc-keepalive-timer
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 (setq rcirc-keepalive-timer
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (run-at-time 0 rcirc-keepalive-seconds 'rcirc-keepalive)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 (message "Connecting to %s...done" server)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 ;; return process object
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 process)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
312 (defmacro with-rcirc-process-buffer (process &rest body)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
313 (declare (indent 1) (debug t))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
314 `(with-current-buffer (process-buffer ,process)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
315 ,@body))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
316
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (defun rcirc-keepalive ()
67014
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
318 "Send keep alive pings to active rcirc processes.
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
319 Kill processes that have not received a server message since the
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
320 last ping."
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (if (rcirc-process-list)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 (mapc (lambda (process)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
323 (with-rcirc-process-buffer process
67014
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
324 (if (> (cadr (time-since rcirc-last-server-message-time))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
325 rcirc-keepalive-seconds)
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
326 (kill-process process)
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
327 (rcirc-send-string process (concat "PING " rcirc-server)))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 (rcirc-process-list))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (cancel-timer rcirc-keepalive-timer)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (setq rcirc-keepalive-timer nil)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
332 (defvar rcirc-debug-buffer " *rcirc debug*")
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
333 (defvar rcirc-debug-flag nil
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
334 "If non-nil, write information to `rcirc-debug-buffer'.")
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
335 (defun rcirc-debug (process text)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 "Add an entry to the debug log including PROCESS and TEXT.
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
337 Debug text is written to `rcirc-debug-buffer' if `rcirc-debug-p'
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
338 is non-nil."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
339 (when rcirc-debug-flag
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (save-excursion
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (save-window-excursion
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
342 (set-buffer (get-buffer-create rcirc-debug-buffer))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 (goto-char (point-max))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 (insert (concat
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 "["
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 (format-time-string "%Y-%m-%dT%T ") (process-name process)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 "] "
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 text))))))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
349
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 (defvar rcirc-sentinel-hooks nil
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 "Hook functions called when the process sentinel is called.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 Functions are called with PROCESS and SENTINEL arguments.")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 (defun rcirc-sentinel (process sentinel)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 "Called when PROCESS receives SENTINEL."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 (let ((sentinel (replace-regexp-in-string "\n" "" sentinel)))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
357 (rcirc-debug process (format "SENTINEL: %S %S\n" process sentinel))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
358 (with-rcirc-process-buffer process
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
359 (dolist (buffer (cons nil (mapcar 'cdr rcirc-buffer-alist)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
360 (rcirc-print process "rcirc.el" "ERROR" buffer
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 (format "%s: %s (%S)"
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 (process-name process)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 sentinel
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 (process-status process)) t)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 ;; remove the prompt from buffers
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
366 (with-current-buffer (or buffer (current-buffer))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 (let ((inhibit-read-only t))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 (delete-region rcirc-prompt-start-marker
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 rcirc-prompt-end-marker)))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 (run-hook-with-args 'rcirc-sentinel-hooks process sentinel)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 (defun rcirc-process-list ()
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 "Return a list of rcirc processes."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (let (ps)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (mapc (lambda (p)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (when (process-buffer p)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
377 (with-rcirc-process-buffer p
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 (when (eq major-mode 'rcirc-mode)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 (setq ps (cons p ps))))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 (process-list))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 ps))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 (defvar rcirc-receive-message-hooks nil
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 "Hook functions run when a message is recieved from server.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 Function is called with PROCESS COMMAND SENDER ARGS and LINE.")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 (defun rcirc-filter (process output)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 "Called when PROCESS receives OUTPUT."
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
388 (rcirc-debug process output)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
389 (with-rcirc-process-buffer process
67014
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
390 (setq rcirc-last-server-message-time (current-time))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 (setq rcirc-process-output (concat rcirc-process-output output))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 (when (= (aref rcirc-process-output
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 (1- (length rcirc-process-output))) ?\n)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (mapc (lambda (line)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 (rcirc-process-server-response process line))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
396 (split-string rcirc-process-output "[\n\r]" t))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 (setq rcirc-process-output nil))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
399 (defvar rcirc-trap-errors-flag t)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 (defun rcirc-process-server-response (process text)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
401 (if rcirc-trap-errors-flag
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 (condition-case err
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (rcirc-process-server-response-1 process text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 (error
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 (rcirc-print process "RCIRC" "ERROR" nil
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
406 (format "\"%s\" %s" text err) t)))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 (rcirc-process-server-response-1 process text)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 (defun rcirc-process-server-response-1 (process text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 (if (string-match "^\\(:\\([^ ]+\\) \\)?\\([^ ]+\\) \\(.+\\)$" text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 (let* ((sender (match-string 2 text))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 (cmd (match-string 3 text))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 (args (match-string 4 text))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 (handler (intern-soft (concat "rcirc-handler-" cmd))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (string-match "^\\([^:]*\\):?\\(.+\\)?$" args)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (let* ((args1 (match-string 1 args))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 (args2 (match-string 2 args))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
418 (args (delq nil (append (split-string args1 " " t)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
419 (list args2)))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (if (not (fboundp handler))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (rcirc-handler-generic process cmd sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (funcall handler process sender args text))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (run-hook-with-args 'rcirc-receive-message-hooks
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 process cmd sender args text)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (message "UNHANDLED: %s" text)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (defun rcirc-handler-generic (process command sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 "Generic server response handler."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 (rcirc-print process sender command nil
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
430 (mapconcat 'identity (cdr args) " ") t))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (defun rcirc-send-string (process string)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 "Send PROCESS a STRING plus a newline."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (let ((string (concat (encode-coding-string string
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 buffer-file-coding-system)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 "\n")))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
437 (rcirc-debug process string)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 (process-send-string process string)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 (defun rcirc-server (process)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 "Return PROCESS server, given by the 001 response."
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
442 (with-rcirc-process-buffer process
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 rcirc-server))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 (defun rcirc-nick (process)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 "Return PROCESS nick."
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
447 (with-rcirc-process-buffer process
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 rcirc-nick))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 (defvar rcirc-max-message-length 450
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 "Messages longer than this value will be split.")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 (defun rcirc-send-message (process target message &optional noticep)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 "Send TARGET associated with PROCESS a privmsg with text MESSAGE.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 If NOTICEP is non-nil, send a notice instead of privmsg."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 ;; max message length is 512 including CRLF
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 (let* ((response (if noticep "NOTICE" "PRIVMSG"))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 (oversize (> (length message) rcirc-max-message-length))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 (text (if oversize
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 (substring message 0 rcirc-max-message-length)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 message))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 (text (if (string= text "")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 " "
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 text))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 (more (if oversize
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 (substring message rcirc-max-message-length))))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
467 (rcirc-print process (rcirc-nick process) response
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
468 (rcirc-get-buffer-create process target)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
469 text)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 (rcirc-send-string process (concat response " " target " :" text))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 (if more
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 (rcirc-send-message process target more noticep))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 (defvar rcirc-input-ring nil)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 (defvar rcirc-input-ring-index 0)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 (defun rcirc-prev-input-string (arg)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 (ring-ref rcirc-input-ring (+ rcirc-input-ring-index arg)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 (defun rcirc-insert-prev-input (arg)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 (interactive "p")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 (when (<= rcirc-prompt-end-marker (point))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 (delete-region rcirc-prompt-end-marker (point-max))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 (insert (rcirc-prev-input-string 0))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 (setq rcirc-input-ring-index (1+ rcirc-input-ring-index))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 (defun rcirc-insert-next-input (arg)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 (interactive "p")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 (when (<= rcirc-prompt-end-marker (point))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 (delete-region rcirc-prompt-end-marker (point-max))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 (setq rcirc-input-ring-index (1- rcirc-input-ring-index))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (insert (rcirc-prev-input-string -1))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (defvar rcirc-nick-completions nil)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (defvar rcirc-nick-completion-start-offset nil)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 (defun rcirc-complete-nick ()
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 "Cycle through nick completions from list of nicks in channel."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 (interactive)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 (if (eq last-command 'rcirc-complete-nick)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 (setq rcirc-nick-completions
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 (append (cdr rcirc-nick-completions)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 (list (car rcirc-nick-completions))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 (setq rcirc-nick-completion-start-offset
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 (- (save-excursion
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 (if (re-search-backward " " rcirc-prompt-end-marker t)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 (1+ (point))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 rcirc-prompt-end-marker))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 rcirc-prompt-end-marker))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 (setq rcirc-nick-completions
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 (let ((completion-ignore-case t))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
510 (all-completions
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
511 (buffer-substring
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 (+ rcirc-prompt-end-marker
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 rcirc-nick-completion-start-offset)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 (point))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 (mapcar (lambda (x) (cons x nil))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 (rcirc-channel-nicks rcirc-process
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 (rcirc-buffer-target)))))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 (let ((completion (car rcirc-nick-completions)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 (when completion
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
520 (delete-region (+ rcirc-prompt-end-marker
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 rcirc-nick-completion-start-offset)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 (point))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 (insert (concat completion
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
524 (if (= (+ rcirc-prompt-end-marker
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 rcirc-nick-completion-start-offset)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 rcirc-prompt-end-marker)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 ": "))))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 (defun rcirc-buffer-target (&optional buffer)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 "Return the name of target for BUFFER.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 If buffer is nil, return the target of the current buffer."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 (with-current-buffer (or buffer (current-buffer))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 rcirc-target))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 (defvar rcirc-mode-map (make-sparse-keymap)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 "Keymap for rcirc mode.")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 (define-key rcirc-mode-map (kbd "RET") 'rcirc-send-input)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 (define-key rcirc-mode-map (kbd "M-p") 'rcirc-insert-prev-input)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 (define-key rcirc-mode-map (kbd "M-n") 'rcirc-insert-next-input)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 (define-key rcirc-mode-map (kbd "TAB") 'rcirc-complete-nick)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 (define-key rcirc-mode-map (kbd "C-c C-b") 'rcirc-browse-url)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 (define-key rcirc-mode-map (kbd "C-c C-c") 'rcirc-edit-multiline)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 (define-key rcirc-mode-map (kbd "C-c C-j") 'rcirc-cmd-join)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 (define-key rcirc-mode-map (kbd "C-c C-k") 'rcirc-cmd-kick)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 (define-key rcirc-mode-map (kbd "C-c C-l") 'rcirc-cmd-list)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 (define-key rcirc-mode-map (kbd "C-c C-d") 'rcirc-cmd-mode)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 (define-key rcirc-mode-map (kbd "C-c C-m") 'rcirc-cmd-msg)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 (define-key rcirc-mode-map (kbd "C-c C-r") 'rcirc-cmd-nick) ; rename
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 (define-key rcirc-mode-map (kbd "C-c C-o") 'rcirc-cmd-oper)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 (define-key rcirc-mode-map (kbd "C-c C-p") 'rcirc-cmd-part)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 (define-key rcirc-mode-map (kbd "C-c C-q") 'rcirc-cmd-query)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 (define-key rcirc-mode-map (kbd "C-c C-t") 'rcirc-cmd-topic)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 (define-key rcirc-mode-map (kbd "C-c C-n") 'rcirc-cmd-names)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 (define-key rcirc-mode-map (kbd "C-c C-w") 'rcirc-cmd-whois)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 (define-key rcirc-mode-map (kbd "C-c C-x") 'rcirc-cmd-quit)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 (define-key rcirc-mode-map (kbd "C-c TAB") ; C-i
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
558 'rcirc-toggle-ignore-buffer-activity)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 (define-key rcirc-mode-map (kbd "C-c C-s") 'rcirc-switch-to-server-buffer)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 (define-key rcirc-mode-map (kbd "C-c C-a") 'rcirc-jump-to-first-unread-line)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 (define-key global-map (kbd "C-c `") 'rcirc-next-active-buffer)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 (define-key global-map (kbd "C-c C-@") 'rcirc-next-active-buffer)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 (define-key global-map (kbd "C-c C-SPC") 'rcirc-next-active-buffer)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
566 (defvar rcirc-browse-url-map (make-sparse-keymap)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
567 "Keymap used ror browsing URLs in `rcirc-mode'.")
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
568
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
569 (define-key rcirc-browse-url-map (kbd "RET") 'rcirc-browse-url-at-point)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
570 (define-key rcirc-browse-url-map (kbd "<mouse-2>") 'rcirc-browse-url-at-mouse)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
571
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
572 (defvar rcirc-short-buffer-name nil
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
573 "Generated abbreviation to use to indicate buffer activity.")
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
574
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 (defvar rcirc-mode-hook nil
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 "Hook run when setting up rcirc buffer.")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 (defun rcirc-mode (process target)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 "Major mode for irc channel buffers.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 \\{rcirc-mode-map}"
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 (kill-all-local-variables)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 (use-local-map rcirc-mode-map)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 (setq mode-name "rcirc")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 (setq major-mode 'rcirc-mode)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 (make-local-variable 'rcirc-input-ring)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 (setq rcirc-input-ring (make-ring rcirc-input-ring-size))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 (make-local-variable 'rcirc-process)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 (setq rcirc-process process)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 (make-local-variable 'rcirc-target)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 (setq rcirc-target target)
67014
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
593 (make-local-variable 'rcirc-topic)
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
594 (setq rcirc-topic nil)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
595
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
596 (make-local-variable 'rcirc-short-buffer-name)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
597 (setq rcirc-short-buffer-name nil)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 (make-local-variable 'rcirc-urls)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 (setq rcirc-urls nil)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 (setq use-hard-newlines t)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 ;; setup the prompt and markers
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 (make-local-variable 'rcirc-prompt-start-marker)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 (setq rcirc-prompt-start-marker (make-marker))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 (set-marker rcirc-prompt-start-marker (point-max))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 (make-local-variable 'rcirc-prompt-end-marker)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 (setq rcirc-prompt-end-marker (make-marker))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 (set-marker rcirc-prompt-end-marker (point-max))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 (rcirc-update-prompt)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 (goto-char rcirc-prompt-end-marker)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 (make-local-variable 'overlay-arrow-position)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 (setq overlay-arrow-position (make-marker))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 (set-marker overlay-arrow-position nil)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
615 ;; add to buffer list, and update buffer abbrevs
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
616 (when target ; skip server buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
617 (let ((buffer (current-buffer)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
618 (with-rcirc-process-buffer process
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
619 (setq rcirc-buffer-alist (cons (cons target buffer)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
620 rcirc-buffer-alist))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
621 (rcirc-update-short-buffer-names))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
622
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 (run-hooks 'rcirc-mode-hook))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
625 (defun rcirc-update-prompt (&optional all)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
626 "Reset the prompt string in the current buffer.
66252
684cec8133e3 (with-rcirc-process-buffer): Move above its first user.
Romain Francoise <romain@orebokech.com>
parents: 66250
diff changeset
627
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
628 If ALL is non-nil, update prompts in all IRC buffers."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
629 (if all
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
630 (mapc (lambda (process)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
631 (mapc (lambda (buffer)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
632 (with-current-buffer buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
633 (rcirc-update-prompt)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
634 (with-rcirc-process-buffer process
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
635 (mapcar 'cdr rcirc-buffer-alist))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
636 (rcirc-process-list))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
637 (let ((inhibit-read-only t)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
638 (prompt (or rcirc-prompt "")))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
639 (mapc (lambda (rep)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
640 (setq prompt
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
641 (replace-regexp-in-string (car rep) (regexp-quote (cdr rep)) prompt)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
642 (list (cons "%n" (with-rcirc-process-buffer rcirc-process
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
643 rcirc-nick))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
644 (cons "%s" (with-rcirc-process-buffer rcirc-process
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
645 rcirc-server))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
646 (cons "%t" (or rcirc-target ""))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
647 (save-excursion
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
648 (delete-region rcirc-prompt-start-marker rcirc-prompt-end-marker)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
649 (goto-char rcirc-prompt-start-marker)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
650 (let ((start (point)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
651 (insert-before-markers prompt)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
652 (set-marker rcirc-prompt-start-marker start)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
653 (when (not (zerop (- rcirc-prompt-end-marker
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
654 rcirc-prompt-start-marker)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
655 (add-text-properties rcirc-prompt-start-marker
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
656 rcirc-prompt-end-marker
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
657 (list 'face 'rcirc-prompt
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
658 'read-only t 'field t
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
659 'front-sticky t 'rear-nonsticky t))))))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
660
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
661 (defun rcirc-set-changed (option value)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
662 "Set OPTION to VALUE and do updates after a customization change."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
663 (set-default option value)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
664 (cond ((eq option 'rcirc-prompt)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
665 (rcirc-update-prompt 'all))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
666 (t
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
667 (error "Bad option %s" option))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 (defun rcirc-channel-p (target)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 "Return t if TARGET is a channel name."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 (and target
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 (not (zerop (length target)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 (or (eq (aref target 0) ?#)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 (eq (aref target 0) ?&))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 (defun rcirc-kill-buffer-hook ()
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 "Part the channel when killing an rcirc buffer."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 (when (eq major-mode 'rcirc-mode)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
679 (rcirc-kill-buffer-hook-1)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
680 (defun rcirc-kill-buffer-hook-1 ()
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
681 (let ((buffer (current-buffer)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
682 (rcirc-clear-activity buffer)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 (when (and rcirc-process
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
684 (eq (process-status rcirc-process) 'open))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
685 (with-rcirc-process-buffer rcirc-process
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
686 (setq rcirc-buffer-alist
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
687 (rassq-delete-all buffer rcirc-buffer-alist)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
688 (rcirc-update-short-buffer-names)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 (if (rcirc-channel-p rcirc-target)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
690 (rcirc-send-string rcirc-process
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
691 (concat "PART " rcirc-target
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
692 " :Killed buffer"))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
693 (when rcirc-target
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
694 (rcirc-remove-nick-channel rcirc-process
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
695 (rcirc-nick rcirc-process)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
696 rcirc-target))))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
697
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 (add-hook 'kill-buffer-hook 'rcirc-kill-buffer-hook)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
700 (defun rcirc-generate-new-buffer-name (process target)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
701 "Return a buffer name based on PROCESS and TARGET.
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
702 This is used for the initial name given to irc buffers."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
703 (if target
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
704 (concat target "@" (process-name process))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
705 (concat "*" (process-name process) "*")))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
707 (defun rcirc-get-buffer (process target &optional server)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 "Return the buffer associated with the PROCESS and TARGET.
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
709
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
710 If TARGET is nil, return the server buffer.
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
711
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
712 If optional argument SERVER is non-nil, return the server buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
713 if there is no existing buffer for TARGET, otherwise return nil."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
714 (with-rcirc-process-buffer process
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
715 (if (null target)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
716 (current-buffer)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
717 (let ((buffer (cdr (assoc-string target rcirc-buffer-alist t))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
718 (or buffer (when server (current-buffer)))))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 (defun rcirc-get-buffer-create (process target)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
721 "Return the buffer associated with the PROCESS and TARGET.
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
722 Create the buffer if it doesn't exist."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
723 (let ((buffer (rcirc-get-buffer process target)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
724 (or buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
725 ;; create the buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
726 (with-rcirc-process-buffer process
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
727 (let ((new-buffer (get-buffer-create
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
728 (rcirc-generate-new-buffer-name process target))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
729 (with-current-buffer new-buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
730 (rcirc-mode process target))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
731 (rcirc-put-nick-channel process (rcirc-nick process) target)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
732 new-buffer)))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 (defun rcirc-send-input ()
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 "Send input to target associated with the current buffer."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 (interactive)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 (if (not (eq (process-status rcirc-process) 'open))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
738 (error "Network connection to %s is not open"
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 (process-name rcirc-process))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740 (if (< (point) rcirc-prompt-end-marker)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 ;; copy the line down to the input area
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 (progn
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 (forward-line 0)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 (let ((start (if (eq (point) (point-min))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 (point)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 (if (get-text-property (1- (point)) 'hard)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 (point)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 (previous-single-property-change (point) 'hard))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749 (end (next-single-property-change (1+ (point)) 'hard)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 (goto-char (point-max))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 (insert (replace-regexp-in-string
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 "\n\\s-+" " "
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753 (buffer-substring-no-properties start end)))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 ;; process input
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 (goto-char (point-max))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 (let ((target (rcirc-buffer-target))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 (start rcirc-prompt-end-marker))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 (when (not (equal 0 (- (point) start)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 ;; delete a trailing newline
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 (when (eq (point) (point-at-bol))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 (delete-backward-char 1))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 (let ((input (buffer-substring-no-properties
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 rcirc-prompt-end-marker (point))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 ;; process a /cmd
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 (if (string-match "^/\\([^ ]+\\) ?\\(.*\\)$" input)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766 (let* ((command (match-string 1 input))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 (fun (intern-soft (concat "rcirc-cmd-" command)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 (args (match-string 2 input)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 (newline)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 (with-current-buffer (current-buffer)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 (delete-region rcirc-prompt-end-marker (point))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 (if (string= command "me")
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
773 (rcirc-print rcirc-process (rcirc-nick rcirc-process)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
774 "ACTION" (current-buffer) args)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
775 (rcirc-print rcirc-process (rcirc-nick rcirc-process)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
776 "COMMAND" (current-buffer) input))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 (set-marker rcirc-prompt-end-marker (point))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778 (if (fboundp fun)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779 (funcall fun args rcirc-process target)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
780 (rcirc-send-string rcirc-process
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
781 (concat command " " args)))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782 ;; send message to server
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783 (if (not rcirc-target)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
784 (message "Not joined")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785 (delete-region rcirc-prompt-end-marker (point))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786 (mapc (lambda (message)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
787 (rcirc-send-message rcirc-process target message))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788 (split-string input "\n"))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 ;; add to input-ring
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
790 (save-excursion
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
791 (ring-insert rcirc-input-ring input)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
792 (setq rcirc-input-ring-index 0))))))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
793
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794 (defvar rcirc-parent-buffer nil)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
795 (defvar rcirc-window-configuration nil)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
796 (defun rcirc-edit-multiline ()
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
797 "Move current edit to a dedicated buffer."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798 (interactive)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 (let ((pos (1+ (- (point) rcirc-prompt-end-marker))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 (goto-char (point-max))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
801 (let ((text (buffer-substring rcirc-prompt-end-marker (point)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
802 (parent (buffer-name))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
803 (process rcirc-process))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
804 (delete-region rcirc-prompt-end-marker (point))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805 (setq rcirc-window-configuration (current-window-configuration))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 (pop-to-buffer (concat "*multiline " parent "*"))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 (rcirc-multiline-edit-mode)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808 (setq rcirc-parent-buffer parent)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
809 (setq rcirc-process process)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810 (insert text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811 (and (> pos 0) (goto-char pos)))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
812
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813 (define-derived-mode rcirc-multiline-edit-mode
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 text-mode "rcirc multi"
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 "Major mode for multiline edits
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 \\{rcirc-multiline-edit-mode-map}"
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817 (make-local-variable 'rcirc-parent-buffer)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 (make-local-variable 'rcirc-process))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820 (define-key rcirc-multiline-edit-mode-map
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821 (kbd "C-c C-c") 'rcirc-multiline-edit-submit)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 (define-key rcirc-multiline-edit-mode-map
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 (kbd "C-x C-s") 'rcirc-multiline-edit-submit)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 (define-key rcirc-multiline-edit-mode-map
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 (kbd "C-c C-k") 'rcirc-multiline-edit-cancel)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826 (define-key rcirc-multiline-edit-mode-map
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827 (kbd "ESC ESC ESC") 'rcirc-multiline-edit-cancel)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 (defun rcirc-multiline-edit-submit ()
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 "Send the text in buffer back to parent buffer."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 (interactive)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 (assert (and (eq major-mode 'rcirc-multiline-edit-mode)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 (assert rcirc-parent-buffer)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
834 (untabify (point-min) (point-max))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835 (let ((text (buffer-substring (point-min) (point-max)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 (buffer (current-buffer))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837 (pos (point)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838 (set-buffer rcirc-parent-buffer)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 (goto-char (point-max))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 (insert text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 (kill-buffer buffer)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
842 (set-window-configuration rcirc-window-configuration)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
843 (goto-char (+ rcirc-prompt-end-marker (1- pos)))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845 (defun rcirc-multiline-edit-cancel ()
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846 "Cancel the multiline edit."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847 (interactive)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 (assert (and (eq major-mode 'rcirc-multiline-edit-mode)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849 (kill-buffer (current-buffer))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 (set-window-configuration rcirc-window-configuration))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
852 (defun rcirc-get-any-buffer (process)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
853 "Return a buffer for PROCESS, either the one selected or the process buffer."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
854 (let ((buffer (window-buffer (selected-window))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
855 (if (and buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
856 (with-current-buffer buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
857 (and (eq major-mode 'rcirc-mode)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
858 (eq rcirc-process process))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
859 buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
860 (process-buffer process))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 (defun rcirc-format-response-string (process sender response target text)
67014
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
863 (concat (rcirc-facify (format-time-string rcirc-time-format (current-time))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
864 'rcirc-timestamp)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865 (cond ((or (string= response "PRIVMSG")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866 (string= response "NOTICE")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 (string= response "ACTION"))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 (let (first middle end)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869 (cond ((string= response "PRIVMSG")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870 (setq first "<" middle "> "))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
871 ((string= response "NOTICE")
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
872 (when sender
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
873 (setq first "-" middle "- ")))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
874 (t
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875 (setq first "[" middle " " end "]")))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
876 (concat first
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 (rcirc-facify (rcirc-user-nick sender)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878 (if (string= sender
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879 (rcirc-nick process))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
880 'rcirc-my-nick
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
881 'rcirc-other-nick))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 middle
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 (rcirc-mangle-text process text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884 end)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 ((string= response "COMMAND")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886 text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887 ((string= response "ERROR")
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
888 (propertize (concat "!!! " text)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
889 'face 'font-lock-warning-face))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 (t
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
891 (rcirc-mangle-text
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
892 process
67014
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
893 (concat (rcirc-facify "*** " 'rcirc-server-prefix)
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
894 (rcirc-facify
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
895 (concat
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
896 (when (not (string= sender (rcirc-server process)))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
897 (concat (rcirc-user-nick sender) " "))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
898 (when (zerop (string-to-number response))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
899 (concat response " "))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
900 text)
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
901 'rcirc-server)))))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
902
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
903 (defvar rcirc-activity-type nil)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
904 (make-variable-buffer-local 'rcirc-activity-type)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
905 (defun rcirc-print (process sender response target text &optional activity)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
906 "Print TEXT in the buffer associated with TARGET.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
907 Format based on SENDER and RESPONSE. If ACTIVITY is non-nil,
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
908 record activity."
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
909 (let* ((buffer (cond ((bufferp target)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910 target)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
911 ((not target)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
912 (rcirc-get-any-buffer process))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
913 ((not (rcirc-channel-p target))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
914 (rcirc-get-buffer-create process
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
915 (rcirc-user-nick sender)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
916 ((or (rcirc-get-buffer process target)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
917 (rcirc-get-any-buffer process)))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
918 (inhibit-read-only t))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
919 (with-current-buffer buffer
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
920 (let ((moving (= (point) rcirc-prompt-end-marker))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
921 (old-point (point-marker))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
922 (fill-start (marker-position rcirc-prompt-start-marker)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
923
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
924 (unless (string= sender (rcirc-nick process))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
925 ;; only decode text from other senders, not ours
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
926 (setq text (decode-coding-string (or text "")
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
927 buffer-file-coding-system))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928 ;; mark the line with overlay arrow
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
929 (unless (or (marker-position overlay-arrow-position)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930 (get-buffer-window (current-buffer)))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
931 (set-marker overlay-arrow-position
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
932 (marker-position rcirc-prompt-start-marker))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
933
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
934 ;; temporarily set the marker insertion-type because
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
935 ;; insert-before-markers results in hidden text in new buffers
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
936 (goto-char rcirc-prompt-start-marker)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937 (set-marker-insertion-type rcirc-prompt-start-marker t)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
938 (set-marker-insertion-type rcirc-prompt-end-marker t)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
939 (insert
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
940 (rcirc-format-response-string process sender response target text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
941 (propertize "\n" 'hard t))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
942 (set-marker-insertion-type rcirc-prompt-start-marker nil)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
943 (set-marker-insertion-type rcirc-prompt-end-marker nil)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
944
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
945 ;; fill the text we just inserted, maybe
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946 (when (and rcirc-fill-flag
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
947 (not (string= response "372"))) ;/motd
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
948 (let ((fill-prefix
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
949 (or rcirc-fill-prefix
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
950 (make-string
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
951 (+ (if rcirc-time-format
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
952 (length (format-time-string
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953 rcirc-time-format))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
954 0)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955 (cond ((or (string= response "PRIVMSG")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956 (string= response "NOTICE"))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
957 (+ (length (rcirc-user-nick sender))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958 2)) ; <>
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
959 ((string= response "ACTION")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
960 (+ (length (rcirc-user-nick sender))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
961 1)) ; [
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
962 (t 3)) ; ***
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
963 1)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
964 ? )))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
965 (fill-column (cond ((eq rcirc-fill-column 'frame-width)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
966 (1- (frame-width)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
967 (rcirc-fill-column
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
968 rcirc-fill-column)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
969 (t fill-column))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
970 (fill-region fill-start rcirc-prompt-start-marker 'left t)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
971
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
972 ;; set inserted text to be read-only
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
973 (when rcirc-read-only-flag
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
974 (put-text-property rcirc-prompt-start-marker fill-start 'read-only t)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
975 (let ((inhibit-read-only t))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
976 (put-text-property rcirc-prompt-start-marker fill-start
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
977 'front-sticky t)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
978 (put-text-property (1- (point)) (point) 'rear-nonsticky t)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
979
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
980 ;; truncate buffer if it is very long
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
981 (save-excursion
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
982 (when (and rcirc-buffer-maximum-lines
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
983 (> rcirc-buffer-maximum-lines 0)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
984 (= (forward-line (- rcirc-buffer-maximum-lines)) 0))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
985 (delete-region (point-min) (point))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
986
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
987 ;; set the window point for buffers show in windows
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
988 (walk-windows (lambda (w)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
989 (unless (eq (selected-window) w)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
990 (when (and (eq (current-buffer)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
991 (window-buffer w))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
992 (>= (window-point w)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
993 rcirc-prompt-end-marker))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
994 (set-window-point w (point-max)))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
995 nil t)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
996
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
997 ;; restore the point
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
998 (goto-char (if moving rcirc-prompt-end-marker old-point))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
999
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1000 ;; flush undo (can we do something smarter here?)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1001 (buffer-disable-undo)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1002 (buffer-enable-undo))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1003
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1004 ;; record modeline activity
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1005 (when activity
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1006 (let ((nick-match
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1007 (string-match (concat "\\b"
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1008 (regexp-quote (rcirc-nick process))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1009 "\\b")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1010 text)))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1011 (when (or (not rcirc-ignore-buffer-activity-flag)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1012 ;; always notice when our nick is mentioned, even
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1013 ;; if ignoring channel activity
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1014 nick-match)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1015 (rcirc-record-activity
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1016 (current-buffer)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1017 (when (or nick-match (not (rcirc-channel-p rcirc-target)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1018 'nick)))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1019
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1020 (sit-for 0) ; displayed text before hook
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1021 (run-hook-with-args 'rcirc-print-hooks
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1022 process sender response target text))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1023
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1024 (defun rcirc-startup-channels (server)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1025 "Return the list of startup channels for server."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1026 (let (channels)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1027 (dolist (i rcirc-startup-channels-alist)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1028 (if (string-match (car i) server)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1029 (setq channels (append channels (cdr i)))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1030 channels))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1031
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1032 (defun rcirc-join-channels (process channels)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1033 "Join CHANNELS."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1034 (save-window-excursion
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1035 (mapc (lambda (channel)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1036 (with-rcirc-process-buffer process
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1037 (rcirc-cmd-join channel process)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1038 channels)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1039
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1040 ;;; nick management
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1041 (defun rcirc-user-nick (user)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1042 "Return the nick from USER. Remove any non-nick junk."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1043 (if (string-match "^[@%+]?\\([^! ]+\\)!?" (or user ""))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1044 (match-string 1 user)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1045 user))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1046
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1047 (defun rcirc-user-non-nick (user)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1048 "Return the non-nick portion of USER."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1049 (if (string-match "^[@+]?[^! ]+!?\\(.*\\)" (or user ""))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1050 (match-string 1 user)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1051 user))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1052
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1053 (defun rcirc-nick-channels (process nick)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1054 "Return list of channels for NICK."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1055 (let ((nick (rcirc-user-nick nick)))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1056 (with-rcirc-process-buffer process
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1057 (mapcar (lambda (x) (car x))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1058 (gethash nick rcirc-nick-table)))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1059
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1060 (defun rcirc-put-nick-channel (process nick channel)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1061 "Add CHANNEL to list associated with NICK."
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1062 (with-rcirc-process-buffer process
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1063 (let* ((nick (rcirc-user-nick nick))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1064 (chans (gethash nick rcirc-nick-table))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1065 (record (assoc-string channel chans t)))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1066 (if record
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1067 (setcdr record (current-time))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1068 (puthash nick (cons (cons channel (current-time))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1069 chans)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1070 rcirc-nick-table)))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1071
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1072 (defun rcirc-nick-remove (process nick)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1073 "Remove NICK from table."
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1074 (with-rcirc-process-buffer process
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1075 (remhash nick rcirc-nick-table)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1076
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1077 (defun rcirc-remove-nick-channel (process nick channel)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1078 "Remove the CHANNEL from list associated with NICK."
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1079 (with-rcirc-process-buffer process
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1080 (let* ((nick (rcirc-user-nick nick))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1081 (chans (gethash nick rcirc-nick-table))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1082 (newchans
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1083 ;; instead of assoc-string-delete-all:
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1084 (let ((record (assoc-string channel chans t)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1085 (when record
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1086 (setcar record 'delete)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1087 (assq-delete-all 'delete chans)))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1088 (if newchans
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1089 (puthash nick newchans rcirc-nick-table)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1090 (remhash nick rcirc-nick-table)))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1091
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1092 (defun rcirc-channel-nicks (process channel)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1093 "Return the list of nicks in CHANNEL sorted by last activity."
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1094 (with-rcirc-process-buffer process
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1095 (let (nicks)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1096 (maphash
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1097 (lambda (k v)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1098 (let ((record (assoc-string channel v t)))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1099 (if record
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1100 (setq nicks (cons (cons k (cdr record)) nicks)))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1101 rcirc-nick-table)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1102 (mapcar (lambda (x) (car x))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1103 (sort nicks (lambda (x y) (time-less-p (cdr y) (cdr x))))))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1104
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1105 ;;; activity tracking
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1106 (or (assq 'rcirc-ignore-buffer-activity-flag minor-mode-alist)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1107 (setq minor-mode-alist
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1108 (cons '(rcirc-ignore-buffer-activity-flag " Ignore") minor-mode-alist)))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1109
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1110 (defun rcirc-toggle-ignore-buffer-activity (&optional all)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1111 "Toggle the value of `rcirc-ignore-buffer-activity-flag'.
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1112 If ALL is non-nil, instead toggle the value of
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1113 `rcirc-ignore-all-activity-flag'."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1114 (interactive "P")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1115 (if all
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1116 (progn
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1117 (setq rcirc-ignore-all-activity-flag
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1118 (not rcirc-ignore-all-activity-flag))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1119 (message (if rcirc-ignore-all-activity-flag
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1120 "Hide all buffer activity"
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1121 "Display buffer activity"))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1122 (rcirc-update-activity-string))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1123 (setq rcirc-ignore-buffer-activity-flag
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1124 (not rcirc-ignore-buffer-activity-flag))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1125 (message (if rcirc-ignore-buffer-activity-flag
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1126 "Ignore activity in this buffer"
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1127 "Notice activity in this buffer")))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1128 (force-mode-line-update))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1129
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1130 (defvar rcirc-switch-to-buffer-function 'switch-to-buffer
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1131 "Function to use when switching buffers.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1132 Possible values are `switch-to-buffer', `pop-to-buffer', and
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1133 `display-buffer'.")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1134
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1135 (defun rcirc-switch-to-server-buffer ()
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1136 "Switch to the server buffer associated with current channel buffer."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1137 (interactive)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1138 (funcall rcirc-switch-to-buffer-function (process-buffer rcirc-process)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1139
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1140 (defun rcirc-jump-to-first-unread-line ()
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1141 "Move the point to the first unread line in this buffer."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1142 (interactive)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1143 (when (marker-position overlay-arrow-position)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1144 (goto-char overlay-arrow-position)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1145
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1146 (defvar rcirc-last-non-irc-buffer nil
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1147 "The buffer to switch to when there is no more activity.")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1148
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1149 (defun rcirc-next-active-buffer (arg)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1150 "Go to the ARGth rcirc buffer with activity.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1151 The function given by `rcirc-switch-to-buffer-function' is used to
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1152 show the buffer."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1153 (interactive "p")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1154 (if rcirc-activity
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1155 (progn
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1156 (unless (eq major-mode 'rcirc-mode)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1157 (setq rcirc-last-non-irc-buffer (current-buffer)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1158 (if (and (> arg 0)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1159 (<= arg (length rcirc-activity)))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1160 (funcall rcirc-switch-to-buffer-function
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1161 (nth (1- arg) rcirc-activity))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1162 (message "Invalid arg: %d" arg)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1163 (if (eq major-mode 'rcirc-mode)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1164 (if (not (and rcirc-last-non-irc-buffer
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1165 (buffer-live-p rcirc-last-non-irc-buffer)))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1166 (message "No IRC activity. Start something.")
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1167 (message "No more IRC activity. Go back to work.")
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1168 (funcall rcirc-switch-to-buffer-function rcirc-last-non-irc-buffer)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1169 (setq rcirc-last-non-irc-buffer nil))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1170 (message "No IRC activity."))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1171
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1172 (defvar rcirc-activity-hooks nil
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1173 "Hook to be run when there is channel activity.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1174
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1175 Functions are called with a single argument, the buffer with the
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1176 activity. Only run if the buffer is not visible and
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1177 `rcirc-ignore-buffer-activity-flag' is non-nil.")
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1178
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1179 (defun rcirc-record-activity (buffer type)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1180 "Record BUFFER activity with TYPE."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1181 (with-current-buffer buffer
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1182 (when (not (get-buffer-window (current-buffer) t))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1183 (add-to-list 'rcirc-activity (current-buffer))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1184 (if (not rcirc-activity-type)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1185 (setq rcirc-activity-type type))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1186 (rcirc-update-activity-string)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1187 (run-hook-with-args 'rcirc-activity-hooks buffer))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1188
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1189 (defun rcirc-clear-activity (buffer)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1190 "Clear the BUFFER activity."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1191 (setq rcirc-activity (delete buffer rcirc-activity))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1192 (with-current-buffer buffer
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1193 (setq rcirc-activity-type nil)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1194
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1195 ;; TODO: add mouse properties
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1196 (defun rcirc-update-activity-string ()
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1197 "Update mode-line string."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1198 (setq rcirc-activity-string
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1199 (cond (rcirc-ignore-all-activity-flag
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1200 " DND")
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1201 ((not rcirc-activity)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1202 "")
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1203 (t
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1204 (concat " ["
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1205 (mapconcat
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1206 (lambda (b)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1207 (let ((s (rcirc-short-buffer-name b)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1208 (with-current-buffer b
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1209 (if (not (eq rcirc-activity-type 'nick))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1210 s
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1211 (rcirc-facify s 'rcirc-mode-line-nick)))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1212 rcirc-activity ",")
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1213 "]")))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1214
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1215 (defun rcirc-short-buffer-name (buffer)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1216 "Return a short name for BUFFER to use in the modeline indicator."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1217 (with-current-buffer buffer
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1218 (or rcirc-short-buffer-name (buffer-name))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1219
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1220 (defvar rcirc-current-buffer nil)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1221 (defun rcirc-window-configuration-change ()
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1222 "Go through visible windows and remove buffers from activity list.
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1223 Also, clear the overlay arrow if the current buffer is now hidden."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1224 (let ((current-now-hidden t))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1225 (walk-windows (lambda (w)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1226 (let ((buf (window-buffer w)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1227 (rcirc-clear-activity buf)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1228 (when (eq buf rcirc-current-buffer)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1229 (setq current-now-hidden nil)))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1230 (when (and rcirc-current-buffer current-now-hidden)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1231 (with-current-buffer rcirc-current-buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1232 (when (eq major-mode 'rcirc-mode)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1233 (marker-position overlay-arrow-position)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1234 (set-marker overlay-arrow-position nil)))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1235
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1236 ;; remove any killed buffers from list
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1237 (setq rcirc-activity
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1238 (delq nil (mapcar (lambda (buf) (when (buffer-live-p buf) buf))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1239 rcirc-activity)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1240 (rcirc-update-activity-string)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1241 (setq rcirc-current-buffer (current-buffer)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1242
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1243
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1244 ;;; buffer name abbreviation
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1245 (defun rcirc-update-short-buffer-names ()
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1246 (let ((bufalist
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1247 (apply 'append (mapcar (lambda (process)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1248 (with-rcirc-process-buffer process
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1249 rcirc-buffer-alist))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1250 (rcirc-process-list)))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1251 (dolist (i (rcirc-abbreviate bufalist))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1252 (with-current-buffer (cdr i)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1253 (setq rcirc-short-buffer-name (car i))))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1254
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1255 (defun rcirc-abbreviate (pairs)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1256 (apply 'append (mapcar 'rcirc-rebuild-tree (rcirc-make-trees pairs))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1257
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1258 (defun rcirc-rebuild-tree (tree &optional acc)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1259 (let ((ch (char-to-string (car tree))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1260 (dolist (x (cdr tree))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1261 (if (listp x)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1262 (setq acc (append acc
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1263 (mapcar (lambda (y)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1264 (cons (concat ch (car y))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1265 (cdr y)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1266 (rcirc-rebuild-tree x))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1267 (setq acc (cons (cons ch x) acc))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1268 acc))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1269
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1270 (defun rcirc-make-trees (pairs)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1271 (let (alist)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1272 (mapc (lambda (pair)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1273 (if (consp pair)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1274 (let* ((str (car pair))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1275 (data (cdr pair))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1276 (char (unless (zerop (length str))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1277 (aref str 0)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1278 (rest (unless (zerop (length str))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1279 (substring str 1)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1280 (part (if char (assq char alist))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1281 (if part
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1282 ;; existing partition
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1283 (setcdr part (cons (cons rest data) (cdr part)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1284 ;; new partition
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1285 (setq alist (cons (if char
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1286 (list char (cons rest data))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1287 data)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1288 alist))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1289 (setq alist (cons pair alist))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1290 pairs)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1291 ;; recurse into cdrs of alist
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1292 (mapc (lambda (x)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1293 (when (and (listp x) (listp (cadr x)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1294 (setcdr x (if (> (length (cdr x)) 1)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1295 (rcirc-make-trees (cdr x))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1296 (setcdr x (list (cdadr x)))))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1297 alist)))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1298
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1299 ;;; /commands these are called with 3 args: PROCESS, TARGET, which is
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1300 ;; the current buffer/channel/user, and ARGS, which is a string
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1301 ;; containing the text following the /cmd.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1302
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1303 (defmacro defun-rcirc-command (command argument docstring interactive-form
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1304 &rest body)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1305 "Define a command."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1306 `(defun ,(intern (concat "rcirc-cmd-" (symbol-name command)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1307 (,@argument &optional process target)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1308 ,(concat docstring "\n\nNote: If PROCESS or TARGET are nil, the values of"
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1309 "\nbuffer local variables `rcirc-process' and `rcirc-target',"
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1310 "\nwill be used.")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1311 ,interactive-form
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1312 (let ((process (or process rcirc-process))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1313 (target (or target rcirc-target)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1314 ,@body)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1315
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1316 (defun-rcirc-command msg (message)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1317 "Send private MESSAGE to TARGET."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1318 (interactive "i")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1319 (if (null message)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1320 (progn
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1321 (setq target (completing-read "Message nick: "
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1322 (with-rcirc-process-buffer rcirc-process
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1323 rcirc-nick-table)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1324 (when (> (length target) 0)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1325 (setq message (read-string (format "Message %s: " target)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1326 (when (> (length message) 0)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1327 (rcirc-send-message process target message))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1328 (if (not (string-match "\\([^ ]+\\) \\(.+\\)" message))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1329 (message "Not enough args, or something.")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1330 (setq target (match-string 1 message)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1331 message (match-string 2 message))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1332 (rcirc-send-message process target message))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1333
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1334 (defun-rcirc-command query (nick)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1335 "Open a private chat buffer to NICK."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1336 (interactive (list (completing-read "Query nick: "
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1337 (with-rcirc-process-buffer rcirc-process
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1338 rcirc-nick-table))))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1339 (let ((existing-buffer (rcirc-get-buffer process nick)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1340 (switch-to-buffer (or existing-buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1341 (rcirc-get-buffer-create process nick)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1342 (when (not existing-buffer)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1343 (rcirc-cmd-whois nick))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1344
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1345 (defun-rcirc-command join (args)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1346 "Join CHANNEL."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1347 (interactive "sJoin channel: ")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1348 (let* ((channel (car (split-string args)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1349 (buffer (rcirc-get-buffer-create process channel)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1350 (when (not (eq (selected-window) (minibuffer-window)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1351 (funcall rcirc-switch-to-buffer-function buffer))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1352 (rcirc-send-string process (concat "JOIN " args))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1353
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1354 (defun-rcirc-command part (channel)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1355 "Part CHANNEL."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1356 (interactive "sPart channel: ")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1357 (let ((channel (if (> (length channel) 0) channel target)))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1358 (rcirc-send-string process (concat "PART " channel " :" rcirc-id-string))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1359
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1360 (defun-rcirc-command quit (reason)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1361 "Send a quit message to server with REASON."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1362 (interactive "sQuit reason: ")
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1363 (rcirc-send-string process (concat "QUIT :"
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1364 (if (not (zerop (length reason)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1365 reason
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1366 rcirc-id-string))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1367
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1368 (defun-rcirc-command nick (nick)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1369 "Change nick to NICK."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1370 (interactive "i")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1371 (when (null nick)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1372 (setq nick (read-string "New nick: " (rcirc-nick process))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1373 (rcirc-send-string process (concat "NICK " nick)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1374
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1375 (defun-rcirc-command names (channel)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1376 "Display list of names in CHANNEL or in current channel if CHANNEL is nil.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1377 If called interactively, prompt for a channel when prefix arg is supplied."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1378 (interactive "P")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1379 (if (interactive-p)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1380 (if channel
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1381 (setq channel (read-string "List names in channel: " target))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1382 (let ((channel (if (> (length channel) 0)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1383 channel
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1384 target)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1385 (rcirc-send-string process (concat "NAMES " channel))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1386
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1387 (defun-rcirc-command topic (topic)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1388 "List TOPIC for the TARGET channel.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1389 With a prefix arg, prompt for new topic."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1390 (interactive "P")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1391 (if (and (interactive-p) topic)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1392 (setq topic (read-string "New Topic: " rcirc-topic)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1393 (rcirc-send-string process (concat "TOPIC " target
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1394 (when (> (length topic) 0)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1395 (concat " :" topic)))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1396
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1397 (defun-rcirc-command whois (nick)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1398 "Request information from server about NICK."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1399 (interactive (list
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1400 (completing-read "Whois: "
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1401 (with-rcirc-process-buffer rcirc-process
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1402 rcirc-nick-table))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1403 (rcirc-send-string process (concat "WHOIS " nick)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1404
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1405 (defun-rcirc-command mode (args)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1406 "Set mode with ARGS."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1407 (interactive (list (concat (read-string "Mode nick or channel: ")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1408 " " (read-string "Mode: "))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1409 (rcirc-send-string process (concat "MODE " args)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1410
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1411 (defun-rcirc-command list (channels)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1412 "Request information on CHANNELS from server."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1413 (interactive "sList Channels: ")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1414 (rcirc-send-string process (concat "LIST " channels)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1415
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1416 (defun-rcirc-command oper (args)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1417 "Send operator command to server."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1418 (interactive "sOper args: ")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1419 (rcirc-send-string process (concat "OPER " args)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1420
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1421 (defun-rcirc-command quote (message)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1422 "Send MESSAGE literally to server."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1423 (interactive "sServer message: ")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1424 (rcirc-send-string process message))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1425
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1426 (defun-rcirc-command kick (arg)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1427 "Kick NICK from current channel."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1428 (interactive (list
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1429 (concat (completing-read "Kick nick: "
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1430 (rcirc-channel-nicks rcirc-process
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1431 rcirc-target))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1432 (read-from-minibuffer "Kick reason: "))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1433 (let* ((arglist (split-string arg))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1434 (argstring (concat (car arglist) " :"
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1435 (mapconcat 'identity (cdr arglist) " "))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1436 (rcirc-send-string process (concat "KICK " target " " argstring))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1437
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1438 (defun rcirc-cmd-ctcp (args &optional process target)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1439 (if (string-match "^\\([^ ]+\\)\\s-+\\(.+\\)$" args)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1440 (let ((target (match-string 1 args))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1441 (request (match-string 2 args)))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1442 (rcirc-send-string process
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1443 (format "PRIVMSG %s \C-a%s\C-a"
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1444 target (upcase request))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1445 (rcirc-print process (rcirc-nick process) "ERROR" nil
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1446 "usage: /ctcp NICK REQUEST")))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1447
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1448 (defun rcirc-cmd-me (args &optional process target)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1449 (rcirc-send-string process (format "PRIVMSG %s :\C-aACTION %s\C-a"
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1450 target args)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1451
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1452 (defun rcirc-message-leader (sender face)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1453 "Return a string with SENDER propertized with FACE."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1454 (rcirc-facify (concat "<" (rcirc-user-nick sender) "> ") face))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1455
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1456 (defun rcirc-facify (string face)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1457 "Return a copy of STRING with FACE property added."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1458 (propertize (or string "") 'face face 'rear-nonsticky t))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1459
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1460 (defvar rcirc-url-regexp
67014
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1461 (rx word-boundary
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1462 (or "www."
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1463 (and (or "http" "https" "ftp" "file" "gopher" "news" "telnet" "wais"
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1464 "mailto")
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1465 "://"
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1466 (1+ (char "a-zA-Z0-9_."))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1467 (optional ":" (1+ (char "0-9")))))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1468 (1+ (char "-a-zA-Z0-9_=!?#$\@~`%&*+|\\/:;.,"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1469 (char "-a-zA-Z0-9_=!?#$\@~`%&*+|\\/:;"))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1470 "Regexp matching URL's. Set to nil to disable URL features in rcirc.")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1471
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1472 (defun rcirc-browse-url (&optional arg)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1473 "Prompt for url to browse based on urls in buffer."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1474 (interactive)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1475 (let ((completions (mapcar (lambda (x) (cons x nil)) rcirc-urls))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1476 (initial-input (car rcirc-urls))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1477 (history (cdr rcirc-urls)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1478 (browse-url (completing-read "rcirc browse-url: "
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1479 completions nil nil initial-input 'history)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1480 arg)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1481
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1482 (defun rcirc-browse-url-at-point (point)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1483 "Send URL at point to `browse-url'."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1484 (interactive "d")
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1485 (let ((beg (previous-single-property-change point 'mouse-face))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1486 (end (next-single-property-change point 'mouse-face)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1487 (browse-url (buffer-substring-no-properties beg end))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1488
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1489 (defun rcirc-browse-url-at-mouse (event)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1490 "Send URL at mouse click to `browse-url'."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1491 (interactive "e")
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1492 (let ((position (event-end event)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1493 (with-current-buffer (window-buffer (posn-window position))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1494 (rcirc-browse-url-at-point (posn-point position)))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1495
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1496 (defun rcirc-map-regexp (function regexp string)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1497 "Return a copy of STRING after calling FUNCTION for each REGEXP match.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1498 FUNCTION takes 3 arguments, MATCH-START, MATCH-END, and STRING."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1499 (let ((start 0))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1500 (while (string-match regexp string start)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1501 (setq start (match-end 0))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1502 (funcall function (match-beginning 0) (match-end 0) string)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1503 string)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1504
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1505 (defvar rcirc-nick-syntax-table
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1506 (let ((table (make-syntax-table text-mode-syntax-table)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1507 (mapc (lambda (c) (modify-syntax-entry c "w" table))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1508 "[]\\`_^{|}-")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1509 (modify-syntax-entry ?' "_" table)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1510 table)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1511 "Syntax table which includes all nick characters as word constituents.")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1512
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1513 (defun rcirc-mangle-text (process text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1514 "Return TEXT with properties added based on various patterns."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1515 ;; ^B
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1516 (setq text
67014
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1517 (rcirc-map-regexp
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1518 (lambda (start end string)
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1519 (let ((orig-face (get-text-property start 'face string)))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1520 (add-text-properties
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1521 start end
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1522 (list 'face (if (listp orig-face)
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1523 (append orig-face
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1524 (list 'bold))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1525 (list orig-face 'bold))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1526 'rear-nonsticky t)
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1527 string)))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1528 ".*?"
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1529 text))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1530 ;; TODO: deal with ^_ and ^C colors sequences
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1531 (while (string-match "\\(.*\\)[]\\(.*\\)" text)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1532 (setq text (concat (match-string 1 text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1533 (match-string 2 text))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1534 ;; my nick
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1535 (setq text
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1536 (with-syntax-table rcirc-nick-syntax-table
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1537 (rcirc-map-regexp (lambda (start end string)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1538 (add-text-properties
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1539 start end
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1540 (list 'face 'rcirc-nick-in-message
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1541 'rear-nonsticky t)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1542 string))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1543 (concat "\\b"
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1544 (regexp-quote (rcirc-nick process))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1545 "\\b")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1546 text)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1547 ;; urls
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1548 (setq text
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1549 (rcirc-map-regexp
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1550 (lambda (start end string)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1551 (let ((orig-face (get-text-property start 'face string)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1552 (add-text-properties start end
67014
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1553 (list 'face (if (listp orig-face)
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1554 (append orig-face
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1555 (list 'bold))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1556 (list orig-face 'bold))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1557 'rear-nonsticky t
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1558 'mouse-face 'highlight
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1559 'keymap rcirc-browse-url-map)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1560 string))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1561 (push (substring string start end) rcirc-urls))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1562 rcirc-url-regexp
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1563 text))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1564 text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1565
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1566
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1567 ;;; handlers
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1568 ;; these are called with the server PROCESS, the SENDER, which is a
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1569 ;; server or a user, depending on the command, the ARGS, which is a
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1570 ;; list of strings, and the TEXT, which is the original server text,
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1571 ;; verbatim
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1572 (defun rcirc-handler-001 (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1573 (rcirc-handler-generic process "001" sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1574 ;; set the real server name
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1575 (with-rcirc-process-buffer process
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1576 (setq rcirc-server sender)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1577 (setq rcirc-nick (car args))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1578 (rcirc-update-prompt)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1579 (when rcirc-auto-authenticate-flag (rcirc-authenticate))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1580 (rcirc-join-channels process rcirc-startup-channels)))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1581
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1582 (defun rcirc-handler-PRIVMSG (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1583 (let ((target (if (rcirc-channel-p (car args))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1584 (car args)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1585 (rcirc-user-nick sender)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1586 (message (or (cadr args) "")))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1587 (if (string-match "^\C-a\\(.*\\)\C-a$" message)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1588 (rcirc-handler-CTCP process target sender (match-string 1 message))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1589 (rcirc-print process sender "PRIVMSG" target message t))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1590 ;; update nick timestamp
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1591 (if (member target (rcirc-nick-channels process sender))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1592 (rcirc-put-nick-channel process sender target))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1593
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1594 (defun rcirc-handler-NOTICE (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1595 (let ((target (car args))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1596 (message (cadr args)))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1597 (if (string-match "^\C-a\\(.*\\)\C-a$" message)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1598 (rcirc-handler-CTCP-response process target sender
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1599 (match-string 1 message))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1600 (rcirc-print process sender "NOTICE"
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1601 (cond ((rcirc-channel-p target)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1602 target)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1603 ;;; -ChanServ- [#gnu] Welcome...
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1604 ((string-match "^\\[\\(#[^ ]+\\)\\]" message)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1605 (match-string 1 message))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1606 (sender
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1607 (if (string= sender (rcirc-server process))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1608 (process-buffer process)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1609 (rcirc-user-nick sender))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1610 message t))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1611 ;; do we need this:
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1612 ;;(and sender (rcirc-put-nick-channel process sender target))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1613
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1614 (defun rcirc-handler-WALLOPS (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1615 (let ((target (rcirc-user-nick sender)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1616 (rcirc-print process sender "WALLOPS" target (car args) t)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1617
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1618 (defun rcirc-handler-JOIN (process sender args text)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1619 (let ((channel (car args))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1620 (nick (rcirc-user-nick sender)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1621 (rcirc-get-buffer-create process channel)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1622 (rcirc-print process sender "JOIN" channel "")
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1623
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1624 ;; print in private chat buffer if it exists
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1625 (when (rcirc-get-buffer rcirc-process nick)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1626 (rcirc-print process sender "JOIN" nick channel))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1627
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1628 (rcirc-put-nick-channel process sender channel)))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1629
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1630 ;; PART and KICK are handled the same way
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1631 (defun rcirc-handler-PART-or-KICK (process response channel sender nick args)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1632 (rcirc-print process sender response channel (concat channel " " args))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1633
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1634 ;; print in private chat buffer if it exists
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1635 (when (rcirc-get-buffer rcirc-process nick)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1636 (rcirc-print process sender response nick (concat channel " " args)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1637
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1638 (if (not (string= nick (rcirc-nick process)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1639 ;; this is someone else leaving
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1640 (rcirc-remove-nick-channel process nick channel)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1641 ;; this is us leaving
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1642 (mapc (lambda (n)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1643 (rcirc-remove-nick-channel process n channel))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1644 (rcirc-channel-nicks process channel))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1645
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1646 ;; if the buffer is still around, make it inactive
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1647 (let ((buffer (rcirc-get-buffer process channel)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1648 (when buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1649 (with-current-buffer buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1650 (setq rcirc-target nil))))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1651
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1652 (defun rcirc-handler-PART (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1653 (rcirc-handler-PART-or-KICK process "PART"
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1654 (car args) sender (rcirc-user-nick sender)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1655 (cadr args)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1656
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1657 (defun rcirc-handler-KICK (process sender args text)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1658 (rcirc-handler-PART-or-KICK process "KICK" (car args) sender (cadr args)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1659 (caddr args)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1660
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1661 (defun rcirc-handler-QUIT (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1662 (let ((nick (rcirc-user-nick sender)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1663 (mapc (lambda (channel)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1664 (rcirc-print process sender "QUIT" channel (apply 'concat args)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1665 (rcirc-nick-channels process nick))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1666
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1667 ;; print in private chat buffer if it exists
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1668 (let ((buffer (rcirc-get-buffer rcirc-process nick)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1669 (when buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1670 (rcirc-print process sender "QUIT" buffer (apply 'concat args))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1671
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1672 (rcirc-nick-remove process nick)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1673
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1674 (defun rcirc-handler-NICK (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1675 (let* ((old-nick (rcirc-user-nick sender))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1676 (new-nick (car args))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1677 (channels (rcirc-nick-channels process old-nick)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1678 ;; print message to nick's channels
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1679 (dolist (target channels)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1680 (rcirc-print process sender "NICK" target new-nick))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1681 ;; update private chat buffer, if it exists
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1682 (let ((chat-buffer (rcirc-get-buffer process old-nick)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1683 (when chat-buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1684 (with-current-buffer chat-buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1685 (rcirc-print process sender "NICK" old-nick new-nick)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1686 (setq rcirc-target new-nick)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1687 (rename-buffer (rcirc-generate-new-buffer-name process new-nick)))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1688 ;; remove old nick and add new one
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1689 (with-rcirc-process-buffer process
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1690 (let ((v (gethash old-nick rcirc-nick-table)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1691 (remhash old-nick rcirc-nick-table)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1692 (puthash new-nick v rcirc-nick-table))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1693 ;; if this is our nick...
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1694 (when (string= old-nick rcirc-nick)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1695 (setq rcirc-nick new-nick)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1696 (rcirc-update-prompt t)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1697 ;; reauthenticate
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1698 (when rcirc-auto-authenticate-flag (rcirc-authenticate))))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1699
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1700 (defun rcirc-handler-PING (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1701 (rcirc-send-string process (concat "PONG " (car args))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1702
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1703 (defun rcirc-handler-PONG (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1704 ;; do nothing
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1705 )
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1706
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1707 (defun rcirc-handler-TOPIC (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1708 (let ((topic (cadr args)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1709 (rcirc-print process sender "TOPIC" (car args) topic)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1710 (with-current-buffer (rcirc-get-buffer process (car args))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1711 (setq rcirc-topic topic))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1712
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1713 (defun rcirc-handler-332 (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1714 "RPL_TOPIC"
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1715 (let ((buffer (or (rcirc-get-buffer process (cadr args))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1716 (rcirc-get-temp-buffer-create process (cadr args)))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1717 (with-current-buffer buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1718 (setq rcirc-topic (caddr args)))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1719
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1720 (defun rcirc-handler-333 (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1721 "Not in rfc1459.txt"
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1722 (let ((buffer (or (rcirc-get-buffer process (cadr args))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1723 (rcirc-get-temp-buffer-create process (cadr args)))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1724 (with-current-buffer buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1725 (let ((setter (caddr args))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1726 (time (current-time-string
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1727 (seconds-to-time
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1728 (string-to-number (cadddr args))))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1729 (rcirc-print process sender "TOPIC" (cadr args)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1730 (format "%s (%s on %s)" rcirc-topic setter time))))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1731
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1732 (defun rcirc-handler-477 (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1733 "ERR_NOCHANMODES"
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1734 (rcirc-print process sender "477" (cadr args) (caddr args)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1735
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1736 (defun rcirc-handler-MODE (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1737 (let ((target (car args))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1738 (msg (mapconcat 'identity (cdr args) " ")))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1739 (rcirc-print process sender "MODE"
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1740 (if (string= target (rcirc-nick process))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1741 nil
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1742 target)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1743 msg)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1744
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1745 ;; print in private chat buffers if they exist
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1746 (mapc (lambda (nick)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1747 (let ((existing-buffer (rcirc-get-buffer process nick)))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1748 (when existing-buffer
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1749 (rcirc-print process sender "MODE" existing-buffer msg))))
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1750 (cddr args))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1751
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1752 (defun rcirc-get-temp-buffer-create (process channel)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1753 "Return a buffer based on PROCESS and CHANNEL."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1754 (let ((tmpnam (concat " " (downcase channel) "TMP" (process-name process))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1755 (get-buffer-create tmpnam)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1756
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1757 (defun rcirc-handler-353 (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1758 "RPL_NAMREPLY"
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1759 (let ((channel (caddr args)))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1760 (mapc (lambda (nick)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1761 (rcirc-put-nick-channel process nick channel))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1762 (split-string (cadddr args) " " t))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1763 (with-current-buffer (rcirc-get-temp-buffer-create process channel)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1764 (goto-char (point-max))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1765 (insert (car (last args)) " "))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1766
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1767 (defun rcirc-handler-366 (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1768 "RPL_ENDOFNAMES"
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1769 (let* ((channel (cadr args))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1770 (buffer (rcirc-get-temp-buffer-create process channel)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1771 (with-current-buffer buffer
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1772 (rcirc-print process sender "NAMES" channel
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1773 (buffer-substring (point-min) (point-max))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1774 (kill-buffer buffer)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1775
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1776 (defun rcirc-handler-433 (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1777 "ERR_NICKNAMEINUSE"
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1778 (rcirc-handler-generic process "433" sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1779 (let* ((new-nick (concat (cadr args) "`")))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1780 (with-rcirc-process-buffer process
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1781 (rcirc-cmd-nick new-nick nil process))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1782
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1783 (defun rcirc-authenticate ()
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1784 "Send authentication to process associated with current buffer.
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1785 Passwords are read from `rcirc-authinfo-file-name' (which see)."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1786 (interactive)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1787 (let ((password-alist
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1788 (with-temp-buffer
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1789 (insert-file-contents-literally rcirc-authinfo-file-name)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1790 (goto-char (point-min))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1791 (read (current-buffer)))))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1792 (with-rcirc-process-buffer rcirc-process
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1793 (dolist (i password-alist)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1794 (let ((server (car i))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1795 (nick (cadr i))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1796 (method (caddr i))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1797 (args (cdddr i)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1798 (when (and (string-match server rcirc-server)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1799 (string-match nick rcirc-nick))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1800 (cond ((equal method 'nickserv)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1801 (rcirc-send-string
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1802 rcirc-process
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1803 (concat
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1804 "PRIVMSG nickserv :identify "
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1805 (car args))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1806 ((equal method 'chanserv)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1807 (rcirc-send-string
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1808 rcirc-process
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1809 (concat
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1810 "PRIVMSG chanserv :identify "
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1811 (car args) " " (cadr args))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1812 ((equal method 'bitlbee)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1813 (rcirc-send-string
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1814 rcirc-process
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1815 (concat "PRIVMSG #bitlbee :identify " (car args))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1816 (t
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1817 (message "No %S authentication method defined"
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1818 method)))))))))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1819
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1820 (defun rcirc-handler-INVITE (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1821 (rcirc-print process sender "INVITE" nil (mapconcat 'identity args " ") t))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1822
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1823 (defun rcirc-handler-ERROR (process sender args text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1824 (rcirc-print process sender "ERROR" nil (mapconcat 'identity args " ")))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1825
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1826 (defun rcirc-handler-CTCP (process target sender text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1827 (if (string-match "^\\([^ ]+\\) *\\(.*\\)$" text)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1828 (let* ((request (upcase (match-string 1 text)))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1829 (args (match-string 2 text))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1830 (nick (rcirc-user-nick sender))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1831 (handler (intern-soft (concat "rcirc-handler-ctcp-" request))))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1832 (if (not (fboundp handler))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1833 (rcirc-print process sender "ERROR"
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1834 (rcirc-get-buffer process target)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1835 (format "%s sent unsupported ctcp: %s" nick text)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1836 t)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1837 (funcall handler process target sender args)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1838 (if (not (string= request "ACTION"))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1839 (rcirc-print process sender "CTCP"
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1840 (rcirc-get-buffer process target)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1841 (format "%s" text) t))))))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1842
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1843 (defun rcirc-handler-ctcp-VERSION (process target sender args)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1844 (rcirc-send-string process
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1845 (concat "NOTICE " (rcirc-user-nick sender)
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1846 " :\C-aVERSION " rcirc-id-string
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1847 "\C-a")))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1848
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1849 (defun rcirc-handler-ctcp-ACTION (process target sender args)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1850 (rcirc-print process sender "ACTION" target args t))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1851
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1852 (defun rcirc-handler-ctcp-TIME (process target sender args)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1853 (rcirc-send-string process
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1854 (concat "NOTICE " (rcirc-user-nick sender)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1855 " :\C-aTIME " (current-time-string) "\C-a")))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1856
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1857 (defun rcirc-handler-CTCP-response (process target sender message)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1858 (rcirc-print process sender "CTCP" nil message t))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1859
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1860 (defgroup rcirc-faces nil
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1861 "Faces for rcirc."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1862 :group 'rcirc
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1863 :group 'faces)
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1864
67014
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1865 (defface rcirc-my-nick ; font-lock-function-name-face
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1866 '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1867 (((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1868 (((class color) (min-colors 16) (background light)) (:foreground "Blue"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1869 (((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1870 (((class color) (min-colors 8)) (:foreground "blue" :weight bold))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1871 (t (:inverse-video t :weight bold)))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1872 "The face used to highlight my messages."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1873 :group 'rcirc-faces)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1874
67014
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1875 (defface rcirc-other-nick ; font-lock-variable-name-face
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1876 '((((class grayscale) (background light))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1877 (:foreground "Gray90" :weight bold :slant italic))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1878 (((class grayscale) (background dark))
67014
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1879 (:foreground "DimGray" :weight bold :slant italic))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1880 (((class color) (min-colors 88) (background light)) (:foreground "DarkGoldenrod"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1881 (((class color) (min-colors 88) (background dark)) (:foreground "LightGoldenrod"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1882 (((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1883 (((class color) (min-colors 16) (background dark)) (:foreground "LightGoldenrod"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1884 (((class color) (min-colors 8)) (:foreground "yellow" :weight light))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1885 (t (:weight bold :slant italic)))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1886 "The face used to highlight other messages."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1887 :group 'rcirc-faces)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1888
67014
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1889 (defface rcirc-server ; font-lock-comment-face
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1890 '((((class grayscale) (background light))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1891 (:foreground "DimGray" :weight bold :slant italic))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1892 (((class grayscale) (background dark))
67014
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1893 (:foreground "LightGray" :weight bold :slant italic))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1894 (((class color) (min-colors 88) (background light))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1895 (:foreground "Firebrick"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1896 (((class color) (min-colors 88) (background dark))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1897 (:foreground "chocolate1"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1898 (((class color) (min-colors 16) (background light))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1899 (:foreground "red"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1900 (((class color) (min-colors 16) (background dark))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1901 (:foreground "red1"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1902 (((class color) (min-colors 8) (background light))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1903 )
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1904 (((class color) (min-colors 8) (background dark))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1905 )
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1906 (t (:weight bold :slant italic)))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1907 "The face used to highlight server messages."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1908 :group 'rcirc-faces)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1909
67014
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1910 (defface rcirc-server-prefix ; font-lock-comment-delimiter-face
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1911 '((default :inherit font-lock-comment-face)
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1912 (((class grayscale)))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1913 (((class color) (min-colors 16)))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1914 (((class color) (min-colors 8) (background light))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1915 :foreground "red")
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1916 (((class color) (min-colors 8) (background dark))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1917 :foreground "red1"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1918 "The face used to highlight server prefixes."
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1919 :group 'rcirc-faces)
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1920
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1921 (defface rcirc-timestamp
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1922 '((t (:inherit default)))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1923 "The face used to highlight timestamps."
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1924 :group 'rcirc-faces)
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1925
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1926 (defface rcirc-nick-in-message ; font-lock-keyword-face
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1927 '((((class grayscale) (background light)) (:foreground "LightGray" :weight bold))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1928 (((class grayscale) (background dark)) (:foreground "DimGray" :weight bold))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1929 (((class color) (min-colors 88) (background light)) (:foreground "Purple"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1930 (((class color) (min-colors 88) (background dark)) (:foreground "Cyan1"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1931 (((class color) (min-colors 16) (background light)) (:foreground "Purple"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1932 (((class color) (min-colors 16) (background dark)) (:foreground "Cyan"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1933 (((class color) (min-colors 8)) (:foreground "cyan" :weight bold))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1934 (t (:weight bold)))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1935 "The face used to highlight instances of nick within messages."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1936 :group 'rcirc-faces)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1937
67014
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1938 (defface rcirc-prompt ; comint-highlight-prompt
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1939 '((((min-colors 88) (background dark)) (:foreground "cyan1"))
d3d8e2bcfa98 (rcirc-mangle-text): Add bold face property without replacing existing
Eli Zaretskii <eliz@gnu.org>
parents: 66703
diff changeset
1940 (((background dark)) (:foreground "cyan"))
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1941 (t (:foreground "dark blue")))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1942 "The face to use to highlight prompts."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1943 :group 'rcirc-faces)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1944
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1945 (defface rcirc-mode-line-nick
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1946 '((t (:bold t)))
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1947 "The face used indicate activity directed at you."
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1948 :group 'rcirc-faces)
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1949
66703
6cfb275aa300 Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents: 66272
diff changeset
1950 ;; When using M-x flyspell-mode, only check words after the prompt
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1951 (put 'rcirc-mode 'flyspell-mode-predicate 'rcirc-looking-at-input)
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1952 (defun rcirc-looking-at-input ()
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1953 "Returns true if point is past the input marker."
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1954 (>= (point) rcirc-prompt-end-marker))
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1955
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1956
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1957 (provide 'rcirc)
66258
4e4cce911e2e Add arch tagline
Miles Bader <miles@gnu.org>
parents: 66252
diff changeset
1958
4e4cce911e2e Add arch tagline
Miles Bader <miles@gnu.org>
parents: 66252
diff changeset
1959 ;; arch-tag: b471b7e8-6b5a-4399-b2c6-a3c78dfc8ffb
66248
6914d742203d New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1960 ;;; rcirc.el ends here