Mercurial > emacs
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 |
rev | line source |
---|---|
66248 | 1 ;;; rcirc.el --- default, simple IRC client. |
2 | |
3 ;; Copyright (C) 2005 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Ryan Yeske | |
6 ;; URL: http://www.nongnu.org/rcirc | |
7 ;; Keywords: comm | |
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 | 10 |
11 ;; This file is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; This file is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
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 | 25 |
26 ;;; Commentary: | |
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 | 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 | 39 |
40 ;; Open a new irc connection with: | |
41 ;; M-x irc RET | |
42 | |
43 ;;; Code: | |
44 | |
45 (require 'ring) | |
46 (require 'time-date) | |
47 (eval-when-compile (require 'cl)) | |
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 | 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 | 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 | 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 | 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 | 76 rcirc-user-name |
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 | 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 | 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 | 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 | 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 | 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 | 103 "*Text to insert before filled lines. |
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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 136 "*The maximum size in lines for rcirc buffers. |
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 | 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 | 144 "~/.rcirc-authinfo" |
145 "File containing rcirc authentication passwords. | |
146 The file consists of a single list, with each element itself a | |
147 list with a SERVER-REGEXP string, a NICK-REGEXP string, a METHOD | |
148 and the remaining method specific ARGUMENTS. The valid METHOD | |
149 symbols are `nickserv', `chanserv' and `bitlbee'. | |
150 | |
151 The required ARGUMENTS for each METHOD symbol are: | |
152 `nickserv': PASSWORD | |
153 `chanserv': CHANNEL PASSWORD | |
154 `bitlbee': PASSWORD | |
155 | |
156 Example: | |
157 ((\"freenode\" \"bob\" nickserv \"p455w0rd\") | |
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 | 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 | 168 |
66703
6cfb275aa300
Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents:
66272
diff
changeset
|
169 (defcustom rcirc-prompt "> " |
66248 | 170 "Prompt string to use in irc buffers. |
171 | |
172 The following replacements are made: | |
173 %n is your nick. | |
174 %s is the server. | |
175 %t is the buffer target, a channel or a user. | |
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 | 189 |
190 (defvar rcirc-prompt-start-marker nil) | |
191 (defvar rcirc-prompt-end-marker nil) | |
192 | |
193 (defvar rcirc-nick-table nil) | |
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 | 198 (defvar rcirc-activity nil |
199 "List of channels with unviewed activity.") | |
200 | |
201 (defvar rcirc-activity-string "" | |
202 "String displayed in modeline representing `rcirc-activity'.") | |
203 (put 'rcirc-activity-string 'risky-local-variable t) | |
204 | |
205 (defvar rcirc-process nil | |
206 "The server process associated with this buffer.") | |
207 | |
208 (defvar rcirc-target nil | |
209 "The channel or user associated with this buffer.") | |
210 | |
211 (defvar rcirc-urls nil | |
212 "List of urls seen in the current buffer.") | |
213 | |
214 (defvar rcirc-keepalive-seconds 60 | |
215 "Number of seconds between keepalive pings.") | |
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 | 218 |
219 (defvar rcirc-startup-channels nil) | |
220 ;;;###autoload | |
221 (defun rcirc (&optional server port nick channels) | |
222 "Connect to IRC. | |
223 | |
224 If any of the the optional SERVER, PORT, NICK or CHANNELS are not | |
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 | 227 respectively." |
228 (interactive (list (read-string "IRC Server: " rcirc-server) | |
229 (read-string "IRC Port: " (number-to-string rcirc-port)) | |
230 (read-string "IRC Nick: " rcirc-nick))) | |
231 (or server (setq server rcirc-server)) | |
232 (or port (setq port rcirc-port)) | |
233 (or nick (setq nick rcirc-nick)) | |
234 (or channels | |
235 (setq channels | |
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 | 243 (rcirc-startup-channels server)))) |
244 (or global-mode-string (setq global-mode-string '(""))) | |
245 (and (not (memq 'rcirc-activity-string global-mode-string)) | |
246 (setq global-mode-string | |
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 | 250 (rcirc-connect server port nick rcirc-user-name rcirc-user-full-name |
251 channels)) | |
252 | |
253 ;;;###autoload | |
254 (defalias 'irc 'rcirc) | |
255 | |
256 | |
257 (defvar rcirc-process-output nil) | |
258 (defvar rcirc-topic nil) | |
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 | 261 (defun rcirc-connect (server port nick user-name full-name startup-channels) |
262 "Return a connection to SERVER on PORT. | |
263 | |
264 User will identify using the values of NICK, USER-NAME and | |
265 FULL-NAME. The variable list of channel names in | |
266 STARTUP-CHANNELS will automatically be joined on startup." | |
267 (save-excursion | |
268 (message "Connecting to %s..." server) | |
269 (let* ((inhibit-eol-conversion) | |
270 (port-number (if (stringp port) | |
271 (string-to-number port) | |
272 port)) | |
273 (process (open-network-stream server nil server port-number))) | |
274 ;; set up process | |
275 (set-process-coding-system process 'raw-text 'raw-text) | |
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 | 278 (set-process-buffer process (current-buffer)) |
279 (set-process-sentinel process 'rcirc-sentinel) | |
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 | 283 (make-local-variable 'rcirc-nick-table) |
284 (setq rcirc-nick-table (make-hash-table :test 'equal)) | |
285 (make-local-variable 'rcirc-server) | |
286 (setq rcirc-server server) | |
287 (make-local-variable 'rcirc-nick) | |
288 (setq rcirc-nick nick) | |
289 (make-local-variable 'rcirc-process-output) | |
290 (setq rcirc-process-output nil) | |
291 (make-local-variable 'rcirc-startup-channels) | |
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 | 295 |
296 ;; identify | |
297 (rcirc-send-string process (concat "NICK " nick)) | |
298 (rcirc-send-string process (concat "USER " user-name | |
299 " hostname servername :" | |
300 full-name)) | |
301 | |
302 ;; setup ping timer if necessary | |
303 (unless rcirc-keepalive-timer | |
304 (setq rcirc-keepalive-timer | |
305 (run-at-time 0 rcirc-keepalive-seconds 'rcirc-keepalive))) | |
306 | |
307 (message "Connecting to %s...done" server) | |
308 | |
309 ;; return process object | |
310 process))) | |
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 | 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 | 321 (if (rcirc-process-list) |
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 | 328 (rcirc-process-list)) |
329 (cancel-timer rcirc-keepalive-timer) | |
330 (setq rcirc-keepalive-timer nil))) | |
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 | 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 | 340 (save-excursion |
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 | 343 (goto-char (point-max)) |
344 (insert (concat | |
345 "[" | |
346 (format-time-string "%Y-%m-%dT%T ") (process-name process) | |
347 "] " | |
348 text)))))) | |
66703
6cfb275aa300
Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents:
66272
diff
changeset
|
349 |
66248 | 350 (defvar rcirc-sentinel-hooks nil |
351 "Hook functions called when the process sentinel is called. | |
352 Functions are called with PROCESS and SENTINEL arguments.") | |
353 | |
354 (defun rcirc-sentinel (process sentinel) | |
355 "Called when PROCESS receives SENTINEL." | |
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 | 361 (format "%s: %s (%S)" |
362 (process-name process) | |
363 sentinel | |
364 (process-status process)) t) | |
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 | 367 (let ((inhibit-read-only t)) |
368 (delete-region rcirc-prompt-start-marker | |
369 rcirc-prompt-end-marker))))) | |
370 (run-hook-with-args 'rcirc-sentinel-hooks process sentinel))) | |
371 | |
372 (defun rcirc-process-list () | |
373 "Return a list of rcirc processes." | |
374 (let (ps) | |
375 (mapc (lambda (p) | |
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 | 378 (when (eq major-mode 'rcirc-mode) |
379 (setq ps (cons p ps)))))) | |
380 (process-list)) | |
381 ps)) | |
382 | |
383 (defvar rcirc-receive-message-hooks nil | |
384 "Hook functions run when a message is recieved from server. | |
385 Function is called with PROCESS COMMAND SENDER ARGS and LINE.") | |
386 (defun rcirc-filter (process output) | |
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 | 391 (setq rcirc-process-output (concat rcirc-process-output output)) |
392 (when (= (aref rcirc-process-output | |
393 (1- (length rcirc-process-output))) ?\n) | |
394 (mapc (lambda (line) | |
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 | 397 (setq rcirc-process-output nil)))) |
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 | 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 | 402 (condition-case err |
403 (rcirc-process-server-response-1 process text) | |
404 (error | |
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 | 407 (rcirc-process-server-response-1 process text))) |
408 | |
409 (defun rcirc-process-server-response-1 (process text) | |
410 (if (string-match "^\\(:\\([^ ]+\\) \\)?\\([^ ]+\\) \\(.+\\)$" text) | |
411 (let* ((sender (match-string 2 text)) | |
412 (cmd (match-string 3 text)) | |
413 (args (match-string 4 text)) | |
414 (handler (intern-soft (concat "rcirc-handler-" cmd)))) | |
415 (string-match "^\\([^:]*\\):?\\(.+\\)?$" args) | |
416 (let* ((args1 (match-string 1 args)) | |
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 | 420 (if (not (fboundp handler)) |
421 (rcirc-handler-generic process cmd sender args text) | |
422 (funcall handler process sender args text)) | |
423 (run-hook-with-args 'rcirc-receive-message-hooks | |
424 process cmd sender args text))) | |
425 (message "UNHANDLED: %s" text))) | |
426 | |
427 (defun rcirc-handler-generic (process command sender args text) | |
428 "Generic server response handler." | |
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 | 431 |
432 (defun rcirc-send-string (process string) | |
433 "Send PROCESS a STRING plus a newline." | |
434 (let ((string (concat (encode-coding-string string | |
435 buffer-file-coding-system) | |
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 | 438 (process-send-string process string))) |
439 | |
440 (defun rcirc-server (process) | |
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 | 443 rcirc-server)) |
444 | |
445 (defun rcirc-nick (process) | |
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 | 448 rcirc-nick)) |
449 | |
450 (defvar rcirc-max-message-length 450 | |
451 "Messages longer than this value will be split.") | |
452 | |
453 (defun rcirc-send-message (process target message &optional noticep) | |
454 "Send TARGET associated with PROCESS a privmsg with text MESSAGE. | |
455 If NOTICEP is non-nil, send a notice instead of privmsg." | |
456 ;; max message length is 512 including CRLF | |
457 (let* ((response (if noticep "NOTICE" "PRIVMSG")) | |
458 (oversize (> (length message) rcirc-max-message-length)) | |
459 (text (if oversize | |
460 (substring message 0 rcirc-max-message-length) | |
461 message)) | |
462 (text (if (string= text "") | |
463 " " | |
464 text)) | |
465 (more (if oversize | |
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 | 470 (rcirc-send-string process (concat response " " target " :" text)) |
471 (if more | |
472 (rcirc-send-message process target more noticep)))) | |
473 | |
474 (defvar rcirc-input-ring nil) | |
475 (defvar rcirc-input-ring-index 0) | |
476 (defun rcirc-prev-input-string (arg) | |
477 (ring-ref rcirc-input-ring (+ rcirc-input-ring-index arg))) | |
478 | |
479 (defun rcirc-insert-prev-input (arg) | |
480 (interactive "p") | |
481 (when (<= rcirc-prompt-end-marker (point)) | |
482 (delete-region rcirc-prompt-end-marker (point-max)) | |
483 (insert (rcirc-prev-input-string 0)) | |
484 (setq rcirc-input-ring-index (1+ rcirc-input-ring-index)))) | |
485 | |
486 (defun rcirc-insert-next-input (arg) | |
487 (interactive "p") | |
488 (when (<= rcirc-prompt-end-marker (point)) | |
489 (delete-region rcirc-prompt-end-marker (point-max)) | |
490 (setq rcirc-input-ring-index (1- rcirc-input-ring-index)) | |
491 (insert (rcirc-prev-input-string -1)))) | |
492 | |
493 (defvar rcirc-nick-completions nil) | |
494 (defvar rcirc-nick-completion-start-offset nil) | |
495 (defun rcirc-complete-nick () | |
496 "Cycle through nick completions from list of nicks in channel." | |
497 (interactive) | |
498 (if (eq last-command 'rcirc-complete-nick) | |
499 (setq rcirc-nick-completions | |
500 (append (cdr rcirc-nick-completions) | |
501 (list (car rcirc-nick-completions)))) | |
502 (setq rcirc-nick-completion-start-offset | |
503 (- (save-excursion | |
504 (if (re-search-backward " " rcirc-prompt-end-marker t) | |
505 (1+ (point)) | |
506 rcirc-prompt-end-marker)) | |
507 rcirc-prompt-end-marker)) | |
508 (setq rcirc-nick-completions | |
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 | 512 (+ rcirc-prompt-end-marker |
513 rcirc-nick-completion-start-offset) | |
514 (point)) | |
515 (mapcar (lambda (x) (cons x nil)) | |
516 (rcirc-channel-nicks rcirc-process | |
517 (rcirc-buffer-target))))))) | |
518 (let ((completion (car rcirc-nick-completions))) | |
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 | 521 rcirc-nick-completion-start-offset) |
522 (point)) | |
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 | 525 rcirc-nick-completion-start-offset) |
526 rcirc-prompt-end-marker) | |
527 ": ")))))) | |
528 | |
529 (defun rcirc-buffer-target (&optional buffer) | |
530 "Return the name of target for BUFFER. | |
531 If buffer is nil, return the target of the current buffer." | |
532 (with-current-buffer (or buffer (current-buffer)) | |
533 rcirc-target)) | |
534 | |
535 (defvar rcirc-mode-map (make-sparse-keymap) | |
536 "Keymap for rcirc mode.") | |
537 | |
538 (define-key rcirc-mode-map (kbd "RET") 'rcirc-send-input) | |
539 (define-key rcirc-mode-map (kbd "M-p") 'rcirc-insert-prev-input) | |
540 (define-key rcirc-mode-map (kbd "M-n") 'rcirc-insert-next-input) | |
541 (define-key rcirc-mode-map (kbd "TAB") 'rcirc-complete-nick) | |
542 (define-key rcirc-mode-map (kbd "C-c C-b") 'rcirc-browse-url) | |
543 (define-key rcirc-mode-map (kbd "C-c C-c") 'rcirc-edit-multiline) | |
544 (define-key rcirc-mode-map (kbd "C-c C-j") 'rcirc-cmd-join) | |
545 (define-key rcirc-mode-map (kbd "C-c C-k") 'rcirc-cmd-kick) | |
546 (define-key rcirc-mode-map (kbd "C-c C-l") 'rcirc-cmd-list) | |
547 (define-key rcirc-mode-map (kbd "C-c C-d") 'rcirc-cmd-mode) | |
548 (define-key rcirc-mode-map (kbd "C-c C-m") 'rcirc-cmd-msg) | |
549 (define-key rcirc-mode-map (kbd "C-c C-r") 'rcirc-cmd-nick) ; rename | |
550 (define-key rcirc-mode-map (kbd "C-c C-o") 'rcirc-cmd-oper) | |
551 (define-key rcirc-mode-map (kbd "C-c C-p") 'rcirc-cmd-part) | |
552 (define-key rcirc-mode-map (kbd "C-c C-q") 'rcirc-cmd-query) | |
553 (define-key rcirc-mode-map (kbd "C-c C-t") 'rcirc-cmd-topic) | |
554 (define-key rcirc-mode-map (kbd "C-c C-n") 'rcirc-cmd-names) | |
555 (define-key rcirc-mode-map (kbd "C-c C-w") 'rcirc-cmd-whois) | |
556 (define-key rcirc-mode-map (kbd "C-c C-x") 'rcirc-cmd-quit) | |
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 | 559 (define-key rcirc-mode-map (kbd "C-c C-s") 'rcirc-switch-to-server-buffer) |
560 (define-key rcirc-mode-map (kbd "C-c C-a") 'rcirc-jump-to-first-unread-line) | |
561 | |
562 (define-key global-map (kbd "C-c `") 'rcirc-next-active-buffer) | |
563 (define-key global-map (kbd "C-c C-@") 'rcirc-next-active-buffer) | |
564 (define-key global-map (kbd "C-c C-SPC") 'rcirc-next-active-buffer) | |
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 | 575 (defvar rcirc-mode-hook nil |
576 "Hook run when setting up rcirc buffer.") | |
577 | |
578 (defun rcirc-mode (process target) | |
579 "Major mode for irc channel buffers. | |
580 | |
581 \\{rcirc-mode-map}" | |
582 (kill-all-local-variables) | |
583 (use-local-map rcirc-mode-map) | |
584 (setq mode-name "rcirc") | |
585 (setq major-mode 'rcirc-mode) | |
586 | |
587 (make-local-variable 'rcirc-input-ring) | |
588 (setq rcirc-input-ring (make-ring rcirc-input-ring-size)) | |
589 (make-local-variable 'rcirc-process) | |
590 (setq rcirc-process process) | |
591 (make-local-variable 'rcirc-target) | |
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 | 598 (make-local-variable 'rcirc-urls) |
599 (setq rcirc-urls nil) | |
600 (setq use-hard-newlines t) | |
601 | |
602 ;; setup the prompt and markers | |
603 (make-local-variable 'rcirc-prompt-start-marker) | |
604 (setq rcirc-prompt-start-marker (make-marker)) | |
605 (set-marker rcirc-prompt-start-marker (point-max)) | |
606 (make-local-variable 'rcirc-prompt-end-marker) | |
607 (setq rcirc-prompt-end-marker (make-marker)) | |
608 (set-marker rcirc-prompt-end-marker (point-max)) | |
609 (rcirc-update-prompt) | |
610 (goto-char rcirc-prompt-end-marker) | |
611 (make-local-variable 'overlay-arrow-position) | |
612 (setq overlay-arrow-position (make-marker)) | |
613 (set-marker overlay-arrow-position nil) | |
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 | 623 (run-hooks 'rcirc-mode-hook)) |
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 | 668 |
669 (defun rcirc-channel-p (target) | |
670 "Return t if TARGET is a channel name." | |
671 (and target | |
672 (not (zerop (length target))) | |
673 (or (eq (aref target 0) ?#) | |
674 (eq (aref target 0) ?&)))) | |
675 | |
676 (defun rcirc-kill-buffer-hook () | |
677 "Part the channel when killing an rcirc buffer." | |
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 | 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 | 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 | 698 (add-hook 'kill-buffer-hook 'rcirc-kill-buffer-hook) |
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 | 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 | 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 | 719 |
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 | 733 |
734 (defun rcirc-send-input () | |
735 "Send input to target associated with the current buffer." | |
736 (interactive) | |
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 | 739 (process-name rcirc-process)) |
740 (if (< (point) rcirc-prompt-end-marker) | |
741 ;; copy the line down to the input area | |
742 (progn | |
743 (forward-line 0) | |
744 (let ((start (if (eq (point) (point-min)) | |
745 (point) | |
746 (if (get-text-property (1- (point)) 'hard) | |
747 (point) | |
748 (previous-single-property-change (point) 'hard)))) | |
749 (end (next-single-property-change (1+ (point)) 'hard))) | |
750 (goto-char (point-max)) | |
751 (insert (replace-regexp-in-string | |
752 "\n\\s-+" " " | |
753 (buffer-substring-no-properties start end))))) | |
754 ;; process input | |
755 (goto-char (point-max)) | |
756 (let ((target (rcirc-buffer-target)) | |
757 (start rcirc-prompt-end-marker)) | |
758 (when (not (equal 0 (- (point) start))) | |
759 ;; delete a trailing newline | |
760 (when (eq (point) (point-at-bol)) | |
761 (delete-backward-char 1)) | |
762 (let ((input (buffer-substring-no-properties | |
763 rcirc-prompt-end-marker (point)))) | |
764 ;; process a /cmd | |
765 (if (string-match "^/\\([^ ]+\\) ?\\(.*\\)$" input) | |
766 (let* ((command (match-string 1 input)) | |
767 (fun (intern-soft (concat "rcirc-cmd-" command))) | |
768 (args (match-string 2 input))) | |
769 (newline) | |
770 (with-current-buffer (current-buffer) | |
771 (delete-region rcirc-prompt-end-marker (point)) | |
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 | 777 (set-marker rcirc-prompt-end-marker (point)) |
778 (if (fboundp fun) | |
779 (funcall fun args rcirc-process target) | |
780 (rcirc-send-string rcirc-process | |
781 (concat command " " args))))) | |
782 ;; send message to server | |
783 (if (not rcirc-target) | |
784 (message "Not joined") | |
785 (delete-region rcirc-prompt-end-marker (point)) | |
786 (mapc (lambda (message) | |
787 (rcirc-send-message rcirc-process target message)) | |
788 (split-string input "\n")))) | |
789 ;; add to input-ring | |
790 (save-excursion | |
791 (ring-insert rcirc-input-ring input) | |
792 (setq rcirc-input-ring-index 0)))))))) | |
793 | |
794 (defvar rcirc-parent-buffer nil) | |
795 (defvar rcirc-window-configuration nil) | |
796 (defun rcirc-edit-multiline () | |
797 "Move current edit to a dedicated buffer." | |
798 (interactive) | |
799 (let ((pos (1+ (- (point) rcirc-prompt-end-marker)))) | |
800 (goto-char (point-max)) | |
801 (let ((text (buffer-substring rcirc-prompt-end-marker (point))) | |
802 (parent (buffer-name)) | |
803 (process rcirc-process)) | |
804 (delete-region rcirc-prompt-end-marker (point)) | |
805 (setq rcirc-window-configuration (current-window-configuration)) | |
806 (pop-to-buffer (concat "*multiline " parent "*")) | |
807 (rcirc-multiline-edit-mode) | |
808 (setq rcirc-parent-buffer parent) | |
809 (setq rcirc-process process) | |
810 (insert text) | |
811 (and (> pos 0) (goto-char pos))))) | |
812 | |
813 (define-derived-mode rcirc-multiline-edit-mode | |
814 text-mode "rcirc multi" | |
815 "Major mode for multiline edits | |
816 \\{rcirc-multiline-edit-mode-map}" | |
817 (make-local-variable 'rcirc-parent-buffer) | |
818 (make-local-variable 'rcirc-process)) | |
819 | |
820 (define-key rcirc-multiline-edit-mode-map | |
821 (kbd "C-c C-c") 'rcirc-multiline-edit-submit) | |
822 (define-key rcirc-multiline-edit-mode-map | |
823 (kbd "C-x C-s") 'rcirc-multiline-edit-submit) | |
824 (define-key rcirc-multiline-edit-mode-map | |
825 (kbd "C-c C-k") 'rcirc-multiline-edit-cancel) | |
826 (define-key rcirc-multiline-edit-mode-map | |
827 (kbd "ESC ESC ESC") 'rcirc-multiline-edit-cancel) | |
828 | |
829 (defun rcirc-multiline-edit-submit () | |
830 "Send the text in buffer back to parent buffer." | |
831 (interactive) | |
832 (assert (and (eq major-mode 'rcirc-multiline-edit-mode))) | |
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 | 835 (let ((text (buffer-substring (point-min) (point-max))) |
836 (buffer (current-buffer)) | |
837 (pos (point))) | |
838 (set-buffer rcirc-parent-buffer) | |
839 (goto-char (point-max)) | |
840 (insert text) | |
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 | 844 |
845 (defun rcirc-multiline-edit-cancel () | |
846 "Cancel the multiline edit." | |
847 (interactive) | |
848 (assert (and (eq major-mode 'rcirc-multiline-edit-mode))) | |
849 (kill-buffer (current-buffer)) | |
850 (set-window-configuration rcirc-window-configuration)) | |
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 | 861 |
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 | 865 (cond ((or (string= response "PRIVMSG") |
866 (string= response "NOTICE") | |
867 (string= response "ACTION")) | |
868 (let (first middle end) | |
869 (cond ((string= response "PRIVMSG") | |
870 (setq first "<" middle "> ")) | |
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 | 874 (t |
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 | 877 (rcirc-facify (rcirc-user-nick sender) |
878 (if (string= sender | |
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 | 882 middle |
883 (rcirc-mangle-text process text) | |
884 end))) | |
885 ((string= response "COMMAND") | |
886 text) | |
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 | 890 (t |
891 (rcirc-mangle-text | |
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 | 902 |
903 (defvar rcirc-activity-type nil) | |
904 (make-variable-buffer-local 'rcirc-activity-type) | |
905 (defun rcirc-print (process sender response target text &optional activity) | |
906 "Print TEXT in the buffer associated with TARGET. | |
907 Format based on SENDER and RESPONSE. If ACTIVITY is non-nil, | |
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 | 910 target) |
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 | 918 (inhibit-read-only t)) |
919 (with-current-buffer buffer | |
920 (let ((moving (= (point) rcirc-prompt-end-marker)) | |
921 (old-point (point-marker)) | |
922 (fill-start (marker-position rcirc-prompt-start-marker))) | |
923 | |
924 (unless (string= sender (rcirc-nick process)) | |
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 | 928 ;; mark the line with overlay arrow |
929 (unless (or (marker-position overlay-arrow-position) | |
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 | 932 (marker-position rcirc-prompt-start-marker)))) |
933 | |
934 ;; temporarily set the marker insertion-type because | |
935 ;; insert-before-markers results in hidden text in new buffers | |
936 (goto-char rcirc-prompt-start-marker) | |
937 (set-marker-insertion-type rcirc-prompt-start-marker t) | |
938 (set-marker-insertion-type rcirc-prompt-end-marker t) | |
939 (insert | |
940 (rcirc-format-response-string process sender response target text) | |
941 (propertize "\n" 'hard t)) | |
942 (set-marker-insertion-type rcirc-prompt-start-marker nil) | |
943 (set-marker-insertion-type rcirc-prompt-end-marker nil) | |
944 | |
945 ;; fill the text we just inserted, maybe | |
946 (when (and rcirc-fill-flag | |
947 (not (string= response "372"))) ;/motd | |
948 (let ((fill-prefix | |
949 (or rcirc-fill-prefix | |
950 (make-string | |
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 | 953 rcirc-time-format)) |
954 0) | |
955 (cond ((or (string= response "PRIVMSG") | |
956 (string= response "NOTICE")) | |
957 (+ (length (rcirc-user-nick sender)) | |
958 2)) ; <> | |
959 ((string= response "ACTION") | |
960 (+ (length (rcirc-user-nick sender)) | |
961 1)) ; [ | |
962 (t 3)) ; *** | |
963 1) | |
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 | 970 (fill-region fill-start rcirc-prompt-start-marker 'left t))) |
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 | 980 ;; truncate buffer if it is very long |
981 (save-excursion | |
982 (when (and rcirc-buffer-maximum-lines | |
983 (> rcirc-buffer-maximum-lines 0) | |
984 (= (forward-line (- rcirc-buffer-maximum-lines)) 0)) | |
985 (delete-region (point-min) (point)))) | |
986 | |
987 ;; set the window point for buffers show in windows | |
988 (walk-windows (lambda (w) | |
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 | 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 | 993 rcirc-prompt-end-marker)) |
994 (set-window-point w (point-max))))) | |
995 nil t) | |
996 | |
997 ;; restore the point | |
998 (goto-char (if moving rcirc-prompt-end-marker old-point)) | |
999 | |
1000 ;; flush undo (can we do something smarter here?) | |
1001 (buffer-disable-undo) | |
1002 (buffer-enable-undo)) | |
1003 | |
1004 ;; record modeline activity | |
1005 (when activity | |
1006 (let ((nick-match | |
1007 (string-match (concat "\\b" | |
1008 (regexp-quote (rcirc-nick process)) | |
1009 "\\b") | |
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 | 1012 ;; always notice when our nick is mentioned, even |
1013 ;; if ignoring channel activity | |
1014 nick-match) | |
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 | 1017 (when (or nick-match (not (rcirc-channel-p rcirc-target))) |
1018 'nick))))) | |
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 | 1021 (run-hook-with-args 'rcirc-print-hooks |
1022 process sender response target text)))) | |
1023 | |
1024 (defun rcirc-startup-channels (server) | |
1025 "Return the list of startup channels for server." | |
1026 (let (channels) | |
1027 (dolist (i rcirc-startup-channels-alist) | |
1028 (if (string-match (car i) server) | |
1029 (setq channels (append channels (cdr i))))) | |
1030 channels)) | |
1031 | |
1032 (defun rcirc-join-channels (process channels) | |
1033 "Join CHANNELS." | |
1034 (save-window-excursion | |
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 | 1037 (rcirc-cmd-join channel process))) |
1038 channels))) | |
1039 | |
1040 ;;; nick management | |
1041 (defun rcirc-user-nick (user) | |
1042 "Return the nick from USER. Remove any non-nick junk." | |
1043 (if (string-match "^[@%+]?\\([^! ]+\\)!?" (or user "")) | |
1044 (match-string 1 user) | |
1045 user)) | |
1046 | |
1047 (defun rcirc-user-non-nick (user) | |
1048 "Return the non-nick portion of USER." | |
1049 (if (string-match "^[@+]?[^! ]+!?\\(.*\\)" (or user "")) | |
1050 (match-string 1 user) | |
1051 user)) | |
1052 | |
1053 (defun rcirc-nick-channels (process nick) | |
1054 "Return list of channels for NICK." | |
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 | 1057 (mapcar (lambda (x) (car x)) |
1058 (gethash nick rcirc-nick-table))))) | |
1059 | |
1060 (defun rcirc-put-nick-channel (process nick channel) | |
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 | 1063 (let* ((nick (rcirc-user-nick nick)) |
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 | 1066 (if record |
1067 (setcdr record (current-time)) | |
1068 (puthash nick (cons (cons channel (current-time)) | |
1069 chans) | |
1070 rcirc-nick-table))))) | |
1071 | |
1072 (defun rcirc-nick-remove (process nick) | |
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 | 1075 (remhash nick rcirc-nick-table))) |
1076 | |
1077 (defun rcirc-remove-nick-channel (process nick channel) | |
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 | 1080 (let* ((nick (rcirc-user-nick nick)) |
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 | 1088 (if newchans |
1089 (puthash nick newchans rcirc-nick-table) | |
1090 (remhash nick rcirc-nick-table))))) | |
1091 | |
1092 (defun rcirc-channel-nicks (process channel) | |
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 | 1095 (let (nicks) |
1096 (maphash | |
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 | 1099 (if record |
1100 (setq nicks (cons (cons k (cdr record)) nicks))))) | |
1101 rcirc-nick-table) | |
1102 (mapcar (lambda (x) (car x)) | |
1103 (sort nicks (lambda (x y) (time-less-p (cdr y) (cdr x)))))))) | |
1104 | |
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 | 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 | 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 | 1112 If ALL is non-nil, instead toggle the value of |
1113 `rcirc-ignore-all-activity-flag'." | |
1114 (interactive "P") | |
1115 (if all | |
1116 (progn | |
1117 (setq rcirc-ignore-all-activity-flag | |
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 | 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 | 1128 (force-mode-line-update)) |
1129 | |
1130 (defvar rcirc-switch-to-buffer-function 'switch-to-buffer | |
1131 "Function to use when switching buffers. | |
1132 Possible values are `switch-to-buffer', `pop-to-buffer', and | |
1133 `display-buffer'.") | |
1134 | |
1135 (defun rcirc-switch-to-server-buffer () | |
1136 "Switch to the server buffer associated with current channel buffer." | |
1137 (interactive) | |
1138 (funcall rcirc-switch-to-buffer-function (process-buffer rcirc-process))) | |
1139 | |
1140 (defun rcirc-jump-to-first-unread-line () | |
1141 "Move the point to the first unread line in this buffer." | |
1142 (interactive) | |
1143 (when (marker-position overlay-arrow-position) | |
1144 (goto-char overlay-arrow-position))) | |
1145 | |
1146 (defvar rcirc-last-non-irc-buffer nil | |
1147 "The buffer to switch to when there is no more activity.") | |
1148 | |
1149 (defun rcirc-next-active-buffer (arg) | |
1150 "Go to the ARGth rcirc buffer with activity. | |
1151 The function given by `rcirc-switch-to-buffer-function' is used to | |
1152 show the buffer." | |
1153 (interactive "p") | |
1154 (if rcirc-activity | |
1155 (progn | |
1156 (unless (eq major-mode 'rcirc-mode) | |
1157 (setq rcirc-last-non-irc-buffer (current-buffer))) | |
1158 (if (and (> arg 0) | |
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 | 1161 (nth (1- arg) rcirc-activity)) |
1162 (message "Invalid arg: %d" arg))) | |
1163 (if (eq major-mode 'rcirc-mode) | |
1164 (if (not (and rcirc-last-non-irc-buffer | |
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 | 1168 (funcall rcirc-switch-to-buffer-function rcirc-last-non-irc-buffer) |
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 | 1171 |
1172 (defvar rcirc-activity-hooks nil | |
1173 "Hook to be run when there is channel activity. | |
1174 | |
1175 Functions are called with a single argument, the buffer with the | |
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 | 1178 |
1179 (defun rcirc-record-activity (buffer type) | |
1180 "Record BUFFER activity with TYPE." | |
1181 (with-current-buffer buffer | |
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 | 1184 (if (not rcirc-activity-type) |
1185 (setq rcirc-activity-type type)) | |
1186 (rcirc-update-activity-string))) | |
1187 (run-hook-with-args 'rcirc-activity-hooks buffer)) | |
1188 | |
1189 (defun rcirc-clear-activity (buffer) | |
1190 "Clear the BUFFER activity." | |
1191 (setq rcirc-activity (delete buffer rcirc-activity)) | |
1192 (with-current-buffer buffer | |
1193 (setq rcirc-activity-type nil))) | |
1194 | |
66703
6cfb275aa300
Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents:
66272
diff
changeset
|
1195 ;; TODO: add mouse properties |
66248 | 1196 (defun rcirc-update-activity-string () |
1197 "Update mode-line string." | |
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 | 1206 (lambda (b) |
1207 (let ((s (rcirc-short-buffer-name b))) | |
1208 (with-current-buffer b | |
1209 (if (not (eq rcirc-activity-type 'nick)) | |
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 | 1214 |
1215 (defun rcirc-short-buffer-name (buffer) | |
1216 "Return a short name for BUFFER to use in the modeline indicator." | |
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 | 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 | 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 | 1298 |
1299 ;;; /commands these are called with 3 args: PROCESS, TARGET, which is | |
1300 ;; the current buffer/channel/user, and ARGS, which is a string | |
1301 ;; containing the text following the /cmd. | |
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 | 1304 &rest body) |
1305 "Define a command." | |
1306 `(defun ,(intern (concat "rcirc-cmd-" (symbol-name command))) | |
1307 (,@argument &optional process target) | |
1308 ,(concat docstring "\n\nNote: If PROCESS or TARGET are nil, the values of" | |
1309 "\nbuffer local variables `rcirc-process' and `rcirc-target'," | |
1310 "\nwill be used.") | |
1311 ,interactive-form | |
1312 (let ((process (or process rcirc-process)) | |
1313 (target (or target rcirc-target))) | |
1314 ,@body))) | |
1315 | |
1316 (defun-rcirc-command msg (message) | |
1317 "Send private MESSAGE to TARGET." | |
1318 (interactive "i") | |
1319 (if (null message) | |
1320 (progn | |
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 | 1323 rcirc-nick-table))) |
1324 (when (> (length target) 0) | |
1325 (setq message (read-string (format "Message %s: " target))) | |
1326 (when (> (length message) 0) | |
1327 (rcirc-send-message process target message)))) | |
1328 (if (not (string-match "\\([^ ]+\\) \\(.+\\)" message)) | |
1329 (message "Not enough args, or something.") | |
1330 (setq target (match-string 1 message) | |
1331 message (match-string 2 message)) | |
1332 (rcirc-send-message process target message)))) | |
1333 | |
1334 (defun-rcirc-command query (nick) | |
1335 "Open a private chat buffer to NICK." | |
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 | 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 | 1343 (rcirc-cmd-whois nick)))) |
1344 | |
1345 (defun-rcirc-command join (args) | |
1346 "Join CHANNEL." | |
1347 (interactive "sJoin channel: ") | |
1348 (let* ((channel (car (split-string args))) | |
1349 (buffer (rcirc-get-buffer-create process channel))) | |
1350 (when (not (eq (selected-window) (minibuffer-window))) | |
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 | 1353 |
1354 (defun-rcirc-command part (channel) | |
1355 "Part CHANNEL." | |
1356 (interactive "sPart channel: ") | |
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 | 1359 |
1360 (defun-rcirc-command quit (reason) | |
1361 "Send a quit message to server with REASON." | |
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 | 1367 |
1368 (defun-rcirc-command nick (nick) | |
1369 "Change nick to NICK." | |
1370 (interactive "i") | |
1371 (when (null nick) | |
1372 (setq nick (read-string "New nick: " (rcirc-nick process)))) | |
1373 (rcirc-send-string process (concat "NICK " nick))) | |
1374 | |
1375 (defun-rcirc-command names (channel) | |
1376 "Display list of names in CHANNEL or in current channel if CHANNEL is nil. | |
1377 If called interactively, prompt for a channel when prefix arg is supplied." | |
1378 (interactive "P") | |
1379 (if (interactive-p) | |
1380 (if channel | |
1381 (setq channel (read-string "List names in channel: " target)))) | |
1382 (let ((channel (if (> (length channel) 0) | |
1383 channel | |
1384 target))) | |
1385 (rcirc-send-string process (concat "NAMES " channel)))) | |
1386 | |
1387 (defun-rcirc-command topic (topic) | |
1388 "List TOPIC for the TARGET channel. | |
1389 With a prefix arg, prompt for new topic." | |
1390 (interactive "P") | |
1391 (if (and (interactive-p) topic) | |
1392 (setq topic (read-string "New Topic: " rcirc-topic))) | |
1393 (rcirc-send-string process (concat "TOPIC " target | |
1394 (when (> (length topic) 0) | |
1395 (concat " :" topic))))) | |
1396 | |
1397 (defun-rcirc-command whois (nick) | |
1398 "Request information from server about NICK." | |
1399 (interactive (list | |
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 | 1402 rcirc-nick-table)))) |
1403 (rcirc-send-string process (concat "WHOIS " nick))) | |
1404 | |
1405 (defun-rcirc-command mode (args) | |
1406 "Set mode with ARGS." | |
1407 (interactive (list (concat (read-string "Mode nick or channel: ") | |
1408 " " (read-string "Mode: ")))) | |
1409 (rcirc-send-string process (concat "MODE " args))) | |
1410 | |
1411 (defun-rcirc-command list (channels) | |
1412 "Request information on CHANNELS from server." | |
1413 (interactive "sList Channels: ") | |
1414 (rcirc-send-string process (concat "LIST " channels))) | |
1415 | |
1416 (defun-rcirc-command oper (args) | |
1417 "Send operator command to server." | |
1418 (interactive "sOper args: ") | |
1419 (rcirc-send-string process (concat "OPER " args))) | |
1420 | |
1421 (defun-rcirc-command quote (message) | |
1422 "Send MESSAGE literally to server." | |
1423 (interactive "sServer message: ") | |
1424 (rcirc-send-string process message)) | |
1425 | |
1426 (defun-rcirc-command kick (arg) | |
1427 "Kick NICK from current channel." | |
1428 (interactive (list | |
1429 (concat (completing-read "Kick nick: " | |
1430 (rcirc-channel-nicks rcirc-process | |
1431 rcirc-target)) | |
1432 (read-from-minibuffer "Kick reason: ")))) | |
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 | 1435 (mapconcat 'identity (cdr arglist) " ")))) |
1436 (rcirc-send-string process (concat "KICK " target " " argstring)))) | |
1437 | |
1438 (defun rcirc-cmd-ctcp (args &optional process target) | |
1439 (if (string-match "^\\([^ ]+\\)\\s-+\\(.+\\)$" args) | |
1440 (let ((target (match-string 1 args)) | |
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 | 1446 "usage: /ctcp NICK REQUEST"))) |
1447 | |
1448 (defun rcirc-cmd-me (args &optional process target) | |
1449 (rcirc-send-string process (format "PRIVMSG %s :\C-aACTION %s\C-a" | |
1450 target args))) | |
1451 | |
1452 (defun rcirc-message-leader (sender face) | |
1453 "Return a string with SENDER propertized with FACE." | |
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 | 1456 (defun rcirc-facify (string face) |
1457 "Return a copy of STRING with FACE property added." | |
1458 (propertize (or string "") 'face face 'rear-nonsticky t)) | |
1459 | |
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 | 1470 "Regexp matching URL's. Set to nil to disable URL features in rcirc.") |
1471 | |
1472 (defun rcirc-browse-url (&optional arg) | |
1473 "Prompt for url to browse based on urls in buffer." | |
1474 (interactive) | |
1475 (let ((completions (mapcar (lambda (x) (cons x nil)) rcirc-urls)) | |
1476 (initial-input (car rcirc-urls)) | |
1477 (history (cdr rcirc-urls))) | |
1478 (browse-url (completing-read "rcirc browse-url: " | |
1479 completions nil nil initial-input 'history) | |
1480 arg))) | |
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 | 1496 (defun rcirc-map-regexp (function regexp string) |
1497 "Return a copy of STRING after calling FUNCTION for each REGEXP match. | |
1498 FUNCTION takes 3 arguments, MATCH-START, MATCH-END, and STRING." | |
1499 (let ((start 0)) | |
1500 (while (string-match regexp string start) | |
1501 (setq start (match-end 0)) | |
1502 (funcall function (match-beginning 0) (match-end 0) string))) | |
1503 string) | |
1504 | |
1505 (defvar rcirc-nick-syntax-table | |
1506 (let ((table (make-syntax-table text-mode-syntax-table))) | |
1507 (mapc (lambda (c) (modify-syntax-entry c "w" table)) | |
1508 "[]\\`_^{|}-") | |
1509 (modify-syntax-entry ?' "_" table) | |
1510 table) | |
1511 "Syntax table which includes all nick characters as word constituents.") | |
1512 | |
1513 (defun rcirc-mangle-text (process text) | |
1514 "Return TEXT with properties added based on various patterns." | |
1515 ;; ^B | |
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 | 1532 (setq text (concat (match-string 1 text) |
1533 (match-string 2 text)))) | |
1534 ;; my nick | |
1535 (setq text | |
1536 (with-syntax-table rcirc-nick-syntax-table | |
1537 (rcirc-map-regexp (lambda (start end string) | |
1538 (add-text-properties | |
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 | 1541 'rear-nonsticky t) |
1542 string)) | |
1543 (concat "\\b" | |
1544 (regexp-quote (rcirc-nick process)) | |
1545 "\\b") | |
1546 text))) | |
1547 ;; urls | |
1548 (setq text | |
1549 (rcirc-map-regexp | |
1550 (lambda (start end string) | |
1551 (let ((orig-face (get-text-property start 'face string))) | |
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 | 1560 string)) |
1561 (push (substring string start end) rcirc-urls)) | |
1562 rcirc-url-regexp | |
1563 text)) | |
1564 text) | |
1565 | |
1566 | |
1567 ;;; handlers | |
1568 ;; these are called with the server PROCESS, the SENDER, which is a | |
1569 ;; server or a user, depending on the command, the ARGS, which is a | |
1570 ;; list of strings, and the TEXT, which is the original server text, | |
1571 ;; verbatim | |
1572 (defun rcirc-handler-001 (process sender args text) | |
1573 (rcirc-handler-generic process "001" sender args text) | |
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 | 1576 (setq rcirc-server sender) |
1577 (setq rcirc-nick (car args)) | |
1578 (rcirc-update-prompt) | |
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 | 1581 |
1582 (defun rcirc-handler-PRIVMSG (process sender args text) | |
1583 (let ((target (if (rcirc-channel-p (car args)) | |
1584 (car args) | |
1585 (rcirc-user-nick sender))) | |
1586 (message (or (cadr args) ""))) | |
1587 (if (string-match "^\C-a\\(.*\\)\C-a$" message) | |
1588 (rcirc-handler-CTCP process target sender (match-string 1 message)) | |
1589 (rcirc-print process sender "PRIVMSG" target message t)) | |
1590 ;; update nick timestamp | |
1591 (if (member target (rcirc-nick-channels process sender)) | |
1592 (rcirc-put-nick-channel process sender target)))) | |
1593 | |
1594 (defun rcirc-handler-NOTICE (process sender args text) | |
1595 (let ((target (car args)) | |
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 | 1613 |
1614 (defun rcirc-handler-WALLOPS (process sender args text) | |
1615 (let ((target (rcirc-user-nick sender))) | |
1616 (rcirc-print process sender "WALLOPS" target (car args) t))) | |
1617 | |
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 | 1620 (nick (rcirc-user-nick sender))) |
1621 (rcirc-get-buffer-create process channel) | |
1622 (rcirc-print process sender "JOIN" channel "") | |
1623 | |
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 | 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 | 1629 |
1630 ;; PART and KICK are handled the same way | |
1631 (defun rcirc-handler-PART-or-KICK (process response channel sender nick args) | |
1632 (rcirc-print process sender response channel (concat channel " " args)) | |
1633 | |
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 | 1636 (rcirc-print process sender response nick (concat channel " " args))) |
1637 | |
1638 (if (not (string= nick (rcirc-nick process))) | |
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 | 1651 |
1652 (defun rcirc-handler-PART (process sender args text) | |
1653 (rcirc-handler-PART-or-KICK process "PART" | |
1654 (car args) sender (rcirc-user-nick sender) | |
1655 (cadr args))) | |
1656 | |
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 | 1659 (caddr args))) |
1660 | |
1661 (defun rcirc-handler-QUIT (process sender args text) | |
1662 (let ((nick (rcirc-user-nick sender))) | |
1663 (mapc (lambda (channel) | |
1664 (rcirc-print process sender "QUIT" channel (apply 'concat args))) | |
1665 (rcirc-nick-channels process nick)) | |
1666 | |
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 | 1671 |
1672 (rcirc-nick-remove process nick))) | |
1673 | |
1674 (defun rcirc-handler-NICK (process sender args text) | |
1675 (let* ((old-nick (rcirc-user-nick sender)) | |
1676 (new-nick (car args)) | |
1677 (channels (rcirc-nick-channels process old-nick))) | |
1678 ;; print message to nick's channels | |
1679 (dolist (target channels) | |
1680 (rcirc-print process sender "NICK" target new-nick)) | |
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 | 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 | 1690 (let ((v (gethash old-nick rcirc-nick-table))) |
1691 (remhash old-nick rcirc-nick-table) | |
1692 (puthash new-nick v rcirc-nick-table)) | |
1693 ;; if this is our nick... | |
1694 (when (string= old-nick rcirc-nick) | |
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 | 1697 ;; reauthenticate |
1698 (when rcirc-auto-authenticate-flag (rcirc-authenticate)))))) | |
1699 | |
1700 (defun rcirc-handler-PING (process sender args text) | |
1701 (rcirc-send-string process (concat "PONG " (car args)))) | |
1702 | |
1703 (defun rcirc-handler-PONG (process sender args text) | |
1704 ;; do nothing | |
1705 ) | |
1706 | |
1707 (defun rcirc-handler-TOPIC (process sender args text) | |
1708 (let ((topic (cadr args))) | |
1709 (rcirc-print process sender "TOPIC" (car args) topic) | |
1710 (with-current-buffer (rcirc-get-buffer process (car args)) | |
1711 (setq rcirc-topic topic)))) | |
1712 | |
1713 (defun rcirc-handler-332 (process sender args text) | |
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 | 1719 |
1720 (defun rcirc-handler-333 (process sender args text) | |
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 | 1731 |
1732 (defun rcirc-handler-477 (process sender args text) | |
1733 "ERR_NOCHANMODES" | |
1734 (rcirc-print process sender "477" (cadr args) (caddr args))) | |
1735 | |
1736 (defun rcirc-handler-MODE (process sender args text) | |
1737 (let ((target (car args)) | |
1738 (msg (mapconcat 'identity (cdr args) " "))) | |
1739 (rcirc-print process sender "MODE" | |
1740 (if (string= target (rcirc-nick process)) | |
1741 nil | |
1742 target) | |
1743 msg) | |
1744 | |
1745 ;; print in private chat buffers if they exist | |
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 | 1751 |
1752 (defun rcirc-get-temp-buffer-create (process channel) | |
1753 "Return a buffer based on PROCESS and CHANNEL." | |
1754 (let ((tmpnam (concat " " (downcase channel) "TMP" (process-name process)))) | |
1755 (get-buffer-create tmpnam))) | |
1756 | |
1757 (defun rcirc-handler-353 (process sender args text) | |
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 | 1760 (mapc (lambda (nick) |
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 | 1763 (with-current-buffer (rcirc-get-temp-buffer-create process channel) |
1764 (goto-char (point-max)) | |
1765 (insert (car (last args)) " ")))) | |
1766 | |
1767 (defun rcirc-handler-366 (process sender args text) | |
1768 "RPL_ENDOFNAMES" | |
1769 (let* ((channel (cadr args)) | |
1770 (buffer (rcirc-get-temp-buffer-create process channel))) | |
1771 (with-current-buffer buffer | |
1772 (rcirc-print process sender "NAMES" channel | |
1773 (buffer-substring (point-min) (point-max)))) | |
1774 (kill-buffer buffer))) | |
1775 | |
1776 (defun rcirc-handler-433 (process sender args text) | |
1777 "ERR_NICKNAMEINUSE" | |
1778 (rcirc-handler-generic process "433" sender args text) | |
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 | 1781 (rcirc-cmd-nick new-nick nil process)))) |
1782 | |
1783 (defun rcirc-authenticate () | |
1784 "Send authentication to process associated with current buffer. | |
1785 Passwords are read from `rcirc-authinfo-file-name' (which see)." | |
1786 (interactive) | |
1787 (let ((password-alist | |
1788 (with-temp-buffer | |
1789 (insert-file-contents-literally rcirc-authinfo-file-name) | |
1790 (goto-char (point-min)) | |
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 | 1793 (dolist (i password-alist) |
1794 (let ((server (car i)) | |
1795 (nick (cadr i)) | |
1796 (method (caddr i)) | |
1797 (args (cdddr i))) | |
1798 (when (and (string-match server rcirc-server) | |
1799 (string-match nick rcirc-nick)) | |
1800 (cond ((equal method 'nickserv) | |
1801 (rcirc-send-string | |
1802 rcirc-process | |
1803 (concat | |
66703
6cfb275aa300
Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents:
66272
diff
changeset
|
1804 "PRIVMSG nickserv :identify " |
66248 | 1805 (car args)))) |
1806 ((equal method 'chanserv) | |
1807 (rcirc-send-string | |
1808 rcirc-process | |
1809 (concat | |
66703
6cfb275aa300
Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents:
66272
diff
changeset
|
1810 "PRIVMSG chanserv :identify " |
66248 | 1811 (car args) " " (cadr args)))) |
1812 ((equal method 'bitlbee) | |
1813 (rcirc-send-string | |
1814 rcirc-process | |
1815 (concat "PRIVMSG #bitlbee :identify " (car args)))) | |
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 | 1818 method))))))))) |
66703
6cfb275aa300
Use split-string OMIT-NULLS argument.
Eli Zaretskii <eliz@gnu.org>
parents:
66272
diff
changeset
|
1819 |
66248 | 1820 (defun rcirc-handler-INVITE (process sender args text) |
1821 (rcirc-print process sender "INVITE" nil (mapconcat 'identity args " ") t)) | |
1822 | |
1823 (defun rcirc-handler-ERROR (process sender args text) | |
1824 (rcirc-print process sender "ERROR" nil (mapconcat 'identity args " "))) | |
1825 | |
1826 (defun rcirc-handler-CTCP (process target sender text) | |
1827 (if (string-match "^\\([^ ]+\\) *\\(.*\\)$" text) | |
1828 (let* ((request (upcase (match-string 1 text))) | |
1829 (args (match-string 2 text)) | |
1830 (nick (rcirc-user-nick sender)) | |
1831 (handler (intern-soft (concat "rcirc-handler-ctcp-" request)))) | |
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 | 1837 (funcall handler process target sender args) |
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 | 1842 |
1843 (defun rcirc-handler-ctcp-VERSION (process target sender args) | |
1844 (rcirc-send-string process | |
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 | 1847 "\C-a"))) |
1848 | |
1849 (defun rcirc-handler-ctcp-ACTION (process target sender args) | |
1850 (rcirc-print process sender "ACTION" target args t)) | |
1851 | |
1852 (defun rcirc-handler-ctcp-TIME (process target sender args) | |
1853 (rcirc-send-string process | |
1854 (concat "NOTICE " (rcirc-user-nick sender) | |
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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 1951 (put 'rcirc-mode 'flyspell-mode-predicate 'rcirc-looking-at-input) |
1952 (defun rcirc-looking-at-input () | |
1953 "Returns true if point is past the input marker." | |
1954 (>= (point) rcirc-prompt-end-marker)) | |
1955 | |
1956 | |
1957 (provide 'rcirc) | |
66258 | 1958 |
1959 ;; arch-tag: b471b7e8-6b5a-4399-b2c6-a3c78dfc8ffb | |
66248 | 1960 ;;; rcirc.el ends here |