diff options
| author | Eli Zaretskii | 2006-04-08 10:23:53 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2006-04-08 10:23:53 +0000 |
| commit | a2524d2695892fcb0d6aeaab6873148498efc7ba (patch) | |
| tree | bddcadb1c44f54f5a6e1dec11da2f5cf6d5c643e | |
| parent | 6716bfa4e5af380fe80ad8fb23be35af2eca06b9 (diff) | |
| download | emacs-a2524d2695892fcb0d6aeaab6873148498efc7ba.tar.gz emacs-a2524d2695892fcb0d6aeaab6873148498efc7ba.zip | |
(rcirc-default-server): Rename from rcirc-server.
(rcirc-default-port): Rename from rcirc-port.
(rcirc-default-nick): Rename from rcirc-nick.
(rcirc-default-user-name): Rename from rcirc-user-name.
(rcirc-default-user-full-name): Rename from rcirc-user-full-name.
(rcirc-low-priority-flag): New variable.
(rcirc-decode-coding-system): New defcustom.
(rcirc-encode-coding-system): New defcustom.
(rcirc-coding-system-alist): New defcustom.
(rcirc-multiline-major-mode): New defcustom.
(rcirc-nick): New internal variable.
(rcirc-process): Remove variable.
(rcirc-server-buffer): New variable.
(rcirc): Update to use rcirc-default-* variables above.
(rcirc-connect): Do not add window-configuration-hook-here.
(rcirc-server): New internal variable.
(rcirc-connect): Do not send keepalive pings if rcirc-keepalive-seconds is nil.
(with-rcirc-server-buffer): New macro.
(rcirc-send-string): Encode with rcirc-encode-coding-system.
(rcirc-server-name): Rename from rcirc-server.
(rcirc-buffer-process): New function.
(rcirc-buffer-nick): New function.
(rcirc-buffer-target): Remove function.
(set-rcirc-decode-coding-system, set-rcirc-encode-coding-system): New commands.
(rcirc-mode-map): Change binding of C-c C-l to rcirc-toggle-low-priority.
(rcirc-mode): Initialize coding system based on rcirc-coding-system-alist.
New change-major-mode-hook to part the channel on a mode change.
Make kill-buffer-hook buffer-local.
(rcirc-change-major-mode-hook): New function.
(rcirc-clean-up-buffer): Rename from rcirc-kill-buffer-hook-1.
(rcirc-last-post-time): New variable.
(rcirc-process-message): Store the last time user posted a message to this
target.
(rcirc-multiline-minor-mode): New mode.
(rcirc-multiline-minor-mode-map): New mode map.
(rcirc-edit-multiline): Put multiline-edit buffer in
rcirc-multiline-major-mode along with rcirc-multiline-minor-mode.
(rcirc-print): Any line starting with an ignored nick will be ignored.
(rcirc-print): Decode using rcirc-decode-coding-system.
(rcirc-track-minor-mode): Update global-mode-string when disabling this mode.
(minor-mode-alist): add LowPri indicator.
(rcirc-toggle-low-priority): New function.
(rcirc-last-non-irc-buffer): Prefix arg now no means switch to next low priority
buffer with activity.
(rcirc-record-activity): Sort buffers in rcirc-activity by the last time the
user posted a message in to the target.
(rcirc-update-activity-string): New formatting for low priority buffers.
(rcirc-split-activity): New function.
(rcirc-handler-PART, rcirc-handler-KICK)
(rcirc-handler-PART-or-KICK): Kick responses are printed properly.
(rcirc-nick-away-alist): New variable.
(rcirc-handler-301): New handler. Away messages are printed once per change.
| -rw-r--r-- | lisp/ChangeLog | 62 | ||||
| -rw-r--r-- | lisp/net/rcirc.el | 620 |
2 files changed, 457 insertions, 225 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 211152283e3..ae489d200d0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,65 @@ | |||
| 1 | 2006-04-08 Ryan Yeske <rcyeske@gmail.com> | ||
| 2 | |||
| 3 | * rcirc.el (rcirc-default-server): Rename from rcirc-server. | ||
| 4 | (rcirc-default-port): Rename from rcirc-port. | ||
| 5 | (rcirc-default-nick): Rename from rcirc-nick. | ||
| 6 | (rcirc-default-user-name): Rename from rcirc-user-name. | ||
| 7 | (rcirc-default-user-full-name): Rename from rcirc-user-full-name. | ||
| 8 | (rcirc-low-priority-flag): New variable. | ||
| 9 | (rcirc-decode-coding-system): New defcustom. | ||
| 10 | (rcirc-encode-coding-system): New defcustom. | ||
| 11 | (rcirc-coding-system-alist): New defcustom. | ||
| 12 | (rcirc-multiline-major-mode): New defcustom. | ||
| 13 | (rcirc-nick): New internal variable. | ||
| 14 | (rcirc-process): Remove variable. | ||
| 15 | (rcirc-server-buffer): New variable. | ||
| 16 | (rcirc): Update to use rcirc-default-* variables above. | ||
| 17 | (rcirc-connect): Do not add window-configuration-hook-here. | ||
| 18 | (rcirc-server): New internal variable. | ||
| 19 | (rcirc-connect): Do not send keepalive pings if | ||
| 20 | rcirc-keepalive-seconds is nil. | ||
| 21 | (with-rcirc-server-buffer): New macro. | ||
| 22 | (rcirc-send-string): Encode with rcirc-encode-coding-system. | ||
| 23 | (rcirc-server-name): Rename from rcirc-server. | ||
| 24 | (rcirc-buffer-process): New function. | ||
| 25 | (rcirc-buffer-nick): New function. | ||
| 26 | (rcirc-buffer-target): Remove function. | ||
| 27 | (set-rcirc-decode-coding-system, set-rcirc-encode-coding-system): | ||
| 28 | New commands. | ||
| 29 | (rcirc-mode-map): Change binding of C-c C-l to | ||
| 30 | rcirc-toggle-low-priority. | ||
| 31 | (rcirc-mode): Initialize coding system based on | ||
| 32 | rcirc-coding-system-alist. New change-major-mode-hook to part the | ||
| 33 | channel on a mode change. Make kill-buffer-hook buffer-local. | ||
| 34 | (rcirc-change-major-mode-hook): New function. | ||
| 35 | (rcirc-clean-up-buffer): Rename from rcirc-kill-buffer-hook-1. | ||
| 36 | (rcirc-last-post-time): New variable. | ||
| 37 | (rcirc-process-message): Store the last time user posted a message | ||
| 38 | to this target. | ||
| 39 | (rcirc-multiline-minor-mode): New mode. | ||
| 40 | (rcirc-multiline-minor-mode-map): New mode map. | ||
| 41 | (rcirc-edit-multiline): Put multiline-edit buffer in | ||
| 42 | rcirc-multiline-major-mode along with rcirc-multiline-minor-mode. | ||
| 43 | (rcirc-print): Any line starting with an ignored nick will be | ||
| 44 | ignored. | ||
| 45 | (rcirc-print): Decode using rcirc-decode-coding-system. | ||
| 46 | (rcirc-track-minor-mode): Update global-mode-string when disabling | ||
| 47 | this mode. | ||
| 48 | (minor-mode-alist): add LowPri indicator. | ||
| 49 | (rcirc-toggle-low-priority): New function. | ||
| 50 | (rcirc-last-non-irc-buffer): Prefix arg now no means switch to | ||
| 51 | next lowpriority buffer with activity. | ||
| 52 | (rcirc-record-activity): Sort buffers in rcirc-activity by the | ||
| 53 | last time the user posted a message in to the target. | ||
| 54 | (rcirc-update-activity-string): New formatting for low priority | ||
| 55 | buffers. | ||
| 56 | (rcirc-split-activity): New function. | ||
| 57 | (rcirc-handler-PART, rcirc-handler-KICK) | ||
| 58 | (rcirc-handler-PART-or-KICK): Kick responses are printed properly. | ||
| 59 | (rcirc-nick-away-alist): New variable. | ||
| 60 | (rcirc-handler-301): New handler. Away messages are printed once | ||
| 61 | per change. | ||
| 62 | |||
| 1 | 2006-04-08 Eli Zaretskii <eliz@gnu.org> | 63 | 2006-04-08 Eli Zaretskii <eliz@gnu.org> |
| 2 | 64 | ||
| 3 | * info.el (Info-follow-nearest-node): Doc fix. | 65 | * info.el (Info-follow-nearest-node): Doc fix. |
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 1dae0daa247..53703166e64 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el | |||
| @@ -53,27 +53,27 @@ | |||
| 53 | :link '(custom-manual "(rcirc)") | 53 | :link '(custom-manual "(rcirc)") |
| 54 | :group 'applications) | 54 | :group 'applications) |
| 55 | 55 | ||
| 56 | (defcustom rcirc-server "irc.freenode.net" | 56 | (defcustom rcirc-default-server "irc.freenode.net" |
| 57 | "The default server to connect to." | 57 | "The default server to connect to." |
| 58 | :type 'string | 58 | :type 'string |
| 59 | :group 'rcirc) | 59 | :group 'rcirc) |
| 60 | 60 | ||
| 61 | (defcustom rcirc-port 6667 | 61 | (defcustom rcirc-default-port 6667 |
| 62 | "The default port to connect to." | 62 | "The default port to connect to." |
| 63 | :type 'integer | 63 | :type 'integer |
| 64 | :group 'rcirc) | 64 | :group 'rcirc) |
| 65 | 65 | ||
| 66 | (defcustom rcirc-nick (user-login-name) | 66 | (defcustom rcirc-default-nick (user-login-name) |
| 67 | "Your nick." | 67 | "Your nick." |
| 68 | :type 'string | 68 | :type 'string |
| 69 | :group 'rcirc) | 69 | :group 'rcirc) |
| 70 | 70 | ||
| 71 | (defcustom rcirc-user-name (user-login-name) | 71 | (defcustom rcirc-default-user-name (user-login-name) |
| 72 | "Your user name sent to the server when connecting." | 72 | "Your user name sent to the server when connecting." |
| 73 | :type 'string | 73 | :type 'string |
| 74 | :group 'rcirc) | 74 | :group 'rcirc) |
| 75 | 75 | ||
| 76 | (defcustom rcirc-user-full-name (if (string= (user-full-name) "") | 76 | (defcustom rcirc-default-user-full-name (if (string= (user-full-name) "") |
| 77 | rcirc-user-name | 77 | rcirc-user-name |
| 78 | (user-full-name)) | 78 | (user-full-name)) |
| 79 | "The full name sent to the server when connecting." | 79 | "The full name sent to the server when connecting." |
| @@ -112,6 +112,10 @@ underneath each nick." | |||
| 112 | "If non-nil, ignore activity in this buffer.") | 112 | "If non-nil, ignore activity in this buffer.") |
| 113 | (make-variable-buffer-local 'rcirc-ignore-buffer-activity-flag) | 113 | (make-variable-buffer-local 'rcirc-ignore-buffer-activity-flag) |
| 114 | 114 | ||
| 115 | (defvar rcirc-low-priority-flag nil | ||
| 116 | "If non-nil, activity in this buffer is considered low priority.") | ||
| 117 | (make-variable-buffer-local 'rcirc-low-priority-flag) | ||
| 118 | |||
| 115 | (defcustom rcirc-time-format "%H:%M " | 119 | (defcustom rcirc-time-format "%H:%M " |
| 116 | "*Describes how timestamps are printed. | 120 | "*Describes how timestamps are printed. |
| 117 | Used as the first arg to `format-time-string'." | 121 | Used as the first arg to `format-time-string'." |
| @@ -213,6 +217,43 @@ Called with 5 arguments, PROCESS, SENDER, RESPONSE, TARGET and TEXT." | |||
| 213 | :type 'boolean | 217 | :type 'boolean |
| 214 | :group 'rcirc) | 218 | :group 'rcirc) |
| 215 | 219 | ||
| 220 | (defcustom rcirc-decode-coding-system 'undecided | ||
| 221 | "Coding system used to decode incoming irc messages." | ||
| 222 | :type 'coding-system | ||
| 223 | :group 'rcirc) | ||
| 224 | |||
| 225 | (defcustom rcirc-encode-coding-system 'utf-8 | ||
| 226 | "Coding system used to encode outgoing irc messages." | ||
| 227 | :type 'coding-system | ||
| 228 | :group 'rcirc) | ||
| 229 | |||
| 230 | (defcustom rcirc-coding-system-alist nil | ||
| 231 | "Alist to decide a coding system to use for a file I/O operation. | ||
| 232 | The format is ((PATTERN . VAL) ...). | ||
| 233 | PATTERN is either a string or a cons of strings. | ||
| 234 | If PATTERN is a string, it is used to match a target. | ||
| 235 | If PATTERN is a cons of strings, the car part is used to match a | ||
| 236 | target, and the cdr part is used to match a server. | ||
| 237 | VAL is either a coding system or a cons of coding systems. | ||
| 238 | If VAL is a coding system, it is used for both decoding and encoding | ||
| 239 | messages. | ||
| 240 | If VAL is a cons of coding systems, the car part is used for decoding, | ||
| 241 | and the cdr part is used for encoding." | ||
| 242 | :type '(alist :key-type (choice (string :tag "Channel Regexp") | ||
| 243 | (cons (string :tag "Channel Regexp") | ||
| 244 | (string :tag "Server Regexp"))) | ||
| 245 | :value-type (choice coding-system | ||
| 246 | (cons (coding-system :tag "Decode") | ||
| 247 | (coding-system :tag "Encode")))) | ||
| 248 | :group 'rcirc) | ||
| 249 | |||
| 250 | (defcustom rcirc-multiline-major-mode 'fundamental-mode | ||
| 251 | "Major-mode function to use in multiline edit buffers." | ||
| 252 | :type 'function | ||
| 253 | :group 'rcirc) | ||
| 254 | |||
| 255 | (defvar rcirc-nick nil) | ||
| 256 | |||
| 216 | (defvar rcirc-prompt-start-marker nil) | 257 | (defvar rcirc-prompt-start-marker nil) |
| 217 | (defvar rcirc-prompt-end-marker nil) | 258 | (defvar rcirc-prompt-end-marker nil) |
| 218 | 259 | ||
| @@ -230,14 +271,14 @@ Called with 5 arguments, PROCESS, SENDER, RESPONSE, TARGET and TEXT." | |||
| 230 | (defvar rcirc-buffer-alist nil) | 271 | (defvar rcirc-buffer-alist nil) |
| 231 | 272 | ||
| 232 | (defvar rcirc-activity nil | 273 | (defvar rcirc-activity nil |
| 233 | "List of channels with unviewed activity.") | 274 | "List of buffers with unviewed activity.") |
| 234 | 275 | ||
| 235 | (defvar rcirc-activity-string "" | 276 | (defvar rcirc-activity-string "" |
| 236 | "String displayed in modeline representing `rcirc-activity'.") | 277 | "String displayed in modeline representing `rcirc-activity'.") |
| 237 | (put 'rcirc-activity-string 'risky-local-variable t) | 278 | (put 'rcirc-activity-string 'risky-local-variable t) |
| 238 | 279 | ||
| 239 | (defvar rcirc-process nil | 280 | (defvar rcirc-server-buffer nil |
| 240 | "The server process associated with this buffer.") | 281 | "The server buffer associated with this channel buffer.") |
| 241 | 282 | ||
| 242 | (defvar rcirc-target nil | 283 | (defvar rcirc-target nil |
| 243 | "The channel or user associated with this buffer.") | 284 | "The channel or user associated with this buffer.") |
| @@ -246,7 +287,8 @@ Called with 5 arguments, PROCESS, SENDER, RESPONSE, TARGET and TEXT." | |||
| 246 | "List of urls seen in the current buffer.") | 287 | "List of urls seen in the current buffer.") |
| 247 | 288 | ||
| 248 | (defvar rcirc-keepalive-seconds 60 | 289 | (defvar rcirc-keepalive-seconds 60 |
| 249 | "Number of seconds between keepalive pings.") | 290 | "Number of seconds between keepalive pings. |
| 291 | If nil, do not send keepalive pings.") | ||
| 250 | 292 | ||
| 251 | (defconst rcirc-id-string (concat "rcirc on GNU Emacs " emacs-version)) | 293 | (defconst rcirc-id-string (concat "rcirc on GNU Emacs " emacs-version)) |
| 252 | 294 | ||
| @@ -257,31 +299,30 @@ Called with 5 arguments, PROCESS, SENDER, RESPONSE, TARGET and TEXT." | |||
| 257 | If ARG is non-nil, prompt for a server to connect to." | 299 | If ARG is non-nil, prompt for a server to connect to." |
| 258 | (interactive "P") | 300 | (interactive "P") |
| 259 | (if arg | 301 | (if arg |
| 260 | (let* ((server (read-string "IRC Server: " rcirc-server)) | 302 | (let* ((server (read-string "IRC Server: " rcirc-default-server)) |
| 261 | (port (read-string "IRC Port: " (number-to-string rcirc-port))) | 303 | (port (read-string "IRC Port: " (number-to-string rcirc-default-port))) |
| 262 | (nick (read-string "IRC Nick: " rcirc-nick)) | 304 | (nick (read-string "IRC Nick: " rcirc-default-nick)) |
| 263 | (channels (split-string | 305 | (channels (split-string |
| 264 | (read-string "IRC Channels: " | 306 | (read-string "IRC Channels: " |
| 265 | (mapconcat 'identity | 307 | (mapconcat 'identity (rcirc-startup-channels server) " ")) |
| 266 | (rcirc-startup-channels server) | ||
| 267 | " ")) | ||
| 268 | "[, ]+" t))) | 308 | "[, ]+" t))) |
| 269 | (rcirc-connect server port nick rcirc-user-name rcirc-user-full-name | 309 | (rcirc-connect server port nick rcirc-default-user-name rcirc-default-user-full-name |
| 270 | channels)) | 310 | channels)) |
| 271 | ;; make new connection using defaults unless already connected to | 311 | ;; make new connection using defaults unless already connected to |
| 272 | ;; the default rcirc-server | 312 | ;; the default rcirc-server |
| 273 | (let ((default-server (default-value 'rcirc-server)) | 313 | (let (connected) |
| 274 | connected) | ||
| 275 | (dolist (p (rcirc-process-list)) | 314 | (dolist (p (rcirc-process-list)) |
| 276 | (when (string= default-server (process-name p)) | 315 | (when (string= rcirc-default-server (process-name p)) |
| 277 | (setq connected p))) | 316 | (setq connected p))) |
| 278 | (if (not connected) | 317 | (if (not connected) |
| 279 | (rcirc-connect rcirc-server rcirc-port rcirc-nick | 318 | (rcirc-connect rcirc-default-server rcirc-default-port |
| 280 | rcirc-user-name rcirc-user-full-name | 319 | rcirc-default-nick rcirc-default-user-name |
| 281 | (rcirc-startup-channels rcirc-server)) | 320 | rcirc-default-user-full-name |
| 321 | (rcirc-startup-channels rcirc-default-server)) | ||
| 282 | (switch-to-buffer (process-buffer connected)) | 322 | (switch-to-buffer (process-buffer connected)) |
| 283 | (message "Connected to %s" rcirc-server))))) | 323 | (message "Connected to %s" |
| 284 | 324 | (process-contact (get-buffer-process (current-buffer)) | |
| 325 | :host)))))) | ||
| 285 | ;;;###autoload | 326 | ;;;###autoload |
| 286 | (defalias 'irc 'rcirc) | 327 | (defalias 'irc 'rcirc) |
| 287 | 328 | ||
| @@ -290,12 +331,10 @@ If ARG is non-nil, prompt for a server to connect to." | |||
| 290 | (defvar rcirc-topic nil) | 331 | (defvar rcirc-topic nil) |
| 291 | (defvar rcirc-keepalive-timer nil) | 332 | (defvar rcirc-keepalive-timer nil) |
| 292 | (defvar rcirc-last-server-message-time nil) | 333 | (defvar rcirc-last-server-message-time nil) |
| 334 | (defvar rcirc-server nil) | ||
| 293 | 335 | ||
| 294 | ;;;###autoload | 336 | ;;;###autoload |
| 295 | (defun rcirc-connect (&optional server port nick user-name full-name startup-channels) | 337 | (defun rcirc-connect (&optional server port nick user-name full-name startup-channels) |
| 296 | (add-hook 'window-configuration-change-hook | ||
| 297 | 'rcirc-window-configuration-change) | ||
| 298 | |||
| 299 | (save-excursion | 338 | (save-excursion |
| 300 | (message "Connecting to %s..." server) | 339 | (message "Connecting to %s..." server) |
| 301 | (let* ((inhibit-eol-conversion) | 340 | (let* ((inhibit-eol-conversion) |
| @@ -303,26 +342,26 @@ If ARG is non-nil, prompt for a server to connect to." | |||
| 303 | (if (stringp port) | 342 | (if (stringp port) |
| 304 | (string-to-number port) | 343 | (string-to-number port) |
| 305 | port) | 344 | port) |
| 306 | rcirc-port)) | 345 | rcirc-default-port)) |
| 307 | (server (or server rcirc-server)) | 346 | (server (or server rcirc-default-server)) |
| 308 | (nick (or nick rcirc-nick)) | 347 | (nick (or nick rcirc-default-nick)) |
| 309 | (user-name (or user-name rcirc-user-name)) | 348 | (user-name (or user-name rcirc-default-user-name)) |
| 310 | (full-name (or full-name rcirc-user-full-name)) | 349 | (full-name (or full-name rcirc-default-user-full-name)) |
| 311 | (startup-channels (or startup-channels (rcirc-startup-channels server))) | 350 | (startup-channels startup-channels) |
| 312 | (process (open-network-stream server nil server port-number))) | 351 | (process (open-network-stream server nil server port-number))) |
| 313 | ;; set up process | 352 | ;; set up process |
| 314 | (set-process-coding-system process 'raw-text 'raw-text) | 353 | (set-process-coding-system process 'raw-text 'raw-text) |
| 315 | (set-process-filter process 'rcirc-filter) | ||
| 316 | (switch-to-buffer (rcirc-generate-new-buffer-name process nil)) | 354 | (switch-to-buffer (rcirc-generate-new-buffer-name process nil)) |
| 317 | (set-process-buffer process (current-buffer)) | 355 | (set-process-buffer process (current-buffer)) |
| 318 | (set-process-sentinel process 'rcirc-sentinel) | ||
| 319 | (rcirc-mode process nil) | 356 | (rcirc-mode process nil) |
| 357 | (set-process-sentinel process 'rcirc-sentinel) | ||
| 358 | (set-process-filter process 'rcirc-filter) | ||
| 359 | (make-local-variable 'rcirc-server) | ||
| 360 | (setq rcirc-server server) | ||
| 320 | (make-local-variable 'rcirc-buffer-alist) | 361 | (make-local-variable 'rcirc-buffer-alist) |
| 321 | (setq rcirc-buffer-alist nil) | 362 | (setq rcirc-buffer-alist nil) |
| 322 | (make-local-variable 'rcirc-nick-table) | 363 | (make-local-variable 'rcirc-nick-table) |
| 323 | (setq rcirc-nick-table (make-hash-table :test 'equal)) | 364 | (setq rcirc-nick-table (make-hash-table :test 'equal)) |
| 324 | (make-local-variable 'rcirc-server) | ||
| 325 | (setq rcirc-server server) | ||
| 326 | (make-local-variable 'rcirc-nick) | 365 | (make-local-variable 'rcirc-nick) |
| 327 | (setq rcirc-nick nick) | 366 | (setq rcirc-nick nick) |
| 328 | (make-local-variable 'rcirc-process-output) | 367 | (make-local-variable 'rcirc-process-output) |
| @@ -339,9 +378,10 @@ If ARG is non-nil, prompt for a server to connect to." | |||
| 339 | full-name)) | 378 | full-name)) |
| 340 | 379 | ||
| 341 | ;; setup ping timer if necessary | 380 | ;; setup ping timer if necessary |
| 342 | (unless rcirc-keepalive-timer | 381 | (when rcirc-keepalive-seconds |
| 343 | (setq rcirc-keepalive-timer | 382 | (unless rcirc-keepalive-timer |
| 344 | (run-at-time 0 rcirc-keepalive-seconds 'rcirc-keepalive))) | 383 | (setq rcirc-keepalive-timer |
| 384 | (run-at-time 0 rcirc-keepalive-seconds 'rcirc-keepalive)))) | ||
| 345 | 385 | ||
| 346 | (message "Connecting to %s...done" server) | 386 | (message "Connecting to %s...done" server) |
| 347 | 387 | ||
| @@ -353,6 +393,11 @@ If ARG is non-nil, prompt for a server to connect to." | |||
| 353 | `(with-current-buffer (process-buffer ,process) | 393 | `(with-current-buffer (process-buffer ,process) |
| 354 | ,@body)) | 394 | ,@body)) |
| 355 | 395 | ||
| 396 | (defmacro with-rcirc-server-buffer (&rest body) | ||
| 397 | (declare (indent 0) (debug t)) | ||
| 398 | `(with-current-buffer rcirc-server-buffer | ||
| 399 | ,@body)) | ||
| 400 | |||
| 356 | (defun rcirc-keepalive () | 401 | (defun rcirc-keepalive () |
| 357 | "Send keep alive pings to active rcirc processes. | 402 | "Send keep alive pings to active rcirc processes. |
| 358 | Kill processes that have not received a server message since the | 403 | Kill processes that have not received a server message since the |
| @@ -471,24 +516,35 @@ Function is called with PROCESS, COMMAND, SENDER, ARGS and LINE.") | |||
| 471 | 516 | ||
| 472 | (defun rcirc-send-string (process string) | 517 | (defun rcirc-send-string (process string) |
| 473 | "Send PROCESS a STRING plus a newline." | 518 | "Send PROCESS a STRING plus a newline." |
| 474 | (let ((string (concat (encode-coding-string string | 519 | (let ((string (concat (encode-coding-string string rcirc-encode-coding-system) |
| 475 | buffer-file-coding-system) | ||
| 476 | "\n"))) | 520 | "\n"))) |
| 477 | (unless (eq (process-status rcirc-process) 'open) | 521 | (unless (eq (process-status process) 'open) |
| 478 | (error "Network connection to %s is not open" | 522 | (error "Network connection to %s is not open" |
| 479 | (process-name rcirc-process))) | 523 | (process-name process))) |
| 480 | (rcirc-debug process string) | 524 | (rcirc-debug process string) |
| 481 | (process-send-string process string))) | 525 | (process-send-string process string))) |
| 482 | 526 | ||
| 483 | (defun rcirc-server (process) | 527 | (defun rcirc-buffer-process (&optional buffer) |
| 484 | "Return PROCESS server, given by the 001 response." | 528 | "Return the process associated with channel BUFFER. |
| 529 | With no argument or nil as argument, use the current buffer." | ||
| 530 | (get-buffer-process (or buffer rcirc-server-buffer))) | ||
| 531 | |||
| 532 | (defun rcirc-server-name (process) | ||
| 533 | "Return PROCESS server name, given by the 001 response." | ||
| 485 | (with-rcirc-process-buffer process | 534 | (with-rcirc-process-buffer process |
| 486 | rcirc-server)) | 535 | (or rcirc-server rcirc-default-server))) |
| 487 | 536 | ||
| 488 | (defun rcirc-nick (process) | 537 | (defun rcirc-nick (process) |
| 489 | "Return PROCESS nick." | 538 | "Return PROCESS nick." |
| 490 | (with-rcirc-process-buffer process | 539 | (with-rcirc-process-buffer process |
| 491 | rcirc-nick)) | 540 | (or rcirc-nick rcirc-default-nick))) |
| 541 | |||
| 542 | (defun rcirc-buffer-nick (&optional buffer) | ||
| 543 | "Return the nick associated with BUFFER. | ||
| 544 | With no argument or nil as argument, use the current buffer." | ||
| 545 | (with-current-buffer (or buffer (current-buffer)) | ||
| 546 | (with-current-buffer rcirc-server-buffer | ||
| 547 | (or rcirc-nick rcirc-default-nick)))) | ||
| 492 | 548 | ||
| 493 | (defvar rcirc-max-message-length 450 | 549 | (defvar rcirc-max-message-length 450 |
| 494 | "Messages longer than this value will be split.") | 550 | "Messages longer than this value will be split.") |
| @@ -554,8 +610,8 @@ If NOTICEP is non-nil, send a notice instead of privmsg." | |||
| 554 | rcirc-nick-completion-start-offset) | 610 | rcirc-nick-completion-start-offset) |
| 555 | (point)) | 611 | (point)) |
| 556 | (mapcar (lambda (x) (cons x nil)) | 612 | (mapcar (lambda (x) (cons x nil)) |
| 557 | (rcirc-channel-nicks rcirc-process | 613 | (rcirc-channel-nicks (rcirc-buffer-process) |
| 558 | (rcirc-buffer-target))))))) | 614 | rcirc-target)))))) |
| 559 | (let ((completion (car rcirc-nick-completions))) | 615 | (let ((completion (car rcirc-nick-completions))) |
| 560 | (when completion | 616 | (when completion |
| 561 | (delete-region (+ rcirc-prompt-end-marker | 617 | (delete-region (+ rcirc-prompt-end-marker |
| @@ -567,11 +623,15 @@ If NOTICEP is non-nil, send a notice instead of privmsg." | |||
| 567 | rcirc-prompt-end-marker) | 623 | rcirc-prompt-end-marker) |
| 568 | ": ")))))) | 624 | ": ")))))) |
| 569 | 625 | ||
| 570 | (defun rcirc-buffer-target (&optional buffer) | 626 | (defun set-rcirc-decode-coding-system (coding-system) |
| 571 | "Return the name of target for BUFFER. | 627 | "Set the decode coding system used in this channel." |
| 572 | If buffer is nil, return the target of the current buffer." | 628 | (interactive "zCoding system for incoming messages: ") |
| 573 | (with-current-buffer (or buffer (current-buffer)) | 629 | (setq rcirc-decode-coding-system coding-system)) |
| 574 | rcirc-target)) | 630 | |
| 631 | (defun set-rcirc-encode-coding-system (coding-system) | ||
| 632 | "Set the encode coding system used in this channel." | ||
| 633 | (interactive "zCoding system for outgoing messages: ") | ||
| 634 | (setq rcirc-encode-coding-system coding-system)) | ||
| 575 | 635 | ||
| 576 | (defvar rcirc-mode-map (make-sparse-keymap) | 636 | (defvar rcirc-mode-map (make-sparse-keymap) |
| 577 | "Keymap for rcirc mode.") | 637 | "Keymap for rcirc mode.") |
| @@ -584,7 +644,7 @@ If buffer is nil, return the target of the current buffer." | |||
| 584 | (define-key rcirc-mode-map (kbd "C-c C-c") 'rcirc-edit-multiline) | 644 | (define-key rcirc-mode-map (kbd "C-c C-c") 'rcirc-edit-multiline) |
| 585 | (define-key rcirc-mode-map (kbd "C-c C-j") 'rcirc-cmd-join) | 645 | (define-key rcirc-mode-map (kbd "C-c C-j") 'rcirc-cmd-join) |
| 586 | (define-key rcirc-mode-map (kbd "C-c C-k") 'rcirc-cmd-kick) | 646 | (define-key rcirc-mode-map (kbd "C-c C-k") 'rcirc-cmd-kick) |
| 587 | (define-key rcirc-mode-map (kbd "C-c C-l") 'rcirc-cmd-list) | 647 | (define-key rcirc-mode-map (kbd "C-c C-l") 'rcirc-toggle-low-priority) |
| 588 | (define-key rcirc-mode-map (kbd "C-c C-d") 'rcirc-cmd-mode) | 648 | (define-key rcirc-mode-map (kbd "C-c C-d") 'rcirc-cmd-mode) |
| 589 | (define-key rcirc-mode-map (kbd "C-c C-m") 'rcirc-cmd-msg) | 649 | (define-key rcirc-mode-map (kbd "C-c C-m") 'rcirc-cmd-msg) |
| 590 | (define-key rcirc-mode-map (kbd "C-c C-r") 'rcirc-cmd-nick) ; rename | 650 | (define-key rcirc-mode-map (kbd "C-c C-r") 'rcirc-cmd-nick) ; rename |
| @@ -612,6 +672,8 @@ If buffer is nil, return the target of the current buffer." | |||
| 612 | (defvar rcirc-mode-hook nil | 672 | (defvar rcirc-mode-hook nil |
| 613 | "Hook run when setting up rcirc buffer.") | 673 | "Hook run when setting up rcirc buffer.") |
| 614 | 674 | ||
| 675 | (defvar rcirc-last-post-time nil) | ||
| 676 | |||
| 615 | (defun rcirc-mode (process target) | 677 | (defun rcirc-mode (process target) |
| 616 | "Major mode for IRC channel buffers. | 678 | "Major mode for IRC channel buffers. |
| 617 | 679 | ||
| @@ -623,12 +685,14 @@ If buffer is nil, return the target of the current buffer." | |||
| 623 | 685 | ||
| 624 | (make-local-variable 'rcirc-input-ring) | 686 | (make-local-variable 'rcirc-input-ring) |
| 625 | (setq rcirc-input-ring (make-ring rcirc-input-ring-size)) | 687 | (setq rcirc-input-ring (make-ring rcirc-input-ring-size)) |
| 626 | (make-local-variable 'rcirc-process) | 688 | (make-local-variable 'rcirc-server-buffer) |
| 627 | (setq rcirc-process process) | 689 | (setq rcirc-server-buffer (process-buffer process)) |
| 628 | (make-local-variable 'rcirc-target) | 690 | (make-local-variable 'rcirc-target) |
| 629 | (setq rcirc-target target) | 691 | (setq rcirc-target target) |
| 630 | (make-local-variable 'rcirc-topic) | 692 | (make-local-variable 'rcirc-topic) |
| 631 | (setq rcirc-topic nil) | 693 | (setq rcirc-topic nil) |
| 694 | (make-local-variable 'rcirc-last-post-time) | ||
| 695 | (setq rcirc-last-post-time (current-time)) | ||
| 632 | 696 | ||
| 633 | (make-local-variable 'rcirc-short-buffer-name) | 697 | (make-local-variable 'rcirc-short-buffer-name) |
| 634 | (setq rcirc-short-buffer-name nil) | 698 | (setq rcirc-short-buffer-name nil) |
| @@ -636,6 +700,16 @@ If buffer is nil, return the target of the current buffer." | |||
| 636 | (setq rcirc-urls nil) | 700 | (setq rcirc-urls nil) |
| 637 | (setq use-hard-newlines t) | 701 | (setq use-hard-newlines t) |
| 638 | 702 | ||
| 703 | (make-local-variable 'rcirc-decode-coding-system) | ||
| 704 | (make-local-variable 'rcirc-encode-coding-system) | ||
| 705 | (dolist (i rcirc-coding-system-alist) | ||
| 706 | (let ((chan (if (consp (car i)) (caar i) (car i))) | ||
| 707 | (serv (if (consp (car i)) (cdar i) ""))) | ||
| 708 | (when (and (string-match chan (or target "")) | ||
| 709 | (string-match serv (rcirc-server-name process))) | ||
| 710 | (setq rcirc-decode-coding-system (if (consp (cdr i)) (cadr i) i) | ||
| 711 | rcirc-encode-coding-system (if (consp (cdr i)) (cddr i) i))))) | ||
| 712 | |||
| 639 | ;; setup the prompt and markers | 713 | ;; setup the prompt and markers |
| 640 | (make-local-variable 'rcirc-prompt-start-marker) | 714 | (make-local-variable 'rcirc-prompt-start-marker) |
| 641 | (setq rcirc-prompt-start-marker (make-marker)) | 715 | (setq rcirc-prompt-start-marker (make-marker)) |
| @@ -649,6 +723,13 @@ If buffer is nil, return the target of the current buffer." | |||
| 649 | (setq overlay-arrow-position (make-marker)) | 723 | (setq overlay-arrow-position (make-marker)) |
| 650 | (set-marker overlay-arrow-position nil) | 724 | (set-marker overlay-arrow-position nil) |
| 651 | 725 | ||
| 726 | ;; if the user changes the major mode or kills the buffer, there is | ||
| 727 | ;; cleanup work to do | ||
| 728 | (make-local-variable 'change-major-mode-hook) | ||
| 729 | (add-hook 'change-major-mode-hook 'rcirc-change-major-mode-hook) | ||
| 730 | (make-local-variable 'kill-buffer-hook) | ||
| 731 | (add-hook 'kill-buffer-hook 'rcirc-kill-buffer-hook) | ||
| 732 | |||
| 652 | ;; add to buffer list, and update buffer abbrevs | 733 | ;; add to buffer list, and update buffer abbrevs |
| 653 | (when target ; skip server buffer | 734 | (when target ; skip server buffer |
| 654 | (let ((buffer (current-buffer))) | 735 | (let ((buffer (current-buffer))) |
| @@ -675,11 +756,9 @@ If ALL is non-nil, update prompts in all IRC buffers." | |||
| 675 | (prompt (or rcirc-prompt ""))) | 756 | (prompt (or rcirc-prompt ""))) |
| 676 | (mapc (lambda (rep) | 757 | (mapc (lambda (rep) |
| 677 | (setq prompt | 758 | (setq prompt |
| 678 | (replace-regexp-in-string (car rep) (regexp-quote (cdr rep)) prompt))) | 759 | (replace-regexp-in-string (car rep) (cdr rep) prompt))) |
| 679 | (list (cons "%n" (with-rcirc-process-buffer rcirc-process | 760 | (list (cons "%n" (rcirc-buffer-nick)) |
| 680 | rcirc-nick)) | 761 | (cons "%s" (with-rcirc-server-buffer (or rcirc-server ""))) |
| 681 | (cons "%s" (with-rcirc-process-buffer rcirc-process | ||
| 682 | rcirc-server)) | ||
| 683 | (cons "%t" (or rcirc-target "")))) | 762 | (cons "%t" (or rcirc-target "")))) |
| 684 | (save-excursion | 763 | (save-excursion |
| 685 | (delete-region rcirc-prompt-start-marker rcirc-prompt-end-marker) | 764 | (delete-region rcirc-prompt-start-marker rcirc-prompt-end-marker) |
| @@ -713,27 +792,29 @@ If ALL is non-nil, update prompts in all IRC buffers." | |||
| 713 | (defun rcirc-kill-buffer-hook () | 792 | (defun rcirc-kill-buffer-hook () |
| 714 | "Part the channel when killing an rcirc buffer." | 793 | "Part the channel when killing an rcirc buffer." |
| 715 | (when (eq major-mode 'rcirc-mode) | 794 | (when (eq major-mode 'rcirc-mode) |
| 716 | (rcirc-kill-buffer-hook-1))) | 795 | (rcirc-clean-up-buffer "Killed buffer"))) |
| 717 | (defun rcirc-kill-buffer-hook-1 () | 796 | |
| 797 | (defun rcirc-change-major-mode-hook () | ||
| 798 | "Part the channel when changing the major-mode." | ||
| 799 | (rcirc-clean-up-buffer "Changed major mode")) | ||
| 800 | |||
| 801 | (defun rcirc-clean-up-buffer (reason) | ||
| 718 | (let ((buffer (current-buffer))) | 802 | (let ((buffer (current-buffer))) |
| 719 | (rcirc-clear-activity buffer) | 803 | (rcirc-clear-activity buffer) |
| 720 | (when (and rcirc-process | 804 | (when (and (rcirc-buffer-process) |
| 721 | (eq (process-status rcirc-process) 'open)) | 805 | (eq (process-status (rcirc-buffer-process)) 'open)) |
| 722 | (with-rcirc-process-buffer rcirc-process | 806 | (with-rcirc-server-buffer |
| 723 | (setq rcirc-buffer-alist | 807 | (setq rcirc-buffer-alist |
| 724 | (rassq-delete-all buffer rcirc-buffer-alist))) | 808 | (rassq-delete-all buffer rcirc-buffer-alist))) |
| 725 | (rcirc-update-short-buffer-names) | 809 | (rcirc-update-short-buffer-names) |
| 726 | (if (rcirc-channel-p rcirc-target) | 810 | (if (rcirc-channel-p rcirc-target) |
| 727 | (rcirc-send-string rcirc-process | 811 | (rcirc-send-string (rcirc-buffer-process) |
| 728 | (concat "PART " rcirc-target | 812 | (concat "PART " rcirc-target " :" reason)) |
| 729 | " :Killed buffer")) | ||
| 730 | (when rcirc-target | 813 | (when rcirc-target |
| 731 | (rcirc-remove-nick-channel rcirc-process | 814 | (rcirc-remove-nick-channel (rcirc-buffer-process) |
| 732 | (rcirc-nick rcirc-process) | 815 | (rcirc-buffer-nick) |
| 733 | rcirc-target)))))) | 816 | rcirc-target)))))) |
| 734 | 817 | ||
| 735 | (add-hook 'kill-buffer-hook 'rcirc-kill-buffer-hook) | ||
| 736 | |||
| 737 | (defun rcirc-generate-new-buffer-name (process target) | 818 | (defun rcirc-generate-new-buffer-name (process target) |
| 738 | "Return a buffer name based on PROCESS and TARGET. | 819 | "Return a buffer name based on PROCESS and TARGET. |
| 739 | This is used for the initial name given to IRC buffers." | 820 | This is used for the initial name given to IRC buffers." |
| @@ -756,7 +837,7 @@ if there is no existing buffer for TARGET, otherwise return nil." | |||
| 756 | "Return the buffer associated with the PROCESS and TARGET. | 837 | "Return the buffer associated with the PROCESS and TARGET. |
| 757 | Create the buffer if it doesn't exist." | 838 | Create the buffer if it doesn't exist." |
| 758 | (let ((buffer (rcirc-get-buffer process target))) | 839 | (let ((buffer (rcirc-get-buffer process target))) |
| 759 | (if buffer | 840 | (if (and buffer (buffer-live-p buffer)) |
| 760 | (with-current-buffer buffer | 841 | (with-current-buffer buffer |
| 761 | (when (not rcirc-target) | 842 | (when (not rcirc-target) |
| 762 | (setq rcirc-target target)) | 843 | (setq rcirc-target target)) |
| @@ -789,22 +870,20 @@ Create the buffer if it doesn't exist." | |||
| 789 | (buffer-substring-no-properties start end))))) | 870 | (buffer-substring-no-properties start end))))) |
| 790 | ;; process input | 871 | ;; process input |
| 791 | (goto-char (point-max)) | 872 | (goto-char (point-max)) |
| 792 | (let ((target (rcirc-buffer-target)) | 873 | (when (not (equal 0 (- (point) rcirc-prompt-end-marker))) |
| 793 | (start rcirc-prompt-end-marker)) | 874 | ;; delete a trailing newline |
| 794 | (when (not (equal 0 (- (point) start))) | 875 | (when (eq (point) (point-at-bol)) |
| 795 | ;; delete a trailing newline | 876 | (delete-backward-char 1)) |
| 796 | (when (eq (point) (point-at-bol)) | 877 | (let ((input (buffer-substring-no-properties |
| 797 | (delete-backward-char 1)) | 878 | rcirc-prompt-end-marker (point)))) |
| 798 | (let ((input (buffer-substring-no-properties | 879 | (dolist (line (split-string input "\n")) |
| 799 | rcirc-prompt-end-marker (point)))) | 880 | (rcirc-process-input-line line)) |
| 800 | (dolist (line (split-string input "\n")) | 881 | ;; add to input-ring |
| 801 | (rcirc-process-input-line rcirc-process target line)) | 882 | (save-excursion |
| 802 | ;; add to input-ring | 883 | (ring-insert rcirc-input-ring input) |
| 803 | (save-excursion | 884 | (setq rcirc-input-ring-index 0)))))) |
| 804 | (ring-insert rcirc-input-ring input) | 885 | |
| 805 | (setq rcirc-input-ring-index 0))))))) | 886 | (defun rcirc-process-input-line (line) |
| 806 | |||
| 807 | (defun rcirc-process-input-line (process target line) | ||
| 808 | (if (string-match "^/\\([^ ]+\\) ?\\(.*\\)$" line) | 887 | (if (string-match "^/\\([^ ]+\\) ?\\(.*\\)$" line) |
| 809 | (rcirc-process-command (match-string 1 line) | 888 | (rcirc-process-command (match-string 1 line) |
| 810 | (match-string 2 line) | 889 | (match-string 2 line) |
| @@ -813,27 +892,29 @@ Create the buffer if it doesn't exist." | |||
| 813 | 892 | ||
| 814 | (defun rcirc-process-message (line) | 893 | (defun rcirc-process-message (line) |
| 815 | (if (not rcirc-target) | 894 | (if (not rcirc-target) |
| 816 | (message "Not joined") | 895 | (message "Not joined (no target)") |
| 817 | (delete-region rcirc-prompt-end-marker (point)) | 896 | (delete-region rcirc-prompt-end-marker (point)) |
| 818 | (rcirc-send-message rcirc-process rcirc-target line))) | 897 | (rcirc-send-message (rcirc-buffer-process) rcirc-target line) |
| 898 | (setq rcirc-last-post-time (current-time)))) | ||
| 819 | 899 | ||
| 820 | (defun rcirc-process-command (command args line) | 900 | (defun rcirc-process-command (command args line) |
| 821 | (if (eq (aref command 0) ?/) | 901 | (if (eq (aref command 0) ?/) |
| 822 | ;; "//text" will send "/text" as a message | 902 | ;; "//text" will send "/text" as a message |
| 823 | (rcirc-process-message (substring line 1)) | 903 | (rcirc-process-message (substring line 1)) |
| 824 | (let* ((fun (intern-soft (concat "rcirc-cmd-" command)))) | 904 | (let ((fun (intern-soft (concat "rcirc-cmd-" command))) |
| 905 | (process (rcirc-buffer-process))) | ||
| 825 | (newline) | 906 | (newline) |
| 826 | (with-current-buffer (current-buffer) | 907 | (with-current-buffer (current-buffer) |
| 827 | (delete-region rcirc-prompt-end-marker (point)) | 908 | (delete-region rcirc-prompt-end-marker (point)) |
| 828 | (if (string= command "me") | 909 | (if (string= command "me") |
| 829 | (rcirc-print rcirc-process (rcirc-nick rcirc-process) | 910 | (rcirc-print process (rcirc-buffer-nick) |
| 830 | "ACTION" rcirc-target args) | 911 | "ACTION" rcirc-target args) |
| 831 | (rcirc-print rcirc-process (rcirc-nick rcirc-process) | 912 | (rcirc-print process (rcirc-buffer-nick) |
| 832 | "COMMAND" rcirc-target line)) | 913 | "COMMAND" rcirc-target line)) |
| 833 | (set-marker rcirc-prompt-end-marker (point)) | 914 | (set-marker rcirc-prompt-end-marker (point)) |
| 834 | (if (fboundp fun) | 915 | (if (fboundp fun) |
| 835 | (funcall fun args rcirc-process rcirc-target) | 916 | (funcall fun args process rcirc-target) |
| 836 | (rcirc-send-string rcirc-process | 917 | (rcirc-send-string process |
| 837 | (concat command " " args))))))) | 918 | (concat command " " args))))))) |
| 838 | 919 | ||
| 839 | (defvar rcirc-parent-buffer nil) | 920 | (defvar rcirc-parent-buffer nil) |
| @@ -844,38 +925,41 @@ Create the buffer if it doesn't exist." | |||
| 844 | (let ((pos (1+ (- (point) rcirc-prompt-end-marker)))) | 925 | (let ((pos (1+ (- (point) rcirc-prompt-end-marker)))) |
| 845 | (goto-char (point-max)) | 926 | (goto-char (point-max)) |
| 846 | (let ((text (buffer-substring rcirc-prompt-end-marker (point))) | 927 | (let ((text (buffer-substring rcirc-prompt-end-marker (point))) |
| 847 | (parent (buffer-name)) | 928 | (parent (buffer-name))) |
| 848 | (process rcirc-process)) | ||
| 849 | (delete-region rcirc-prompt-end-marker (point)) | 929 | (delete-region rcirc-prompt-end-marker (point)) |
| 850 | (setq rcirc-window-configuration (current-window-configuration)) | 930 | (setq rcirc-window-configuration (current-window-configuration)) |
| 851 | (pop-to-buffer (concat "*multiline " parent "*")) | 931 | (pop-to-buffer (concat "*multiline " parent "*")) |
| 852 | (rcirc-multiline-edit-mode) | 932 | (funcall rcirc-multiline-major-mode) |
| 933 | (rcirc-multiline-minor-mode 1) | ||
| 853 | (setq rcirc-parent-buffer parent) | 934 | (setq rcirc-parent-buffer parent) |
| 854 | (setq rcirc-process process) | ||
| 855 | (insert text) | 935 | (insert text) |
| 856 | (and (> pos 0) (goto-char pos)) | 936 | (and (> pos 0) (goto-char pos)) |
| 857 | (message "Type C-c C-c to return text to %s, or C-c C-k to cancel" parent)))) | 937 | (message "Type C-c C-c to return text to %s, or C-c C-k to cancel" parent)))) |
| 858 | 938 | ||
| 859 | (define-derived-mode rcirc-multiline-edit-mode | 939 | (defvar rcirc-multiline-minor-mode-map (make-sparse-keymap) |
| 860 | text-mode "rcirc multi" | 940 | "Keymap for multiline mode in rcirc.") |
| 861 | "Major mode for multiline edits | 941 | (define-key rcirc-multiline-minor-mode-map |
| 862 | \\{rcirc-multiline-edit-mode-map}" | 942 | (kbd "C-c C-c") 'rcirc-multiline-minor-submit) |
| 943 | (define-key rcirc-multiline-minor-mode-map | ||
| 944 | (kbd "C-x C-s") 'rcirc-multiline-minor-submit) | ||
| 945 | (define-key rcirc-multiline-minor-mode-map | ||
| 946 | (kbd "C-c C-k") 'rcirc-multiline-minor-cancel) | ||
| 947 | (define-key rcirc-multiline-minor-mode-map | ||
| 948 | (kbd "ESC ESC ESC") 'rcirc-multiline-minor-cancel) | ||
| 949 | |||
| 950 | (define-minor-mode rcirc-multiline-minor-mode | ||
| 951 | "Minor mode for editing multiple lines in rcirc." | ||
| 952 | :init-value nil | ||
| 953 | :lighter " rcirc-mline" | ||
| 954 | :keymap rcirc-multiline-minor-mode-map | ||
| 955 | :global nil | ||
| 956 | :group 'rcirc | ||
| 863 | (make-local-variable 'rcirc-parent-buffer) | 957 | (make-local-variable 'rcirc-parent-buffer) |
| 864 | (make-local-variable 'rcirc-process)) | 958 | (put 'rcirc-parent-buffer 'permanent-local t)) |
| 865 | 959 | ||
| 866 | (define-key rcirc-multiline-edit-mode-map | 960 | (defun rcirc-multiline-minor-submit () |
| 867 | (kbd "C-c C-c") 'rcirc-multiline-edit-submit) | ||
| 868 | (define-key rcirc-multiline-edit-mode-map | ||
| 869 | (kbd "C-x C-s") 'rcirc-multiline-edit-submit) | ||
| 870 | (define-key rcirc-multiline-edit-mode-map | ||
| 871 | (kbd "C-c C-k") 'rcirc-multiline-edit-cancel) | ||
| 872 | (define-key rcirc-multiline-edit-mode-map | ||
| 873 | (kbd "ESC ESC ESC") 'rcirc-multiline-edit-cancel) | ||
| 874 | |||
| 875 | (defun rcirc-multiline-edit-submit () | ||
| 876 | "Send the text in buffer back to parent buffer." | 961 | "Send the text in buffer back to parent buffer." |
| 877 | (interactive) | 962 | (interactive) |
| 878 | (assert (eq major-mode 'rcirc-multiline-edit-mode)) | ||
| 879 | (assert rcirc-parent-buffer) | 963 | (assert rcirc-parent-buffer) |
| 880 | (untabify (point-min) (point-max)) | 964 | (untabify (point-min) (point-max)) |
| 881 | (let ((text (buffer-substring (point-min) (point-max))) | 965 | (let ((text (buffer-substring (point-min) (point-max))) |
| @@ -888,10 +972,9 @@ Create the buffer if it doesn't exist." | |||
| 888 | (set-window-configuration rcirc-window-configuration) | 972 | (set-window-configuration rcirc-window-configuration) |
| 889 | (goto-char (+ rcirc-prompt-end-marker (1- pos))))) | 973 | (goto-char (+ rcirc-prompt-end-marker (1- pos))))) |
| 890 | 974 | ||
| 891 | (defun rcirc-multiline-edit-cancel () | 975 | (defun rcirc-multiline-minor-cancel () |
| 892 | "Cancel the multiline edit." | 976 | "Cancel the multiline edit." |
| 893 | (interactive) | 977 | (interactive) |
| 894 | (assert (eq major-mode 'rcirc-multiline-edit-mode)) | ||
| 895 | (kill-buffer (current-buffer)) | 978 | (kill-buffer (current-buffer)) |
| 896 | (set-window-configuration rcirc-window-configuration)) | 979 | (set-window-configuration rcirc-window-configuration)) |
| 897 | 980 | ||
| @@ -903,7 +986,7 @@ Create the buffer if it doesn't exist." | |||
| 903 | (if (and buffer | 986 | (if (and buffer |
| 904 | (with-current-buffer buffer | 987 | (with-current-buffer buffer |
| 905 | (and (eq major-mode 'rcirc-mode) | 988 | (and (eq major-mode 'rcirc-mode) |
| 906 | (eq rcirc-process process)))) | 989 | (eq (rcirc-buffer-process) process)))) |
| 907 | buffer | 990 | buffer |
| 908 | (process-buffer process))))) | 991 | (process-buffer process))))) |
| 909 | 992 | ||
| @@ -932,8 +1015,7 @@ the of the following escape sequences replaced by the described values: | |||
| 932 | %fs Following text uses the face `rcirc-server' | 1015 | %fs Following text uses the face `rcirc-server' |
| 933 | %f[FACE] Following text uses the face FACE | 1016 | %f[FACE] Following text uses the face FACE |
| 934 | %f- Following text uses the default face | 1017 | %f- Following text uses the default face |
| 935 | %% A literal `%' character | 1018 | %% A literal `%' character" |
| 936 | " | ||
| 937 | :type '(alist :key-type (choice (string :tag "Type") | 1019 | :type '(alist :key-type (choice (string :tag "Type") |
| 938 | (const :tag "Default" t)) | 1020 | (const :tag "Default" t)) |
| 939 | :value-type string) | 1021 | :value-type string) |
| @@ -963,8 +1045,8 @@ is found by looking up RESPONSE in `rcirc-response-formats'." | |||
| 963 | "%") | 1045 | "%") |
| 964 | ((or (eq key ?n) (eq key ?N)) | 1046 | ((or (eq key ?n) (eq key ?N)) |
| 965 | ;; %n/%N -- nick | 1047 | ;; %n/%N -- nick |
| 966 | (let ((nick (concat (if (string= (with-rcirc-process-buffer | 1048 | (let ((nick (concat (if (string= (with-rcirc-process-buffer process |
| 967 | process rcirc-server) | 1049 | rcirc-server) |
| 968 | sender) | 1050 | sender) |
| 969 | "" | 1051 | "" |
| 970 | sender) | 1052 | sender) |
| @@ -1037,13 +1119,18 @@ is found by looking up RESPONSE in `rcirc-response-formats'." | |||
| 1037 | 1119 | ||
| 1038 | (defvar rcirc-activity-type nil) | 1120 | (defvar rcirc-activity-type nil) |
| 1039 | (make-variable-buffer-local 'rcirc-activity-type) | 1121 | (make-variable-buffer-local 'rcirc-activity-type) |
| 1122 | (defvar rcirc-last-sender nil) | ||
| 1123 | (make-variable-buffer-local 'rcirc-last-sender) | ||
| 1124 | (defvar rcirc-gray-toggle nil) | ||
| 1125 | (make-variable-buffer-local 'rcirc-gray-toggle) | ||
| 1040 | (defun rcirc-print (process sender response target text &optional activity) | 1126 | (defun rcirc-print (process sender response target text &optional activity) |
| 1041 | "Print TEXT in the buffer associated with TARGET. | 1127 | "Print TEXT in the buffer associated with TARGET. |
| 1042 | Format based on SENDER and RESPONSE. If ACTIVITY is non-nil, | 1128 | Format based on SENDER and RESPONSE. If ACTIVITY is non-nil, |
| 1043 | record activity." | 1129 | record activity." |
| 1130 | (or text (setq text "")) | ||
| 1044 | (unless (or (member sender rcirc-ignore-list) | 1131 | (unless (or (member sender rcirc-ignore-list) |
| 1045 | (member (with-syntax-table rcirc-nick-syntax-table | 1132 | (member (with-syntax-table rcirc-nick-syntax-table |
| 1046 | (when (string-match "^\\([^/]\\w*\\)[:,]" text) | 1133 | (when (string-match "^\\([^/]\\w*\\)\\b" text) |
| 1047 | (match-string 1 text))) rcirc-ignore-list)) | 1134 | (match-string 1 text))) rcirc-ignore-list)) |
| 1048 | (let* ((buffer (rcirc-target-buffer process sender response target text)) | 1135 | (let* ((buffer (rcirc-target-buffer process sender response target text)) |
| 1049 | (inhibit-read-only t)) | 1136 | (inhibit-read-only t)) |
| @@ -1054,8 +1141,7 @@ record activity." | |||
| 1054 | 1141 | ||
| 1055 | (unless (string= sender (rcirc-nick process)) | 1142 | (unless (string= sender (rcirc-nick process)) |
| 1056 | ;; only decode text from other senders, not ours | 1143 | ;; only decode text from other senders, not ours |
| 1057 | (setq text (decode-coding-string (or text "") | 1144 | (setq text (decode-coding-string text rcirc-decode-coding-system)) |
| 1058 | buffer-file-coding-system)) | ||
| 1059 | ;; mark the line with overlay arrow | 1145 | ;; mark the line with overlay arrow |
| 1060 | (unless (or (marker-position overlay-arrow-position) | 1146 | (unless (or (marker-position overlay-arrow-position) |
| 1061 | (get-buffer-window (current-buffer))) | 1147 | (get-buffer-window (current-buffer))) |
| @@ -1142,7 +1228,8 @@ record activity." | |||
| 1142 | nick-match) | 1228 | nick-match) |
| 1143 | (rcirc-record-activity | 1229 | (rcirc-record-activity |
| 1144 | (current-buffer) | 1230 | (current-buffer) |
| 1145 | (when (or nick-match (not (rcirc-channel-p rcirc-target))) | 1231 | (when (or nick-match (and (not (rcirc-channel-p rcirc-target)) |
| 1232 | (not rcirc-low-priority-flag))) | ||
| 1146 | 'nick))))) | 1233 | 'nick))))) |
| 1147 | 1234 | ||
| 1148 | (sit-for 0) ; displayed text before hook | 1235 | (sit-for 0) ; displayed text before hook |
| @@ -1215,18 +1302,21 @@ record activity." | |||
| 1215 | (puthash nick newchans rcirc-nick-table) | 1302 | (puthash nick newchans rcirc-nick-table) |
| 1216 | (remhash nick rcirc-nick-table))))) | 1303 | (remhash nick rcirc-nick-table))))) |
| 1217 | 1304 | ||
| 1218 | (defun rcirc-channel-nicks (process channel) | 1305 | (defun rcirc-channel-nicks (process target) |
| 1219 | "Return the list of nicks in CHANNEL sorted by last activity." | 1306 | "Return the list of nicks associated with TARGET sorted by last activity." |
| 1220 | (with-rcirc-process-buffer process | 1307 | (when target |
| 1221 | (let (nicks) | 1308 | (if (rcirc-channel-p target) |
| 1222 | (maphash | 1309 | (with-rcirc-process-buffer process |
| 1223 | (lambda (k v) | 1310 | (let (nicks) |
| 1224 | (let ((record (assoc-string channel v t))) | 1311 | (maphash |
| 1225 | (if record | 1312 | (lambda (k v) |
| 1226 | (setq nicks (cons (cons k (cdr record)) nicks))))) | 1313 | (let ((record (assoc-string target v t))) |
| 1227 | rcirc-nick-table) | 1314 | (if record |
| 1228 | (mapcar (lambda (x) (car x)) | 1315 | (setq nicks (cons (cons k (cdr record)) nicks))))) |
| 1229 | (sort nicks (lambda (x y) (time-less-p (cdr y) (cdr x)))))))) | 1316 | rcirc-nick-table) |
| 1317 | (mapcar (lambda (x) (car x)) | ||
| 1318 | (sort nicks (lambda (x y) (time-less-p (cdr y) (cdr x))))))) | ||
| 1319 | (list target)))) | ||
| 1230 | 1320 | ||
| 1231 | (defun rcirc-ignore-update-automatic (nick) | 1321 | (defun rcirc-ignore-update-automatic (nick) |
| 1232 | "Remove NICK from `rcirc-ignore-list' | 1322 | "Remove NICK from `rcirc-ignore-list' |
| @@ -1256,15 +1346,23 @@ if NICK is also on `rcirc-ignore-list-automatic'." | |||
| 1256 | (or global-mode-string (setq global-mode-string '(""))) | 1346 | (or global-mode-string (setq global-mode-string '(""))) |
| 1257 | ;; toggle the mode-line channel indicator | 1347 | ;; toggle the mode-line channel indicator |
| 1258 | (if rcirc-track-minor-mode | 1348 | (if rcirc-track-minor-mode |
| 1259 | (and (not (memq 'rcirc-activity-string global-mode-string)) | 1349 | (progn |
| 1260 | (setq global-mode-string | 1350 | (and (not (memq 'rcirc-activity-string global-mode-string)) |
| 1261 | (append global-mode-string '(rcirc-activity-string)))) | 1351 | (setq global-mode-string |
| 1352 | (append global-mode-string '(rcirc-activity-string)))) | ||
| 1353 | (add-hook 'window-configuration-change-hook | ||
| 1354 | 'rcirc-window-configuration-change)) | ||
| 1262 | (setq global-mode-string | 1355 | (setq global-mode-string |
| 1263 | (delete 'rcirc-activity-string global-mode-string)))) | 1356 | (delete 'rcirc-activity-string global-mode-string)) |
| 1357 | (remove-hook 'window-configuration-change-hook | ||
| 1358 | 'rcirc-window-configuration-change))) | ||
| 1264 | 1359 | ||
| 1265 | (or (assq 'rcirc-ignore-buffer-activity-flag minor-mode-alist) | 1360 | (or (assq 'rcirc-ignore-buffer-activity-flag minor-mode-alist) |
| 1266 | (setq minor-mode-alist | 1361 | (setq minor-mode-alist |
| 1267 | (cons '(rcirc-ignore-buffer-activity-flag " Ignore") minor-mode-alist))) | 1362 | (cons '(rcirc-ignore-buffer-activity-flag " Ignore") minor-mode-alist))) |
| 1363 | (or (assq 'rcirc-low-priority-flag minor-mode-alist) | ||
| 1364 | (setq minor-mode-alist | ||
| 1365 | (cons '(rcirc-low-priority-flag " LowPri") minor-mode-alist))) | ||
| 1268 | 1366 | ||
| 1269 | (defun rcirc-toggle-ignore-buffer-activity () | 1367 | (defun rcirc-toggle-ignore-buffer-activity () |
| 1270 | "Toggle the value of `rcirc-ignore-buffer-activity-flag'." | 1368 | "Toggle the value of `rcirc-ignore-buffer-activity-flag'." |
| @@ -1276,6 +1374,16 @@ if NICK is also on `rcirc-ignore-list-automatic'." | |||
| 1276 | "Notice activity in this buffer")) | 1374 | "Notice activity in this buffer")) |
| 1277 | (force-mode-line-update)) | 1375 | (force-mode-line-update)) |
| 1278 | 1376 | ||
| 1377 | (defun rcirc-toggle-low-priority () | ||
| 1378 | "Toggle the value of `rcirc-ignore-buffer-activity-flag'." | ||
| 1379 | (interactive) | ||
| 1380 | (setq rcirc-low-priority-flag | ||
| 1381 | (not rcirc-low-priority-flag)) | ||
| 1382 | (message (if rcirc-low-priority-flag | ||
| 1383 | "Activity in this buffer is low priority" | ||
| 1384 | "Activity in this buffer is normal priority")) | ||
| 1385 | (force-mode-line-update)) | ||
| 1386 | |||
| 1279 | (defvar rcirc-switch-to-buffer-function 'switch-to-buffer | 1387 | (defvar rcirc-switch-to-buffer-function 'switch-to-buffer |
| 1280 | "Function to use when switching buffers. | 1388 | "Function to use when switching buffers. |
| 1281 | Possible values are `switch-to-buffer', `pop-to-buffer', and | 1389 | Possible values are `switch-to-buffer', `pop-to-buffer', and |
| @@ -1284,7 +1392,7 @@ Possible values are `switch-to-buffer', `pop-to-buffer', and | |||
| 1284 | (defun rcirc-switch-to-server-buffer () | 1392 | (defun rcirc-switch-to-server-buffer () |
| 1285 | "Switch to the server buffer associated with current channel buffer." | 1393 | "Switch to the server buffer associated with current channel buffer." |
| 1286 | (interactive) | 1394 | (interactive) |
| 1287 | (funcall rcirc-switch-to-buffer-function (process-buffer rcirc-process))) | 1395 | (funcall rcirc-switch-to-buffer-function rcirc-server-buffer)) |
| 1288 | 1396 | ||
| 1289 | (defun rcirc-jump-to-first-unread-line () | 1397 | (defun rcirc-jump-to-first-unread-line () |
| 1290 | "Move the point to the first unread line in this buffer." | 1398 | "Move the point to the first unread line in this buffer." |
| @@ -1296,27 +1404,35 @@ Possible values are `switch-to-buffer', `pop-to-buffer', and | |||
| 1296 | "The buffer to switch to when there is no more activity.") | 1404 | "The buffer to switch to when there is no more activity.") |
| 1297 | 1405 | ||
| 1298 | (defun rcirc-next-active-buffer (arg) | 1406 | (defun rcirc-next-active-buffer (arg) |
| 1299 | "Go to the ARGth rcirc buffer with activity. | 1407 | "Go to the next rcirc buffer with activity. |
| 1408 | With prefix ARG, go to the next low priority buffer with activity. | ||
| 1300 | The function given by `rcirc-switch-to-buffer-function' is used to | 1409 | The function given by `rcirc-switch-to-buffer-function' is used to |
| 1301 | show the buffer." | 1410 | show the buffer." |
| 1302 | (interactive "p") | 1411 | (interactive "P") |
| 1303 | (if rcirc-activity | 1412 | (let* ((pair (rcirc-split-activity rcirc-activity)) |
| 1304 | (progn | 1413 | (lopri (car pair)) |
| 1305 | (unless (eq major-mode 'rcirc-mode) | 1414 | (hipri (cdr pair))) |
| 1306 | (setq rcirc-last-non-irc-buffer (current-buffer))) | 1415 | (if (or (and (not arg) hipri) |
| 1307 | (if (and (> arg 0) | 1416 | (and arg lopri)) |
| 1308 | (<= arg (length rcirc-activity))) | 1417 | (progn |
| 1309 | (funcall rcirc-switch-to-buffer-function | 1418 | (unless (eq major-mode 'rcirc-mode) |
| 1310 | (nth (1- arg) rcirc-activity)) | 1419 | (setq rcirc-last-non-irc-buffer (current-buffer))) |
| 1311 | (message "Invalid arg: %d" arg))) | 1420 | (funcall rcirc-switch-to-buffer-function |
| 1312 | (if (eq major-mode 'rcirc-mode) | 1421 | (car (if arg lopri hipri)))) |
| 1313 | (if (not (and rcirc-last-non-irc-buffer | 1422 | (if (eq major-mode 'rcirc-mode) |
| 1314 | (buffer-live-p rcirc-last-non-irc-buffer))) | 1423 | (if (not (and rcirc-last-non-irc-buffer |
| 1315 | (message "No IRC activity. Start something.") | 1424 | (buffer-live-p rcirc-last-non-irc-buffer))) |
| 1316 | (message "No more IRC activity. Go back to work.") | 1425 | (message "No IRC activity. Start something.") |
| 1317 | (funcall rcirc-switch-to-buffer-function rcirc-last-non-irc-buffer) | 1426 | (message "No more IRC activity. Go back to work.") |
| 1318 | (setq rcirc-last-non-irc-buffer nil)) | 1427 | (funcall rcirc-switch-to-buffer-function rcirc-last-non-irc-buffer) |
| 1319 | (message "No IRC activity.")))) | 1428 | (setq rcirc-last-non-irc-buffer nil)) |
| 1429 | (message (concat | ||
| 1430 | "No IRC activity." | ||
| 1431 | (when lopri | ||
| 1432 | (concat | ||
| 1433 | " Type C-u " | ||
| 1434 | (key-description (this-command-keys)) | ||
| 1435 | " for low priority activity.")))))))) | ||
| 1320 | 1436 | ||
| 1321 | (defvar rcirc-activity-hooks nil | 1437 | (defvar rcirc-activity-hooks nil |
| 1322 | "Hook to be run when there is channel activity. | 1438 | "Hook to be run when there is channel activity. |
| @@ -1325,13 +1441,18 @@ Functions are called with a single argument, the buffer with the | |||
| 1325 | activity. Only run if the buffer is not visible and | 1441 | activity. Only run if the buffer is not visible and |
| 1326 | `rcirc-ignore-buffer-activity-flag' is non-nil.") | 1442 | `rcirc-ignore-buffer-activity-flag' is non-nil.") |
| 1327 | 1443 | ||
| 1328 | (defun rcirc-record-activity (buffer type) | 1444 | (defun rcirc-record-activity (buffer &optional type) |
| 1329 | "Record BUFFER activity with TYPE." | 1445 | "Record BUFFER activity with TYPE." |
| 1330 | (with-current-buffer buffer | 1446 | (with-current-buffer buffer |
| 1331 | (when (not (get-buffer-window (current-buffer) t)) | 1447 | (when (not (get-buffer-window (current-buffer) t)) |
| 1332 | (add-to-list 'rcirc-activity (current-buffer)) | 1448 | (setq rcirc-activity |
| 1449 | (sort (add-to-list 'rcirc-activity (current-buffer)) | ||
| 1450 | (lambda (b1 b2) | ||
| 1451 | (let ((t1 (with-current-buffer b1 rcirc-last-post-time)) | ||
| 1452 | (t2 (with-current-buffer b2 rcirc-last-post-time))) | ||
| 1453 | (time-less-p t2 t1))))) | ||
| 1333 | (if (not rcirc-activity-type) | 1454 | (if (not rcirc-activity-type) |
| 1334 | (setq rcirc-activity-type type)) | 1455 | (setq rcirc-activity-type type)) |
| 1335 | (rcirc-update-activity-string))) | 1456 | (rcirc-update-activity-string))) |
| 1336 | (run-hook-with-args 'rcirc-activity-hooks buffer)) | 1457 | (run-hook-with-args 'rcirc-activity-hooks buffer)) |
| 1337 | 1458 | ||
| @@ -1341,22 +1462,45 @@ activity. Only run if the buffer is not visible and | |||
| 1341 | (with-current-buffer buffer | 1462 | (with-current-buffer buffer |
| 1342 | (setq rcirc-activity-type nil))) | 1463 | (setq rcirc-activity-type nil))) |
| 1343 | 1464 | ||
| 1465 | (defun rcirc-split-activity (activity) | ||
| 1466 | "Return a cons cell with ACTIVITY split into (lopri . hipri)." | ||
| 1467 | (let (lopri hipri) | ||
| 1468 | (dolist (buf rcirc-activity) | ||
| 1469 | (with-current-buffer buf | ||
| 1470 | (if (and rcirc-low-priority-flag | ||
| 1471 | (not (eq rcirc-activity-type 'nick))) | ||
| 1472 | (add-to-list 'lopri buf t) | ||
| 1473 | (add-to-list 'hipri buf t)))) | ||
| 1474 | (cons lopri hipri))) | ||
| 1475 | |||
| 1344 | ;; TODO: add mouse properties | 1476 | ;; TODO: add mouse properties |
| 1345 | (defun rcirc-update-activity-string () | 1477 | (defun rcirc-update-activity-string () |
| 1346 | "Update mode-line string." | 1478 | "Update mode-line string." |
| 1347 | (setq rcirc-activity-string | 1479 | (let* ((pair (rcirc-split-activity rcirc-activity)) |
| 1348 | (if (not rcirc-activity) | 1480 | (lopri (car pair)) |
| 1349 | "" | 1481 | (hipri (cdr pair))) |
| 1350 | (concat "-[" | 1482 | (setq rcirc-activity-string |
| 1351 | (mapconcat | 1483 | (if (or hipri lopri) |
| 1352 | (lambda (b) | 1484 | (concat "-" |
| 1353 | (let ((s (rcirc-short-buffer-name b))) | 1485 | (and hipri "[") |
| 1354 | (with-current-buffer b | 1486 | (rcirc-activity-string hipri) |
| 1355 | (if (not (eq rcirc-activity-type 'nick)) | 1487 | (and hipri lopri ",") |
| 1356 | s | 1488 | (and lopri |
| 1357 | (rcirc-facify s 'rcirc-mode-line-nick))))) | 1489 | (concat "(" |
| 1358 | rcirc-activity ",") | 1490 | (rcirc-activity-string lopri) |
| 1359 | "]-")))) | 1491 | ")")) |
| 1492 | (and hipri "]") | ||
| 1493 | "-") | ||
| 1494 | "-[]-")))) | ||
| 1495 | |||
| 1496 | (defun rcirc-activity-string (buffers) | ||
| 1497 | (mapconcat (lambda (b) | ||
| 1498 | (let ((s (rcirc-short-buffer-name b))) | ||
| 1499 | (with-current-buffer b | ||
| 1500 | (if (not (eq rcirc-activity-type 'nick)) | ||
| 1501 | s | ||
| 1502 | (rcirc-facify s 'rcirc-mode-line-nick))))) | ||
| 1503 | buffers ",")) | ||
| 1360 | 1504 | ||
| 1361 | (defun rcirc-short-buffer-name (buffer) | 1505 | (defun rcirc-short-buffer-name (buffer) |
| 1362 | "Return a short name for BUFFER to use in the modeline indicator." | 1506 | "Return a short name for BUFFER to use in the modeline indicator." |
| @@ -1370,9 +1514,11 @@ Also, clear the overlay arrow if the current buffer is now hidden." | |||
| 1370 | (let ((current-now-hidden t)) | 1514 | (let ((current-now-hidden t)) |
| 1371 | (walk-windows (lambda (w) | 1515 | (walk-windows (lambda (w) |
| 1372 | (let ((buf (window-buffer w))) | 1516 | (let ((buf (window-buffer w))) |
| 1373 | (rcirc-clear-activity buf) | 1517 | (when (eq major-mode 'rcirc-mode) |
| 1374 | (when (eq buf rcirc-current-buffer) | 1518 | (rcirc-clear-activity buf) |
| 1375 | (setq current-now-hidden nil))))) | 1519 | (when (eq buf rcirc-current-buffer) |
| 1520 | (setq current-now-hidden nil)))))) | ||
| 1521 | ;; add overlay arrow if the buffer isn't displayed | ||
| 1376 | (when (and rcirc-current-buffer current-now-hidden) | 1522 | (when (and rcirc-current-buffer current-now-hidden) |
| 1377 | (with-current-buffer rcirc-current-buffer | 1523 | (with-current-buffer rcirc-current-buffer |
| 1378 | (when (eq major-mode 'rcirc-mode) | 1524 | (when (eq major-mode 'rcirc-mode) |
| @@ -1395,8 +1541,9 @@ Also, clear the overlay arrow if the current buffer is now hidden." | |||
| 1395 | rcirc-buffer-alist)) | 1541 | rcirc-buffer-alist)) |
| 1396 | (rcirc-process-list))))) | 1542 | (rcirc-process-list))))) |
| 1397 | (dolist (i (rcirc-abbreviate bufalist)) | 1543 | (dolist (i (rcirc-abbreviate bufalist)) |
| 1398 | (with-current-buffer (cdr i) | 1544 | (when (buffer-live-p (cdr i)) |
| 1399 | (setq rcirc-short-buffer-name (car i)))))) | 1545 | (with-current-buffer (cdr i) |
| 1546 | (setq rcirc-short-buffer-name (car i))))))) | ||
| 1400 | 1547 | ||
| 1401 | (defun rcirc-abbreviate (pairs) | 1548 | (defun rcirc-abbreviate (pairs) |
| 1402 | (apply 'append (mapcar 'rcirc-rebuild-tree (rcirc-make-trees pairs)))) | 1549 | (apply 'append (mapcar 'rcirc-rebuild-tree (rcirc-make-trees pairs)))) |
| @@ -1451,11 +1598,10 @@ Also, clear the overlay arrow if the current buffer is now hidden." | |||
| 1451 | "Define a command." | 1598 | "Define a command." |
| 1452 | `(defun ,(intern (concat "rcirc-cmd-" (symbol-name command))) | 1599 | `(defun ,(intern (concat "rcirc-cmd-" (symbol-name command))) |
| 1453 | (,@argument &optional process target) | 1600 | (,@argument &optional process target) |
| 1454 | ,(concat docstring "\n\nNote: If PROCESS or TARGET are nil, the values of" | 1601 | ,(concat docstring "\n\nNote: If PROCESS or TARGET are nil, the values given" |
| 1455 | "\nbuffer local variables `rcirc-process' and `rcirc-target'," | 1602 | "\nby `rcirc-buffer-process' and `rcirc-target' will be used.") |
| 1456 | "\nwill be used.") | ||
| 1457 | ,interactive-form | 1603 | ,interactive-form |
| 1458 | (let ((process (or process rcirc-process)) | 1604 | (let ((process (or process (rcirc-buffer-process))) |
| 1459 | (target (or target rcirc-target))) | 1605 | (target (or target rcirc-target))) |
| 1460 | ,@body))) | 1606 | ,@body))) |
| 1461 | 1607 | ||
| @@ -1465,8 +1611,8 @@ Also, clear the overlay arrow if the current buffer is now hidden." | |||
| 1465 | (if (null message) | 1611 | (if (null message) |
| 1466 | (progn | 1612 | (progn |
| 1467 | (setq target (completing-read "Message nick: " | 1613 | (setq target (completing-read "Message nick: " |
| 1468 | (with-rcirc-process-buffer rcirc-process | 1614 | (with-rcirc-server-buffer |
| 1469 | rcirc-nick-table))) | 1615 | rcirc-nick-table))) |
| 1470 | (when (> (length target) 0) | 1616 | (when (> (length target) 0) |
| 1471 | (setq message (read-string (format "Message %s: " target))) | 1617 | (setq message (read-string (format "Message %s: " target))) |
| 1472 | (when (> (length message) 0) | 1618 | (when (> (length message) 0) |
| @@ -1480,8 +1626,7 @@ Also, clear the overlay arrow if the current buffer is now hidden." | |||
| 1480 | (defun-rcirc-command query (nick) | 1626 | (defun-rcirc-command query (nick) |
| 1481 | "Open a private chat buffer to NICK." | 1627 | "Open a private chat buffer to NICK." |
| 1482 | (interactive (list (completing-read "Query nick: " | 1628 | (interactive (list (completing-read "Query nick: " |
| 1483 | (with-rcirc-process-buffer rcirc-process | 1629 | (with-rcirc-server-buffer rcirc-nick-table)))) |
| 1484 | rcirc-nick-table)))) | ||
| 1485 | (let ((existing-buffer (rcirc-get-buffer process nick))) | 1630 | (let ((existing-buffer (rcirc-get-buffer process nick))) |
| 1486 | (switch-to-buffer (or existing-buffer | 1631 | (switch-to-buffer (or existing-buffer |
| 1487 | (rcirc-get-buffer-create process nick))) | 1632 | (rcirc-get-buffer-create process nick))) |
| @@ -1493,9 +1638,9 @@ Also, clear the overlay arrow if the current buffer is now hidden." | |||
| 1493 | (interactive "sJoin channel: ") | 1638 | (interactive "sJoin channel: ") |
| 1494 | (let ((buffer (rcirc-get-buffer-create process | 1639 | (let ((buffer (rcirc-get-buffer-create process |
| 1495 | (car (split-string channel))))) | 1640 | (car (split-string channel))))) |
| 1641 | (rcirc-send-string process (concat "JOIN " channel)) | ||
| 1496 | (when (not (eq (selected-window) (minibuffer-window))) | 1642 | (when (not (eq (selected-window) (minibuffer-window))) |
| 1497 | (funcall rcirc-switch-to-buffer-function buffer)) | 1643 | (funcall rcirc-switch-to-buffer-function buffer)))) |
| 1498 | (rcirc-send-string process (concat "JOIN " channel)))) | ||
| 1499 | 1644 | ||
| 1500 | (defun-rcirc-command part (channel) | 1645 | (defun-rcirc-command part (channel) |
| 1501 | "Part CHANNEL." | 1646 | "Part CHANNEL." |
| @@ -1544,8 +1689,7 @@ With a prefix arg, prompt for new topic." | |||
| 1544 | "Request information from server about NICK." | 1689 | "Request information from server about NICK." |
| 1545 | (interactive (list | 1690 | (interactive (list |
| 1546 | (completing-read "Whois: " | 1691 | (completing-read "Whois: " |
| 1547 | (with-rcirc-process-buffer rcirc-process | 1692 | (with-rcirc-server-buffer rcirc-nick-table)))) |
| 1548 | rcirc-nick-table)))) | ||
| 1549 | (rcirc-send-string process (concat "WHOIS " nick))) | 1693 | (rcirc-send-string process (concat "WHOIS " nick))) |
| 1550 | 1694 | ||
| 1551 | (defun-rcirc-command mode (args) | 1695 | (defun-rcirc-command mode (args) |
| @@ -1573,8 +1717,9 @@ With a prefix arg, prompt for new topic." | |||
| 1573 | "Kick NICK from current channel." | 1717 | "Kick NICK from current channel." |
| 1574 | (interactive (list | 1718 | (interactive (list |
| 1575 | (concat (completing-read "Kick nick: " | 1719 | (concat (completing-read "Kick nick: " |
| 1576 | (rcirc-channel-nicks rcirc-process | 1720 | (rcirc-channel-nicks |
| 1577 | rcirc-target)) | 1721 | (rcirc-buffer-process) |
| 1722 | rcirc-target)) | ||
| 1578 | (read-from-minibuffer "Kick reason: ")))) | 1723 | (read-from-minibuffer "Kick reason: ")))) |
| 1579 | (let* ((arglist (split-string arg)) | 1724 | (let* ((arglist (split-string arg)) |
| 1580 | (argstring (concat (car arglist) " :" | 1725 | (argstring (concat (car arglist) " :" |
| @@ -1768,7 +1913,7 @@ FUNCTION takes 3 arguments, MATCH-START, MATCH-END, and STRING." | |||
| 1768 | ((string-match "^\\[\\(#[^ ]+\\)\\]" message) | 1913 | ((string-match "^\\[\\(#[^ ]+\\)\\]" message) |
| 1769 | (match-string 1 message)) | 1914 | (match-string 1 message)) |
| 1770 | (sender | 1915 | (sender |
| 1771 | (if (string= sender (rcirc-server process)) | 1916 | (if (string= sender (rcirc-server-name process)) |
| 1772 | nil ; server notice | 1917 | nil ; server notice |
| 1773 | sender))) | 1918 | sender))) |
| 1774 | message t)))) | 1919 | message t)))) |
| @@ -1782,19 +1927,14 @@ FUNCTION takes 3 arguments, MATCH-START, MATCH-END, and STRING." | |||
| 1782 | (rcirc-print process sender "JOIN" channel "") | 1927 | (rcirc-print process sender "JOIN" channel "") |
| 1783 | 1928 | ||
| 1784 | ;; print in private chat buffer if it exists | 1929 | ;; print in private chat buffer if it exists |
| 1785 | (when (rcirc-get-buffer rcirc-process sender) | 1930 | (when (rcirc-get-buffer (rcirc-buffer-process) sender) |
| 1786 | (rcirc-print process sender "JOIN" sender channel)) | 1931 | (rcirc-print process sender "JOIN" sender channel)) |
| 1787 | 1932 | ||
| 1788 | (rcirc-put-nick-channel process sender channel))) | 1933 | (rcirc-put-nick-channel process sender channel))) |
| 1789 | 1934 | ||
| 1790 | ;; PART and KICK are handled the same way | 1935 | ;; PART and KICK are handled the same way |
| 1791 | (defun rcirc-handler-PART-or-KICK (process response channel sender nick args) | 1936 | (defun rcirc-handler-PART-or-KICK (process response channel sender nick args) |
| 1792 | (rcirc-print process sender response channel (concat channel " " args)) | 1937 | (rcirc-ignore-update-automatic nick) |
| 1793 | |||
| 1794 | ;; print in private chat buffer if it exists | ||
| 1795 | (when (rcirc-get-buffer rcirc-process nick) | ||
| 1796 | (rcirc-print process sender response nick (concat channel " " args))) | ||
| 1797 | |||
| 1798 | (if (not (string= nick (rcirc-nick process))) | 1938 | (if (not (string= nick (rcirc-nick process))) |
| 1799 | ;; this is someone else leaving | 1939 | ;; this is someone else leaving |
| 1800 | (rcirc-remove-nick-channel process nick channel) | 1940 | (rcirc-remove-nick-channel process nick channel) |
| @@ -1810,14 +1950,27 @@ FUNCTION takes 3 arguments, MATCH-START, MATCH-END, and STRING." | |||
| 1810 | (setq rcirc-target nil)))))) | 1950 | (setq rcirc-target nil)))))) |
| 1811 | 1951 | ||
| 1812 | (defun rcirc-handler-PART (process sender args text) | 1952 | (defun rcirc-handler-PART (process sender args text) |
| 1813 | (rcirc-ignore-update-automatic sender) | 1953 | (let* ((channel (car args)) |
| 1814 | (rcirc-handler-PART-or-KICK process "PART" | 1954 | (reason (cadr args)) |
| 1815 | (car args) sender sender | 1955 | (message (concat channel " " reason))) |
| 1816 | (cadr args))) | 1956 | (rcirc-print process sender "PART" channel message) |
| 1957 | ;; print in private chat buffer if it exists | ||
| 1958 | (when (rcirc-get-buffer (rcirc-buffer-process) sender) | ||
| 1959 | (rcirc-print process sender "PART" sender message)) | ||
| 1960 | |||
| 1961 | (rcirc-handler-PART-or-KICK process "PART" channel sender sender reason))) | ||
| 1817 | 1962 | ||
| 1818 | (defun rcirc-handler-KICK (process sender args text) | 1963 | (defun rcirc-handler-KICK (process sender args text) |
| 1819 | (rcirc-handler-PART-or-KICK process "KICK" (car args) sender (cadr args) | 1964 | (let* ((channel (car args)) |
| 1820 | (caddr args))) | 1965 | (nick (cadr args)) |
| 1966 | (reason (caddr args)) | ||
| 1967 | (message (concat nick " " channel " " reason))) | ||
| 1968 | (rcirc-print process sender "KICK" channel message t) | ||
| 1969 | ;; print in private chat buffer if it exists | ||
| 1970 | (when (rcirc-get-buffer (rcirc-buffer-process) nick) | ||
| 1971 | (rcirc-print process sender "KICK" nick message)) | ||
| 1972 | |||
| 1973 | (rcirc-handler-PART-or-KICK process "KICK" channel sender nick reason))) | ||
| 1821 | 1974 | ||
| 1822 | (defun rcirc-handler-QUIT (process sender args text) | 1975 | (defun rcirc-handler-QUIT (process sender args text) |
| 1823 | (rcirc-ignore-update-automatic sender) | 1976 | (rcirc-ignore-update-automatic sender) |
| @@ -1826,7 +1979,7 @@ FUNCTION takes 3 arguments, MATCH-START, MATCH-END, and STRING." | |||
| 1826 | (rcirc-nick-channels process sender)) | 1979 | (rcirc-nick-channels process sender)) |
| 1827 | 1980 | ||
| 1828 | ;; print in private chat buffer if it exists | 1981 | ;; print in private chat buffer if it exists |
| 1829 | (when (rcirc-get-buffer rcirc-process sender) | 1982 | (when (rcirc-get-buffer (rcirc-buffer-process) sender) |
| 1830 | (rcirc-print process sender "QUIT" sender (apply 'concat args))) | 1983 | (rcirc-print process sender "QUIT" sender (apply 'concat args))) |
| 1831 | 1984 | ||
| 1832 | (rcirc-nick-remove process sender)) | 1985 | (rcirc-nick-remove process sender)) |
| @@ -1875,6 +2028,21 @@ FUNCTION takes 3 arguments, MATCH-START, MATCH-END, and STRING." | |||
| 1875 | (with-current-buffer (rcirc-get-buffer process (car args)) | 2028 | (with-current-buffer (rcirc-get-buffer process (car args)) |
| 1876 | (setq rcirc-topic topic)))) | 2029 | (setq rcirc-topic topic)))) |
| 1877 | 2030 | ||
| 2031 | (defvar rcirc-nick-away-alist nil) | ||
| 2032 | (defun rcirc-handler-301 (process sender args text) | ||
| 2033 | "RPL_AWAY" | ||
| 2034 | (let* ((nick (cadr args)) | ||
| 2035 | (rec (assoc-string nick rcirc-nick-away-alist)) | ||
| 2036 | (away-message (caddr args))) | ||
| 2037 | (when (or (not rec) | ||
| 2038 | (not (string= (cdr rec) away-message))) | ||
| 2039 | ;; away message has changed | ||
| 2040 | (rcirc-handler-generic process "AWAY" nick (cdr args) text) | ||
| 2041 | (if rec | ||
| 2042 | (setcdr rec away-message) | ||
| 2043 | (setq rcirc-nick-away-alist (cons (cons nick away-message) | ||
| 2044 | rcirc-nick-away-alist)))))) | ||
| 2045 | |||
| 1878 | (defun rcirc-handler-332 (process sender args text) | 2046 | (defun rcirc-handler-332 (process sender args text) |
| 1879 | "RPL_TOPIC" | 2047 | "RPL_TOPIC" |
| 1880 | (let ((buffer (or (rcirc-get-buffer process (cadr args)) | 2048 | (let ((buffer (or (rcirc-get-buffer process (cadr args)) |
| @@ -1948,9 +2116,10 @@ FUNCTION takes 3 arguments, MATCH-START, MATCH-END, and STRING." | |||
| 1948 | "Send authentication to process associated with current buffer. | 2116 | "Send authentication to process associated with current buffer. |
| 1949 | Passwords are stored in `rcirc-authinfo' (which see)." | 2117 | Passwords are stored in `rcirc-authinfo' (which see)." |
| 1950 | (interactive) | 2118 | (interactive) |
| 1951 | (with-rcirc-process-buffer rcirc-process | 2119 | (with-rcirc-server-buffer |
| 1952 | (dolist (i rcirc-authinfo) | 2120 | (dolist (i rcirc-authinfo) |
| 1953 | (let ((server (car i)) | 2121 | (let ((process (rcirc-buffer-process)) |
| 2122 | (server (car i)) | ||
| 1954 | (nick (caddr i)) | 2123 | (nick (caddr i)) |
| 1955 | (method (cadr i)) | 2124 | (method (cadr i)) |
| 1956 | (args (cdddr i))) | 2125 | (args (cdddr i))) |
| @@ -1958,19 +2127,19 @@ Passwords are stored in `rcirc-authinfo' (which see)." | |||
| 1958 | (string-match nick rcirc-nick)) | 2127 | (string-match nick rcirc-nick)) |
| 1959 | (cond ((equal method 'nickserv) | 2128 | (cond ((equal method 'nickserv) |
| 1960 | (rcirc-send-string | 2129 | (rcirc-send-string |
| 1961 | rcirc-process | 2130 | process |
| 1962 | (concat | 2131 | (concat |
| 1963 | "PRIVMSG nickserv :identify " | 2132 | "PRIVMSG nickserv :identify " |
| 1964 | (car args)))) | 2133 | (car args)))) |
| 1965 | ((equal method 'chanserv) | 2134 | ((equal method 'chanserv) |
| 1966 | (rcirc-send-string | 2135 | (rcirc-send-string |
| 1967 | rcirc-process | 2136 | process |
| 1968 | (concat | 2137 | (concat |
| 1969 | "PRIVMSG chanserv :identify " | 2138 | "PRIVMSG chanserv :identify " |
| 1970 | (cadr args) " " (car args)))) | 2139 | (cadr args) " " (car args)))) |
| 1971 | ((equal method 'bitlbee) | 2140 | ((equal method 'bitlbee) |
| 1972 | (rcirc-send-string | 2141 | (rcirc-send-string |
| 1973 | rcirc-process | 2142 | process |
| 1974 | (concat "PRIVMSG &bitlbee :identify " (car args)))) | 2143 | (concat "PRIVMSG &bitlbee :identify " (car args)))) |
| 1975 | (t | 2144 | (t |
| 1976 | (message "No %S authentication method defined" | 2145 | (message "No %S authentication method defined" |
| @@ -2102,6 +2271,7 @@ Passwords are stored in `rcirc-authinfo' (which see)." | |||
| 2102 | '((t (:bold t))) | 2271 | '((t (:bold t))) |
| 2103 | "The face used indicate activity directed at you." | 2272 | "The face used indicate activity directed at you." |
| 2104 | :group 'rcirc-faces) | 2273 | :group 'rcirc-faces) |
| 2274 | |||
| 2105 | 2275 | ||
| 2106 | ;; When using M-x flyspell-mode, only check words after the prompt | 2276 | ;; When using M-x flyspell-mode, only check words after the prompt |
| 2107 | (put 'rcirc-mode 'flyspell-mode-predicate 'rcirc-looking-at-input) | 2277 | (put 'rcirc-mode 'flyspell-mode-predicate 'rcirc-looking-at-input) |