aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2007-06-13 21:17:18 +0000
committerStefan Monnier2007-06-13 21:17:18 +0000
commit195eca781ccdeca3756434c28ba996112abda58f (patch)
tree9d6197894310aad0996fc6d369b5b8cf0d532f96
parent97311ec3a4d914e61a142e5eb790f830ec71018c (diff)
downloademacs-195eca781ccdeca3756434c28ba996112abda58f.tar.gz
emacs-195eca781ccdeca3756434c28ba996112abda58f.zip
(rcirc-format-response-string): Use rcirc-nick-syntax
around bright and dim regexps. Make sure bright and dim matches use word anchors. Send text through rcirc-markup functions. (rcirc-url-regexp): Add single quote character. (rcirc-connect): Write logs to disk on auto-save-hook. Make server a non-optional argument. (rcirc-log-alist): New variable. (rcirc-log-directory): Make customizable. (rcirc-log-flag): New customizable variable. (rcirc-log): New function. (rcirc-print): Use above function. (rcirc-log-write): New function. (rcirc-generate-new-buffer-name): Strip text properties. (rcirc-switch-to-buffer-function): Remove variable. (rcirc-last-non-irc-buffer): Remove variable. (rcirc-non-irc-buffer): Add function. (rcirc-next-active-buffer): Use above function. (rcirc-keepalive): Send KEEPALIVE ctcp instead of a PING. (rcirc-handler-ctcp-KEEPALIVE): Add handler. (rcirc-handler-CTCP): Don't print KEEPALIVE responses. (rcirc-omit-mode): Add minor-mode. (rcirc-mode-map): Change C-c C-o binding. (rcirc-mode): Clear mode-line-process. Use a custom fill-paragraph-function. Set up buffer-invisibility-spec. (rcirc-response-formats): Remove timestamp code. (rcirc-omit-responses): Add variable. (rcirc-print): Don't put the overlay arrow on potentially omitted lines. Log line to disk. Record activity for private messages from /dim nicks. Facify the fill-prefix with rcirc-timestamp face. (rcirc-jump-to-first-unread-line): Print message if there is no unread text. (rcirc-clear-unread): New function. (rcirc-markup-text-functions): Add variable. (rcirc-markup-timestamp, rcirc-markup-fill): Add functions. (rcirc-debug): Don't mess with window configuration. (rcirc-send-message): Send message before printing locally. Add SILENT argument, do not print message if non-nil. (rcirc-visible-buffers): New function and variable. (rcirc-window-configuration-change-1): Add function. (rcirc-target-buffer): Make sure ACTIONs don't get sent to the server buffer. (rcirc-clean-up-buffer): Set rcirc-target to nil when finished. (rcirc-fill-paragraph): Add function. (rcirc-record-activity, rcirc-window-configuration-change-1): Only update the activity string if it has actually changed. (rcirc-update-activity-string): Remove padding characters from the mode-line string. (rcirc-disconnect-buffer): New function to be called when a channel is parted or the user quits. (rcirc-server-name): Warn when the server-name hasn't been set. (rcirc-window-configuration-change): Postpone work until post-command-hook. (rcirc-window-configuration-change-1): Update mode-line and overlay arrows here. (rcirc-authenticate): Fix chanserv identification. (rcirc-default-server): Remove variable. (rcirc): Connect according to rcirc-connections. (rcirc-connections): Add variable. (rcirc-startup-channels-alist): Remove variable. (rcirc-startup-channels): Remove function.
-rw-r--r--lisp/ChangeLog63
-rw-r--r--lisp/net/rcirc.el797
2 files changed, 525 insertions, 335 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 602ff2d7838..ee072eca720 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,66 @@
12007-06-13 Ryan Yeske <rcyeske@gmail.com>
2
3 * rcirc.el (rcirc-format-response-string): Use rcirc-nick-syntax
4 around bright and dim regexps. Make sure bright and dim matches
5 use word anchors. Send text through rcirc-markup functions.
6 (rcirc-url-regexp): Add single quote character.
7 (rcirc-connect): Write logs to disk on auto-save-hook.
8 Make server a non-optional argument.
9 (rcirc-log-alist): New variable.
10 (rcirc-log-directory): Make customizable.
11 (rcirc-log-flag): New customizable variable.
12 (rcirc-log): New function.
13 (rcirc-print): Use above function.
14 (rcirc-log-write): New function.
15 (rcirc-generate-new-buffer-name): Strip text properties.
16 (rcirc-switch-to-buffer-function): Remove variable.
17 (rcirc-last-non-irc-buffer): Remove variable.
18 (rcirc-non-irc-buffer): Add function.
19 (rcirc-next-active-buffer): Use above function.
20 (rcirc-keepalive): Send KEEPALIVE ctcp instead of a PING.
21 (rcirc-handler-ctcp-KEEPALIVE): Add handler.
22 (rcirc-handler-CTCP): Don't print KEEPALIVE responses.
23 (rcirc-omit-mode): Add minor-mode.
24 (rcirc-mode-map): Change C-c C-o binding.
25 (rcirc-mode): Clear mode-line-process. Use a custom
26 fill-paragraph-function. Set up buffer-invisibility-spec.
27 (rcirc-response-formats): Remove timestamp code.
28 (rcirc-omit-responses): Add variable.
29 (rcirc-print): Don't put the overlay arrow on potentially omitted
30 lines. Log line to disk. Record activity for private messages
31 from /dim nicks. Facify the fill-prefix with rcirc-timestamp face.
32 (rcirc-jump-to-first-unread-line): Print message if there is no
33 unread text.
34 (rcirc-clear-unread): New function.
35 (rcirc-markup-text-functions): Add variable.
36 (rcirc-markup-timestamp, rcirc-markup-fill): Add functions.
37 (rcirc-debug): Don't mess with window configuration.
38 (rcirc-send-message): Send message before printing locally.
39 Add SILENT argument, do not print message if non-nil.
40 (rcirc-visible-buffers): New function and variable.
41 (rcirc-window-configuration-change-1): Add function.
42 (rcirc-target-buffer): Make sure ACTIONs don't get sent to the
43 server buffer.
44 (rcirc-clean-up-buffer): Set rcirc-target to nil when finished.
45 (rcirc-fill-paragraph): Add function.
46 (rcirc-record-activity, rcirc-window-configuration-change-1):
47 Only update the activity string if it has actually changed.
48 (rcirc-update-activity-string): Remove padding characters from the
49 mode-line string.
50 (rcirc-disconnect-buffer): New function to be called when a
51 channel is parted or the user quits.
52 (rcirc-server-name): Warn when the server-name hasn't been set.
53 (rcirc-window-configuration-change): Postpone work until
54 post-command-hook.
55 (rcirc-window-configuration-change-1): Update mode-line and
56 overlay arrows here.
57 (rcirc-authenticate): Fix chanserv identification.
58 (rcirc-default-server): Remove variable.
59 (rcirc): Connect according to rcirc-connections.
60 (rcirc-connections): Add variable.
61 (rcirc-startup-channels-alist): Remove variable.
62 (rcirc-startup-channels): Remove function.
63
12007-06-13 Stefan Monnier <monnier@iro.umontreal.ca> 642007-06-13 Stefan Monnier <monnier@iro.umontreal.ca>
2 65
3 * diff-mode.el (diff-font-lock-keywords): Fix M. Kifer's last change. 66 * diff-mode.el (diff-font-lock-keywords): Fix M. Kifer's last change.
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index 60d81aedb7a..04f3fa45ceb 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -55,9 +55,24 @@
55 :link '(custom-manual "(rcirc)") 55 :link '(custom-manual "(rcirc)")
56 :group 'applications) 56 :group 'applications)
57 57
58(defcustom rcirc-default-server "irc.freenode.net" 58(defcustom rcirc-connections
59 "The default server to connect to." 59 '(("irc.freenode.net" :channels ("#rcirc")))
60 :type 'string 60 "An alist of IRC connections to establish when running `rcirc'.
61Each element looks like (SERVER-NAME PARAMETERS).
62
63SERVER-NAME is a string describing the server to connect
64to.
65
66PARAMETERS is a plist of optional connection parameters. Valid
67properties are: nick (a string), port (number or string),
68user-name (string), full-name (string), and channels (list of
69strings)."
70 :type '(alist :key-type string
71 :value-type (plist :options ((nick string)
72 (port integer)
73 (user-name string)
74 (full-name string)
75 (channels (repeat string)))))
61 :group 'rcirc) 76 :group 'rcirc)
62 77
63(defcustom rcirc-default-port 6667 78(defcustom rcirc-default-port 6667
@@ -82,12 +97,6 @@
82 :type 'string 97 :type 'string
83 :group 'rcirc) 98 :group 'rcirc)
84 99
85(defcustom rcirc-startup-channels-alist '(("^irc.freenode.net$" "#rcirc"))
86 "Alist of channels to join at startup.
87Each element looks like (SERVER-REGEXP . CHANNEL-LIST)."
88 :type '(alist :key-type string :value-type (repeat string))
89 :group 'rcirc)
90
91(defcustom rcirc-fill-flag t 100(defcustom rcirc-fill-flag t
92 "*Non-nil means line-wrap messages printed in channel buffers." 101 "*Non-nil means line-wrap messages printed in channel buffers."
93 :type 'boolean 102 :type 'boolean
@@ -95,11 +104,9 @@ Each element looks like (SERVER-REGEXP . CHANNEL-LIST)."
95 104
96(defcustom rcirc-fill-column nil 105(defcustom rcirc-fill-column nil
97 "*Column beyond which automatic line-wrapping should happen. 106 "*Column beyond which automatic line-wrapping should happen.
98If nil, use value of `fill-column'. 107If nil, use value of `fill-column'. If 'frame-width, use the
99If `window-width', use the window's width as maximum. 108maximum frame width."
100If `frame-width', use the frame's width as maximum."
101 :type '(choice (const :tag "Value of `fill-column'") 109 :type '(choice (const :tag "Value of `fill-column'")
102 (const :tag "Full window width" window-width)
103 (const :tag "Full frame width" frame-width) 110 (const :tag "Full frame width" frame-width)
104 (integer :tag "Number of columns")) 111 (integer :tag "Number of columns"))
105 :group 'rcirc) 112 :group 'rcirc)
@@ -120,6 +127,11 @@ underneath each nick."
120 "If non-nil, activity in this buffer is considered low priority.") 127 "If non-nil, activity in this buffer is considered low priority.")
121(make-variable-buffer-local 'rcirc-low-priority-flag) 128(make-variable-buffer-local 'rcirc-low-priority-flag)
122 129
130(defvar rcirc-omit-mode nil
131 "Non-nil if Rcirc-Omit mode is enabled.
132Use the command `rcirc-omit-mode' to change this variable.")
133(make-variable-buffer-local 'rcirc-omit-mode)
134
123(defcustom rcirc-time-format "%H:%M " 135(defcustom rcirc-time-format "%H:%M "
124 "*Describes how timestamps are printed. 136 "*Describes how timestamps are printed.
125Used as the first arg to `format-time-string'." 137Used as the first arg to `format-time-string'."
@@ -145,7 +157,8 @@ number. If zero or nil, no truncating is done."
145 :group 'rcirc) 157 :group 'rcirc)
146 158
147(defcustom rcirc-scroll-show-maximum-output t 159(defcustom rcirc-scroll-show-maximum-output t
148 "*If non-nil, scroll buffer to keep the point at the bottom of the window." 160 "*If non-nil, scroll buffer to keep the point at the bottom of
161the window."
149 :type 'boolean 162 :type 'boolean
150 :group 'rcirc) 163 :group 'rcirc)
151 164
@@ -319,36 +332,69 @@ and the cdr part is used for encoding."
319(defconst rcirc-id-string (concat "rcirc on GNU Emacs " emacs-version)) 332(defconst rcirc-id-string (concat "rcirc on GNU Emacs " emacs-version))
320 333
321(defvar rcirc-startup-channels nil) 334(defvar rcirc-startup-channels nil)
335
322;;;###autoload 336;;;###autoload
323(defun rcirc (arg) 337(defun rcirc (arg)
324 "Connect to IRC. 338 "Connect to all servers in `rcirc-connections'.
325If ARG is non-nil, prompt for a server to connect to." 339
340Do not connect to a server if it is already connected.
341
342If ARG is non-nil, instead prompt for connection parameters."
326 (interactive "P") 343 (interactive "P")
327 (if arg 344 (if arg
328 (let* ((server (read-string "IRC Server: " rcirc-default-server)) 345 (let* ((server (completing-read "IRC Server: "
329 (port (read-string "IRC Port: " (number-to-string rcirc-default-port))) 346 rcirc-connections
330 (nick (read-string "IRC Nick: " rcirc-default-nick)) 347 nil nil
348 (caar rcirc-connections)))
349 (server-plist (cdr (assoc-string server rcirc-connections)))
350 (port (read-string "IRC Port: "
351 (number-to-string
352 (or (plist-get server-plist 'port)
353 rcirc-default-port))))
354 (nick (read-string "IRC Nick: "
355 (or (plist-get server-plist 'nick)
356 rcirc-default-nick)))
331 (channels (split-string 357 (channels (split-string
332 (read-string "IRC Channels: " 358 (read-string "IRC Channels: "
333 (mapconcat 'identity (rcirc-startup-channels server) " ")) 359 (mapconcat 'identity
360 (plist-get server-plist
361 'channels)
362 " "))
334 "[, ]+" t))) 363 "[, ]+" t)))
335 (rcirc-connect server port nick rcirc-default-user-name rcirc-default-user-full-name 364 (rcirc-connect server port nick rcirc-default-user-name
365 rcirc-default-user-full-name
336 channels)) 366 channels))
337 ;; make new connection using defaults unless already connected to 367 ;; connect to servers in `rcirc-connections'
338 ;; the default rcirc-server 368 (let (connected-servers)
339 (let (connected) 369 (dolist (c rcirc-connections)
340 (dolist (p (rcirc-process-list)) 370 (let ((server (car c))
341 (when (string= rcirc-default-server (process-name p)) 371 (port (or (plist-get (cdr c) 'port) rcirc-default-port))
342 (setq connected p))) 372 (nick (or (plist-get (cdr c) 'nick) rcirc-default-nick))
343 (if (not connected) 373 (user-name (or (plist-get (cdr c) 'user-name)
344 (rcirc-connect rcirc-default-server rcirc-default-port 374 rcirc-default-user-name))
345 rcirc-default-nick rcirc-default-user-name 375 (full-name (or (plist-get (cdr c) 'full-name)
346 rcirc-default-user-full-name 376 rcirc-default-user-full-name))
347 (rcirc-startup-channels rcirc-default-server)) 377 (channels (plist-get (cdr c) 'channels)))
348 (switch-to-buffer (process-buffer connected)) 378 (when server
349 (message "Connected to %s" 379 (let (connected)
350 (process-contact (get-buffer-process (current-buffer)) 380 (dolist (p (rcirc-process-list))
351 :host)))))) 381 (when (string= server (process-name p))
382 (setq connected p)))
383 (if (not connected)
384 (condition-case e
385 (rcirc-connect server port nick user-name
386 full-name channels)
387 (quit (message "Quit connecting to %s" server)))
388 (with-current-buffer (process-buffer connected)
389 (setq connected-servers
390 (cons (process-contact (get-buffer-process
391 (current-buffer)) :host)
392 connected-servers))))))))
393 (when connected-servers
394 (message "Already connected to %s"
395 (concat (mapconcat 'identity (butlast connected-servers) ", ")
396 ", and " (car (last connected-servers))))))))
397
352;;;###autoload 398;;;###autoload
353(defalias 'irc 'rcirc) 399(defalias 'irc 'rcirc)
354 400
@@ -365,7 +411,8 @@ If ARG is non-nil, prompt for a server to connect to."
365(defvar rcirc-process nil) 411(defvar rcirc-process nil)
366 412
367;;;###autoload 413;;;###autoload
368(defun rcirc-connect (&optional server port nick user-name full-name startup-channels) 414(defun rcirc-connect (server &optional port nick user-name full-name
415 startup-channels)
369 (save-excursion 416 (save-excursion
370 (message "Connecting to %s..." server) 417 (message "Connecting to %s..." server)
371 (let* ((inhibit-eol-conversion) 418 (let* ((inhibit-eol-conversion)
@@ -374,7 +421,6 @@ If ARG is non-nil, prompt for a server to connect to."
374 (string-to-number port) 421 (string-to-number port)
375 port) 422 port)
376 rcirc-default-port)) 423 rcirc-default-port))
377 (server (or server rcirc-default-server))
378 (nick (or nick rcirc-default-nick)) 424 (nick (or nick rcirc-default-nick))
379 (user-name (or user-name rcirc-default-user-name)) 425 (user-name (or user-name rcirc-default-user-name))
380 (full-name (or full-name rcirc-default-user-full-name)) 426 (full-name (or full-name rcirc-default-user-full-name))
@@ -412,6 +458,8 @@ If ARG is non-nil, prompt for a server to connect to."
412 (make-local-variable 'rcirc-connecting) 458 (make-local-variable 'rcirc-connecting)
413 (setq rcirc-connecting t) 459 (setq rcirc-connecting t)
414 460
461 (add-hook 'auto-save-hook 'rcirc-log-write)
462
415 ;; identify 463 ;; identify
416 (rcirc-send-string process (concat "NICK " nick)) 464 (rcirc-send-string process (concat "NICK " nick))
417 (rcirc-send-string process (concat "USER " user-name 465 (rcirc-send-string process (concat "USER " user-name
@@ -446,12 +494,21 @@ last ping."
446 (mapc (lambda (process) 494 (mapc (lambda (process)
447 (with-rcirc-process-buffer process 495 (with-rcirc-process-buffer process
448 (when (not rcirc-connecting) 496 (when (not rcirc-connecting)
449 (rcirc-send-string process (concat "PING " (rcirc-server-name process)))))) 497 (rcirc-send-string process
498 (format "PRIVMSG %s :\C-aKEEPALIVE %f\C-a"
499 rcirc-nick
500 (time-to-seconds
501 (current-time)))))))
450 (rcirc-process-list)) 502 (rcirc-process-list))
451 ;; no processes, clean up timer 503 ;; no processes, clean up timer
452 (cancel-timer rcirc-keepalive-timer) 504 (cancel-timer rcirc-keepalive-timer)
453 (setq rcirc-keepalive-timer nil))) 505 (setq rcirc-keepalive-timer nil)))
454 506
507(defun rcirc-handler-ctcp-KEEPALIVE (process target sender message)
508 (with-rcirc-process-buffer process
509 (setq header-line-format (format "%f" (- (time-to-seconds (current-time))
510 (string-to-number message))))))
511
455(defvar rcirc-debug-buffer " *rcirc debug*") 512(defvar rcirc-debug-buffer " *rcirc debug*")
456(defvar rcirc-debug-flag nil 513(defvar rcirc-debug-flag nil
457 "If non-nil, write information to `rcirc-debug-buffer'.") 514 "If non-nil, write information to `rcirc-debug-buffer'.")
@@ -461,14 +518,13 @@ Debug text is written to `rcirc-debug-buffer' if `rcirc-debug-flag'
461is non-nil." 518is non-nil."
462 (when rcirc-debug-flag 519 (when rcirc-debug-flag
463 (save-excursion 520 (save-excursion
464 (save-window-excursion 521 (set-buffer (get-buffer-create rcirc-debug-buffer))
465 (set-buffer (get-buffer-create rcirc-debug-buffer)) 522 (goto-char (point-max))
466 (goto-char (point-max)) 523 (insert (concat
467 (insert (concat 524 "["
468 "[" 525 (format-time-string "%Y-%m-%dT%T ") (process-name process)
469 (format-time-string "%Y-%m-%dT%T ") (process-name process) 526 "] "
470 "] " 527 text)))))
471 text))))))
472 528
473(defvar rcirc-sentinel-hooks nil 529(defvar rcirc-sentinel-hooks nil
474 "Hook functions called when the process sentinel is called. 530 "Hook functions called when the process sentinel is called.
@@ -486,12 +542,16 @@ Functions are called with PROCESS and SENTINEL arguments.")
486 (process-name process) 542 (process-name process)
487 sentinel 543 sentinel
488 (process-status process)) (not rcirc-target)) 544 (process-status process)) (not rcirc-target))
489 ;; remove the prompt from buffers 545 (rcirc-disconnect-buffer)))
490 (let ((inhibit-read-only t))
491 (delete-region rcirc-prompt-start-marker
492 rcirc-prompt-end-marker))))
493 (run-hook-with-args 'rcirc-sentinel-hooks process sentinel)))) 546 (run-hook-with-args 'rcirc-sentinel-hooks process sentinel))))
494 547
548(defun rcirc-disconnect-buffer (&optional buffer)
549 (with-current-buffer (or buffer (current-buffer))
550 ;; set rcirc-target to nil for each channel so cleanup
551 ;; doesnt happen when we reconnect
552 (setq rcirc-target nil)
553 (setq mode-line-process ":disconnected")))
554
495(defun rcirc-process-list () 555(defun rcirc-process-list ()
496 "Return a list of rcirc processes." 556 "Return a list of rcirc processes."
497 (let (ps) 557 (let (ps)
@@ -593,7 +653,8 @@ With no argument or nil as argument, use the current buffer."
593(defun rcirc-server-name (process) 653(defun rcirc-server-name (process)
594 "Return PROCESS server name, given by the 001 response." 654 "Return PROCESS server name, given by the 001 response."
595 (with-rcirc-process-buffer process 655 (with-rcirc-process-buffer process
596 (or rcirc-server-name rcirc-default-server))) 656 (or rcirc-server-name
657 (warn "server name for process %S unknown" process))))
597 658
598(defun rcirc-nick (process) 659(defun rcirc-nick (process)
599 "Return PROCESS nick." 660 "Return PROCESS nick."
@@ -610,9 +671,10 @@ With no argument or nil as argument, use the current buffer."
610(defvar rcirc-max-message-length 420 671(defvar rcirc-max-message-length 420
611 "Messages longer than this value will be split.") 672 "Messages longer than this value will be split.")
612 673
613(defun rcirc-send-message (process target message &optional noticep) 674(defun rcirc-send-message (process target message &optional noticep silent)
614 "Send TARGET associated with PROCESS a privmsg with text MESSAGE. 675 "Send TARGET associated with PROCESS a privmsg with text MESSAGE.
615If NOTICEP is non-nil, send a notice instead of privmsg." 676If NOTICEP is non-nil, send a notice instead of privmsg.
677If SILENT is non-nil, do not print the message in any irc buffer."
616 ;; max message length is 512 including CRLF 678 ;; max message length is 512 including CRLF
617 (let* ((response (if noticep "NOTICE" "PRIVMSG")) 679 (let* ((response (if noticep "NOTICE" "PRIVMSG"))
618 (oversize (> (length message) rcirc-max-message-length)) 680 (oversize (> (length message) rcirc-max-message-length))
@@ -625,8 +687,9 @@ If NOTICEP is non-nil, send a notice instead of privmsg."
625 (more (if oversize 687 (more (if oversize
626 (substring message rcirc-max-message-length)))) 688 (substring message rcirc-max-message-length))))
627 (rcirc-get-buffer-create process target) 689 (rcirc-get-buffer-create process target)
628 (rcirc-print process (rcirc-nick process) response target text)
629 (rcirc-send-string process (concat response " " target " :" text)) 690 (rcirc-send-string process (concat response " " target " :" text))
691 (unless silent
692 (rcirc-print process (rcirc-nick process) response target text))
630 (when more (rcirc-send-message process target more noticep)))) 693 (when more (rcirc-send-message process target more noticep))))
631 694
632(defvar rcirc-input-ring nil) 695(defvar rcirc-input-ring nil)
@@ -711,7 +774,7 @@ If NOTICEP is non-nil, send a notice instead of privmsg."
711(define-key rcirc-mode-map (kbd "C-c C-d") 'rcirc-cmd-mode) 774(define-key rcirc-mode-map (kbd "C-c C-d") 'rcirc-cmd-mode)
712(define-key rcirc-mode-map (kbd "C-c C-m") 'rcirc-cmd-msg) 775(define-key rcirc-mode-map (kbd "C-c C-m") 'rcirc-cmd-msg)
713(define-key rcirc-mode-map (kbd "C-c C-r") 'rcirc-cmd-nick) ; rename 776(define-key rcirc-mode-map (kbd "C-c C-r") 'rcirc-cmd-nick) ; rename
714(define-key rcirc-mode-map (kbd "C-c C-o") 'rcirc-cmd-oper) 777(define-key rcirc-mode-map (kbd "C-c C-o") 'rcirc-omit-mode)
715(define-key rcirc-mode-map (kbd "C-c C-p") 'rcirc-cmd-part) 778(define-key rcirc-mode-map (kbd "C-c C-p") 'rcirc-cmd-part)
716(define-key rcirc-mode-map (kbd "C-c C-q") 'rcirc-cmd-query) 779(define-key rcirc-mode-map (kbd "C-c C-q") 'rcirc-cmd-query)
717(define-key rcirc-mode-map (kbd "C-c C-t") 'rcirc-cmd-topic) 780(define-key rcirc-mode-map (kbd "C-c C-t") 'rcirc-cmd-topic)
@@ -737,6 +800,10 @@ If NOTICEP is non-nil, send a notice instead of privmsg."
737 800
738(defvar rcirc-last-post-time nil) 801(defvar rcirc-last-post-time nil)
739 802
803(defvar rcirc-log-alist nil
804 "Alist of lines to log to disk when `rcirc-log-flag' is non-nil.
805Each element looks like (FILENAME . TEXT).")
806
740(defun rcirc-mode (process target) 807(defun rcirc-mode (process target)
741 "Major mode for IRC channel buffers. 808 "Major mode for IRC channel buffers.
742 809
@@ -745,6 +812,7 @@ If NOTICEP is non-nil, send a notice instead of privmsg."
745 (use-local-map rcirc-mode-map) 812 (use-local-map rcirc-mode-map)
746 (setq mode-name "rcirc") 813 (setq mode-name "rcirc")
747 (setq major-mode 'rcirc-mode) 814 (setq major-mode 'rcirc-mode)
815 (setq mode-line-process nil)
748 816
749 (make-local-variable 'rcirc-input-ring) 817 (make-local-variable 'rcirc-input-ring)
750 (setq rcirc-input-ring (make-ring rcirc-input-ring-size)) 818 (setq rcirc-input-ring (make-ring rcirc-input-ring-size))
@@ -756,6 +824,8 @@ If NOTICEP is non-nil, send a notice instead of privmsg."
756 (setq rcirc-topic nil) 824 (setq rcirc-topic nil)
757 (make-local-variable 'rcirc-last-post-time) 825 (make-local-variable 'rcirc-last-post-time)
758 (setq rcirc-last-post-time (current-time)) 826 (setq rcirc-last-post-time (current-time))
827 (make-local-variable 'fill-paragraph-function)
828 (setq fill-paragraph-function 'rcirc-fill-paragraph)
759 829
760 (make-local-variable 'rcirc-short-buffer-name) 830 (make-local-variable 'rcirc-short-buffer-name)
761 (setq rcirc-short-buffer-name nil) 831 (setq rcirc-short-buffer-name nil)
@@ -785,6 +855,8 @@ If NOTICEP is non-nil, send a notice instead of privmsg."
785 (setq overlay-arrow-position (make-marker)) 855 (setq overlay-arrow-position (make-marker))
786 (set-marker overlay-arrow-position nil) 856 (set-marker overlay-arrow-position nil)
787 857
858 (setq buffer-invisibility-spec '(rcirc-ignored-user))
859
788 ;; if the user changes the major mode or kills the buffer, there is 860 ;; if the user changes the major mode or kills the buffer, there is
789 ;; cleanup work to do 861 ;; cleanup work to do
790 (add-hook 'change-major-mode-hook 'rcirc-change-major-mode-hook nil t) 862 (add-hook 'change-major-mode-hook 'rcirc-change-major-mode-hook nil t)
@@ -873,14 +945,16 @@ If ALL is non-nil, update prompts in all IRC buffers."
873 (when rcirc-target 945 (when rcirc-target
874 (rcirc-remove-nick-channel (rcirc-buffer-process) 946 (rcirc-remove-nick-channel (rcirc-buffer-process)
875 (rcirc-buffer-nick) 947 (rcirc-buffer-nick)
876 rcirc-target)))))) 948 rcirc-target))))
949 (setq rcirc-target nil)))
877 950
878(defun rcirc-generate-new-buffer-name (process target) 951(defun rcirc-generate-new-buffer-name (process target)
879 "Return a buffer name based on PROCESS and TARGET. 952 "Return a buffer name based on PROCESS and TARGET.
880This is used for the initial name given to IRC buffers." 953This is used for the initial name given to IRC buffers."
881 (if target 954 (substring-no-properties
882 (concat target "@" (process-name process)) 955 (if target
883 (concat "*" (process-name process) "*"))) 956 (concat target "@" (process-name process))
957 (concat "*" (process-name process) "*"))))
884 958
885(defun rcirc-get-buffer (process target &optional server) 959(defun rcirc-get-buffer (process target &optional server)
886 "Return the buffer associated with the PROCESS and TARGET. 960 "Return the buffer associated with the PROCESS and TARGET.
@@ -902,14 +976,14 @@ Create the buffer if it doesn't exist."
902 (when (not rcirc-target) 976 (when (not rcirc-target)
903 (setq rcirc-target target)) 977 (setq rcirc-target target))
904 buffer) 978 buffer)
905 ;; create the buffer 979 ;; create the buffer
906 (with-rcirc-process-buffer process 980 (with-rcirc-process-buffer process
907 (let ((new-buffer (get-buffer-create 981 (let ((new-buffer (get-buffer-create
908 (rcirc-generate-new-buffer-name process target)))) 982 (rcirc-generate-new-buffer-name process target))))
909 (with-current-buffer new-buffer 983 (with-current-buffer new-buffer
910 (rcirc-mode process target)) 984 (rcirc-mode process target))
911 (rcirc-put-nick-channel process (rcirc-nick process) target) 985 (rcirc-put-nick-channel process (rcirc-nick process) target)
912 new-buffer))))) 986 new-buffer)))))
913 987
914(defun rcirc-send-input () 988(defun rcirc-send-input ()
915 "Send input to target associated with the current buffer." 989 "Send input to target associated with the current buffer."
@@ -943,6 +1017,14 @@ Create the buffer if it doesn't exist."
943 (ring-insert rcirc-input-ring input) 1017 (ring-insert rcirc-input-ring input)
944 (setq rcirc-input-ring-index 0)))))) 1018 (setq rcirc-input-ring-index 0))))))
945 1019
1020(defun rcirc-fill-paragraph (&optional arg)
1021 (interactive "p")
1022 (when (> (point) rcirc-prompt-end-marker)
1023 (save-restriction
1024 (narrow-to-region rcirc-prompt-end-marker (point-max))
1025 (let ((fill-column rcirc-max-message-length))
1026 (fill-region (point-min) (point-max))))))
1027
946(defun rcirc-process-input-line (line) 1028(defun rcirc-process-input-line (line)
947 (if (string-match "^/\\([^ ]+\\) ?\\(.*\\)$" line) 1029 (if (string-match "^/\\([^ ]+\\) ?\\(.*\\)$" line)
948 (rcirc-process-command (match-string 1 line) 1030 (rcirc-process-command (match-string 1 line)
@@ -1021,7 +1103,6 @@ Create the buffer if it doesn't exist."
1021(defun rcirc-multiline-minor-submit () 1103(defun rcirc-multiline-minor-submit ()
1022 "Send the text in buffer back to parent buffer." 1104 "Send the text in buffer back to parent buffer."
1023 (interactive) 1105 (interactive)
1024 (assert rcirc-parent-buffer)
1025 (untabify (point-min) (point-max)) 1106 (untabify (point-min) (point-max))
1026 (let ((text (buffer-substring (point-min) (point-max))) 1107 (let ((text (buffer-substring (point-min) (point-max)))
1027 (buffer (current-buffer)) 1108 (buffer (current-buffer))
@@ -1052,12 +1133,12 @@ Create the buffer if it doesn't exist."
1052 (process-buffer process))))) 1133 (process-buffer process)))))
1053 1134
1054(defcustom rcirc-response-formats 1135(defcustom rcirc-response-formats
1055 '(("PRIVMSG" . "%T<%N> %m") 1136 '(("PRIVMSG" . "<%N> %m")
1056 ("NOTICE" . "%T-%N- %m") 1137 ("NOTICE" . "-%N- %m")
1057 ("ACTION" . "%T[%N %m]") 1138 ("ACTION" . "[%N %m]")
1058 ("COMMAND" . "%T%m") 1139 ("COMMAND" . "%m")
1059 ("ERROR" . "%T%fw!!! %m") 1140 ("ERROR" . "%fw!!! %m")
1060 (t . "%T%fp*** %fs%n %r %m")) 1141 (t . "%fp*** %fs%n %r %m"))
1061 "An alist of formats used for printing responses. 1142 "An alist of formats used for printing responses.
1062The format is looked up using the response-type as a key; 1143The format is looked up using the response-type as a key;
1063if no match is found, the default entry (with a key of `t') is used. 1144if no match is found, the default entry (with a key of `t') is used.
@@ -1069,7 +1150,6 @@ the of the following escape sequences replaced by the described values:
1069 %n The sender's nick 1150 %n The sender's nick
1070 %N The sender's nick (with face `rcirc-my-nick' or `rcirc-other-nick') 1151 %N The sender's nick (with face `rcirc-my-nick' or `rcirc-other-nick')
1071 %r The response-type 1152 %r The response-type
1072 %T The timestamp (with face `rcirc-timestamp')
1073 %t The target 1153 %t The target
1074 %fw Following text uses the face `font-lock-warning-face' 1154 %fw Following text uses the face `font-lock-warning-face'
1075 %fp Following text uses the face `rcirc-server-prefix' 1155 %fp Following text uses the face `rcirc-server-prefix'
@@ -1082,92 +1162,67 @@ the of the following escape sequences replaced by the described values:
1082 :value-type string) 1162 :value-type string)
1083 :group 'rcirc) 1163 :group 'rcirc)
1084 1164
1165(defcustom rcirc-omit-responses
1166 '("JOIN" "PART" "QUIT")
1167 "Responses which will be hidden when `rcirc-omit-mode' is enabled."
1168 :type '(repeat string)
1169 :group 'rcirc)
1170
1085(defun rcirc-format-response-string (process sender response target text) 1171(defun rcirc-format-response-string (process sender response target text)
1086 "Return a nicely-formatted response string, incorporating TEXT 1172 "Return a nicely-formatted response string, incorporating TEXT
1087\(and perhaps other arguments). The specific formatting used 1173\(and perhaps other arguments). The specific formatting used
1088is found by looking up RESPONSE in `rcirc-response-formats'." 1174is found by looking up RESPONSE in `rcirc-response-formats'."
1089 (let ((chunks 1175 (with-temp-buffer
1090 (split-string (or (cdr (assoc response rcirc-response-formats)) 1176 (insert (or (cdr (assoc response rcirc-response-formats))
1091 (cdr (assq t rcirc-response-formats))) 1177 (cdr (assq t rcirc-response-formats))))
1092 "%")) 1178 (goto-char (point-min))
1093 (sender (or sender "")) 1179 (let ((start (point-min))
1094 (result "") 1180 (sender (if (or (not sender)
1095 (face nil) 1181 (string= (rcirc-server-name process) sender))
1096 key face-key repl) 1182 ""
1097 (when (equal (car chunks) "") 1183 sender))
1098 (pop chunks)) 1184 face)
1099 (dolist (chunk chunks) 1185 (while (re-search-forward "%\\(\\(f\\(.\\)\\)\\|\\(.\\)\\)" nil t)
1100 (if (equal chunk "") 1186 (rcirc-add-face start (match-beginning 0) face)
1101 (setq key ?%) 1187 (setq start (match-beginning 0))
1102 (setq key (aref chunk 0)) 1188 (replace-match
1103 (setq chunk (substring chunk 1))) 1189 (case (aref (match-string 1) 0)
1104 (setq repl 1190 (?f (setq face
1105 (cond ((eq key ?%) 1191 (case (string-to-char (match-string 3))
1106 ;; %% -- literal % character 1192 (?w 'font-lock-warning-face)
1107 "%") 1193 (?p 'rcirc-server-prefix)
1108 ((or (eq key ?n) (eq key ?N)) 1194 (?s 'rcirc-server)
1109 ;; %n/%N -- nick 1195 (t nil)))
1110 (let ((nick (concat (if (string= (rcirc-server-name process) 1196 "")
1111 sender) 1197 (?n sender)
1112 "" 1198 (?N (let ((my-nick (rcirc-nick process)))
1113 sender) 1199 (save-match-data
1114 (and target (concat "," target))))) 1200 (with-syntax-table rcirc-nick-syntax-table
1115 (rcirc-facify nick 1201 (rcirc-facify sender
1116 (if (eq key ?n) 1202 (cond ((string= sender my-nick)
1117 face 1203 'rcirc-my-nick)
1118 (cond ((string= sender (rcirc-nick process)) 1204 ((and rcirc-bright-nicks
1119 'rcirc-my-nick) 1205 (string-match
1120 ((and rcirc-bright-nicks 1206 (regexp-opt rcirc-bright-nicks
1121 (string-match 1207 'words)
1122 (regexp-opt rcirc-bright-nicks) 1208 sender))
1123 sender)) 1209 'rcirc-bright-nick)
1124 'rcirc-bright-nick) 1210 ((and rcirc-dim-nicks
1125 ((and rcirc-dim-nicks 1211 (string-match
1126 (string-match 1212 (regexp-opt rcirc-dim-nicks
1127 (regexp-opt rcirc-dim-nicks) 1213 'words)
1128 sender)) 1214 sender))
1129 'rcirc-dim-nick) 1215 'rcirc-dim-nick)
1130 (t 1216 (t
1131 'rcirc-other-nick)))))) 1217 'rcirc-other-nick)))))))
1132 ((eq key ?T) 1218 (?m (propertize text 'rcirc-text text))
1133 ;; %T -- timestamp 1219 (?r response)
1134 (rcirc-facify 1220 (?t (or target ""))
1135 (format-time-string rcirc-time-format (current-time)) 1221 (t (concat "UNKNOWN CODE:" (match-string 0))))
1136 'rcirc-timestamp)) 1222 t t nil 0)
1137 ((eq key ?m) 1223 (rcirc-add-face (match-beginning 0) (match-end 0) face))
1138 ;; %m -- message text 1224 (rcirc-add-face start (match-beginning 0) face))
1139 (rcirc-markup-text process sender response (rcirc-facify text face))) 1225 (buffer-substring (point-min) (point-max))))
1140 ((eq key ?t)
1141 ;; %t -- target
1142 (rcirc-facify (or rcirc-target "") face))
1143 ((eq key ?r)
1144 ;; %r -- response
1145 (rcirc-facify response face))
1146 ((eq key ?f)
1147 ;; %f -- change face
1148 (setq face-key (aref chunk 0))
1149 (setq chunk (substring chunk 1))
1150 (cond ((eq face-key ?w)
1151 ;; %fw -- warning face
1152 (setq face 'font-lock-warning-face))
1153 ((eq face-key ?p)
1154 ;; %fp -- server-prefix face
1155 (setq face 'rcirc-server-prefix))
1156 ((eq face-key ?s)
1157 ;; %fs -- warning face
1158 (setq face 'rcirc-server))
1159 ((eq face-key ?-)
1160 ;; %fs -- warning face
1161 (setq face nil))
1162 ((and (eq face-key ?\[)
1163 (string-match "^\\([^]]*\\)[]]" chunk)
1164 (facep (match-string 1 chunk)))
1165 ;; %f[...] -- named face
1166 (setq face (intern (match-string 1 chunk)))
1167 (setq chunk (substring chunk (match-end 0)))))
1168 "")))
1169 (setq result (concat result repl (rcirc-facify chunk face))))
1170 result))
1171 1226
1172(defun rcirc-target-buffer (process sender response target text) 1227(defun rcirc-target-buffer (process sender response target text)
1173 "Return a buffer to print the server response." 1228 "Return a buffer to print the server response."
@@ -1177,7 +1232,8 @@ is found by looking up RESPONSE in `rcirc-response-formats'."
1177 (rcirc-any-buffer process)) 1232 (rcirc-any-buffer process))
1178 ((not (rcirc-channel-p target)) 1233 ((not (rcirc-channel-p target))
1179 ;; message from another user 1234 ;; message from another user
1180 (if (string= response "PRIVMSG") 1235 (if (or (string= response "PRIVMSG")
1236 (string= response "ACTION"))
1181 (rcirc-get-buffer-create process (if (string= sender rcirc-nick) 1237 (rcirc-get-buffer-create process (if (string= sender rcirc-nick)
1182 target 1238 target
1183 sender)) 1239 sender))
@@ -1190,6 +1246,17 @@ is found by looking up RESPONSE in `rcirc-response-formats'."
1190(defvar rcirc-last-sender nil) 1246(defvar rcirc-last-sender nil)
1191(make-variable-buffer-local 'rcirc-last-sender) 1247(make-variable-buffer-local 'rcirc-last-sender)
1192 1248
1249(defcustom rcirc-log-directory "~/.emacs.d/rcirc-log"
1250 "Directory to keep IRC logfiles."
1251 :type 'directory
1252 :group 'rcirc)
1253
1254(defcustom rcirc-log-flag nil
1255 "Non-nil means log IRC activity to disk.
1256Logfiles are kept in `rcirc-log-directory'."
1257 :type 'boolean
1258 :group 'rcirc)
1259
1193(defun rcirc-print (process sender response target text &optional activity) 1260(defun rcirc-print (process sender response target text &optional activity)
1194 "Print TEXT in the buffer associated with TARGET. 1261 "Print TEXT in the buffer associated with TARGET.
1195Format based on SENDER and RESPONSE. If ACTIVITY is non-nil, 1262Format based on SENDER and RESPONSE. If ACTIVITY is non-nil,
@@ -1212,7 +1279,8 @@ record activity."
1212 (setq text (decode-coding-string text rcirc-decode-coding-system)) 1279 (setq text (decode-coding-string text rcirc-decode-coding-system))
1213 ;; mark the line with overlay arrow 1280 ;; mark the line with overlay arrow
1214 (unless (or (marker-position overlay-arrow-position) 1281 (unless (or (marker-position overlay-arrow-position)
1215 (get-buffer-window (current-buffer))) 1282 (get-buffer-window (current-buffer))
1283 (member response rcirc-omit-responses))
1216 (set-marker overlay-arrow-position 1284 (set-marker overlay-arrow-position
1217 (marker-position rcirc-prompt-start-marker)))) 1285 (marker-position rcirc-prompt-start-marker))))
1218 1286
@@ -1222,44 +1290,40 @@ record activity."
1222 (set-marker-insertion-type rcirc-prompt-start-marker t) 1290 (set-marker-insertion-type rcirc-prompt-start-marker t)
1223 (set-marker-insertion-type rcirc-prompt-end-marker t) 1291 (set-marker-insertion-type rcirc-prompt-end-marker t)
1224 1292
1225 (let ((fmted-text 1293 (let ((start (point)))
1226 (rcirc-format-response-string process sender response nil 1294 (insert (rcirc-format-response-string process sender response nil
1227 text))) 1295 text)
1228 1296 (propertize "\n" 'hard t))
1229 (insert fmted-text (propertize "\n" 'hard t)) 1297
1230 (set-marker-insertion-type rcirc-prompt-start-marker nil) 1298 ;; squeeze spaces out of text before rcirc-text
1231 (set-marker-insertion-type rcirc-prompt-end-marker nil) 1299 (fill-region fill-start
1232 1300 (1- (or (next-single-property-change fill-start
1233 (let ((text-start (make-marker))) 1301 'rcirc-text)
1234 (set-marker text-start 1302 rcirc-prompt-end-marker)))
1235 (or (next-single-property-change fill-start 1303
1236 'rcirc-text) 1304 ;; run markup functions
1237 rcirc-prompt-end-marker)) 1305 (save-excursion
1238 ;; squeeze spaces out of text before rcirc-text 1306 (save-restriction
1239 (fill-region fill-start (1- text-start)) 1307 (narrow-to-region start rcirc-prompt-start-marker)
1240 1308 (goto-char (or (next-single-property-change start 'rcirc-text)
1241 ;; fill the text we just inserted, maybe 1309 (point)))
1242 (when (and rcirc-fill-flag 1310 (when (rcirc-buffer-process)
1243 (not (string= response "372"))) ;/motd 1311 (save-excursion (rcirc-markup-timestamp sender response))
1244 (let ((fill-prefix 1312 (dolist (fn rcirc-markup-text-functions)
1245 (or rcirc-fill-prefix 1313 (save-excursion (funcall fn sender response)))
1246 (make-string (- text-start fill-start) ?\s))) 1314 (save-excursion (rcirc-markup-fill sender response)))
1247 (fill-column (cond ((eq rcirc-fill-column 'frame-width) 1315
1248 (1- (frame-width))) 1316 (when rcirc-read-only-flag
1249 ((eq rcirc-fill-column 'window-width) 1317 (add-text-properties (point-min) (point-max)
1250 (1- (window-width))) 1318 '(read-only t front-sticky t))))
1251 (rcirc-fill-column 1319 ;; make text omittable
1252 rcirc-fill-column) 1320 (when (and (member response rcirc-omit-responses)
1253 (t fill-column)))) 1321 (> start (point-min)))
1254 (fill-region fill-start rcirc-prompt-start-marker 'left t))))) 1322 (put-text-property (1- start) (1- rcirc-prompt-start-marker)
1255 1323 'invisible 'rcirc-omit))))
1256 ;; set inserted text to be read-only 1324
1257 (when rcirc-read-only-flag 1325 (set-marker-insertion-type rcirc-prompt-start-marker nil)
1258 (put-text-property rcirc-prompt-start-marker fill-start 'read-only t) 1326 (set-marker-insertion-type rcirc-prompt-end-marker nil)
1259 (let ((inhibit-read-only t))
1260 (put-text-property rcirc-prompt-start-marker fill-start
1261 'front-sticky t)
1262 (put-text-property (1- (point)) (point) 'rear-nonsticky t)))
1263 1327
1264 ;; truncate buffer if it is very long 1328 ;; truncate buffer if it is very long
1265 (save-excursion 1329 (save-excursion
@@ -1275,27 +1339,26 @@ record activity."
1275 (window-buffer w)) 1339 (window-buffer w))
1276 (>= (window-point w) 1340 (>= (window-point w)
1277 rcirc-prompt-end-marker)) 1341 rcirc-prompt-end-marker))
1278 (set-window-point w (point-max)))) 1342 (set-window-point w (point-max))))
1279 nil t) 1343 nil t)
1280 1344
1281 ;; restore the point 1345 ;; restore the point
1282 (goto-char (if moving rcirc-prompt-end-marker old-point)) 1346 (goto-char (if moving rcirc-prompt-end-marker old-point))
1283 1347
1284 ;; keep window on bottom line if it was already there 1348 ;; keep window on bottom line if it was already there
1285 (when rcirc-scroll-show-maximum-output 1349 (when rcirc-scroll-show-maximum-output
1286 (walk-windows (lambda (w) 1350 (walk-windows (lambda (w)
1287 (when (eq (window-buffer w) (current-buffer)) 1351 (when (eq (window-buffer w) (current-buffer))
1288 (with-current-buffer (window-buffer w) 1352 (with-current-buffer (window-buffer w)
1289 (when (eq major-mode 'rcirc-mode) 1353 (when (eq major-mode 'rcirc-mode)
1290 (with-selected-window w 1354 (with-selected-window w
1291 (when (<= (- (window-height) 1355 (when (<= (- (window-height)
1292 (count-screen-lines 1356 (count-screen-lines (window-point)
1293 (window-point) 1357 (window-start))
1294 (window-start))
1295 1) 1358 1)
1296 0) 1359 0)
1297 (recenter -1))))))) 1360 (recenter -1)))))))
1298 nil t)) 1361 nil t))
1299 1362
1300 ;; flush undo (can we do something smarter here?) 1363 ;; flush undo (can we do something smarter here?)
1301 (buffer-disable-undo) 1364 (buffer-disable-undo)
@@ -1305,22 +1368,45 @@ record activity."
1305 (when (and activity 1368 (when (and activity
1306 (not rcirc-ignore-buffer-activity-flag) 1369 (not rcirc-ignore-buffer-activity-flag)
1307 (not (and rcirc-dim-nicks sender 1370 (not (and rcirc-dim-nicks sender
1308 (string-match (regexp-opt rcirc-dim-nicks) sender)))) 1371 (string-match (regexp-opt rcirc-dim-nicks) sender)
1372 (rcirc-channel-p target))))
1309 (rcirc-record-activity (current-buffer) 1373 (rcirc-record-activity (current-buffer)
1310 (when (not (rcirc-channel-p rcirc-target)) 1374 (when (not (rcirc-channel-p rcirc-target))
1311 'nick))) 1375 'nick)))
1312 1376
1377 (when rcirc-log-flag
1378 (rcirc-log process sender response target text))
1379
1313 (sit-for 0) ; displayed text before hook 1380 (sit-for 0) ; displayed text before hook
1314 (run-hook-with-args 'rcirc-print-hooks 1381 (run-hook-with-args 'rcirc-print-hooks
1315 process sender response target text))))) 1382 process sender response target text)))))
1316 1383
1317(defun rcirc-startup-channels (server) 1384(defun rcirc-log (process sender response target text)
1318 "Return the list of startup channels for SERVER." 1385 "Record line in `rcirc-log', to be later written to disk."
1319 (let (channels) 1386 (let* ((filename (rcirc-generate-new-buffer-name process target))
1320 (dolist (i rcirc-startup-channels-alist) 1387 (cell (assoc-string filename rcirc-log-alist))
1321 (if (string-match (car i) server) 1388 (line (concat (format-time-string rcirc-time-format)
1322 (setq channels (append channels (cdr i))))) 1389 (substring-no-properties
1323 channels)) 1390 (rcirc-format-response-string process sender
1391 response target text))
1392 "\n")))
1393 (if cell
1394 (setcdr cell (concat (cdr cell) line))
1395 (setq rcirc-log-alist
1396 (cons (cons filename line) rcirc-log-alist)))))
1397
1398(defun rcirc-log-write ()
1399 "Flush `rcirc-log-alist' data to disk.
1400
1401Log data is written to `rcirc-log-directory'."
1402 (make-directory rcirc-log-directory t)
1403 (dolist (cell rcirc-log-alist)
1404 (with-temp-buffer
1405 (insert (cdr cell))
1406 (write-region (point-min) (point-max)
1407 (concat rcirc-log-directory "/" (car cell))
1408 t 'quiet)))
1409 (setq rcirc-log-alist nil))
1324 1410
1325(defun rcirc-join-channels (process channels) 1411(defun rcirc-join-channels (process channels)
1326 "Join CHANNELS." 1412 "Join CHANNELS."
@@ -1437,6 +1523,9 @@ if NICK is also on `rcirc-ignore-list-automatic'."
1437(or (assq 'rcirc-low-priority-flag minor-mode-alist) 1523(or (assq 'rcirc-low-priority-flag minor-mode-alist)
1438 (setq minor-mode-alist 1524 (setq minor-mode-alist
1439 (cons '(rcirc-low-priority-flag " LowPri") minor-mode-alist))) 1525 (cons '(rcirc-low-priority-flag " LowPri") minor-mode-alist)))
1526(or (assq 'rcirc-omit-mode minor-mode-alist)
1527 (setq minor-mode-alist
1528 (cons '(rcirc-omit-mode " Omit") minor-mode-alist)))
1440 1529
1441(defun rcirc-toggle-ignore-buffer-activity () 1530(defun rcirc-toggle-ignore-buffer-activity ()
1442 "Toggle the value of `rcirc-ignore-buffer-activity-flag'." 1531 "Toggle the value of `rcirc-ignore-buffer-activity-flag'."
@@ -1458,48 +1547,59 @@ if NICK is also on `rcirc-ignore-list-automatic'."
1458 "Activity in this buffer is normal priority")) 1547 "Activity in this buffer is normal priority"))
1459 (force-mode-line-update)) 1548 (force-mode-line-update))
1460 1549
1461(defvar rcirc-switch-to-buffer-function 'switch-to-buffer 1550(defun rcirc-omit-mode ()
1462 "Function to use when switching buffers. 1551 "Toggle the Rcirc-Omit mode.
1463Possible values are `switch-to-buffer', `pop-to-buffer', and 1552If enabled, \"uninteresting\" lines are not shown.
1464`display-buffer'.") 1553Uninteresting lines are those whose responses are listed in
1554`rcirc-omit-responses'."
1555 (interactive)
1556 (setq rcirc-omit-mode (not rcirc-omit-mode))
1557 (let ((line (1- (count-screen-lines (point) (window-start)))))
1558 (if rcirc-omit-mode
1559 (progn
1560 (add-to-invisibility-spec 'rcirc-omit)
1561 (message "Rcirc-Omit mode enabled"))
1562 (remove-from-invisibility-spec 'rcirc-omit)
1563 (message "Rcirc-Omit mode disabled"))
1564 (recenter line))
1565 (force-mode-line-update))
1465 1566
1466(defun rcirc-switch-to-server-buffer () 1567(defun rcirc-switch-to-server-buffer ()
1467 "Switch to the server buffer associated with current channel buffer." 1568 "Switch to the server buffer associated with current channel buffer."
1468 (interactive) 1569 (interactive)
1469 (funcall rcirc-switch-to-buffer-function rcirc-server-buffer)) 1570 (switch-to-buffer rcirc-server-buffer))
1470 1571
1471(defun rcirc-jump-to-first-unread-line () 1572(defun rcirc-jump-to-first-unread-line ()
1472 "Move the point to the first unread line in this buffer." 1573 "Move the point to the first unread line in this buffer."
1473 (interactive) 1574 (interactive)
1474 (when (marker-position overlay-arrow-position) 1575 (if (marker-position overlay-arrow-position)
1475 (goto-char overlay-arrow-position))) 1576 (goto-char overlay-arrow-position)
1476 1577 (message "No unread messages")))
1477(defvar rcirc-last-non-irc-buffer nil 1578
1478 "The buffer to switch to when there is no more activity.") 1579(defun rcirc-non-irc-buffer ()
1580 (let ((buflist (buffer-list))
1581 buffer)
1582 (while (and buflist (not buffer))
1583 (with-current-buffer (car buflist)
1584 (unless (or (eq major-mode 'rcirc-mode)
1585 (= ?\s (aref (buffer-name) 0)) ; internal buffers
1586 (get-buffer-window (current-buffer)))
1587 (setq buffer (current-buffer))))
1588 (setq buflist (cdr buflist)))
1589 buffer))
1479 1590
1480(defun rcirc-next-active-buffer (arg) 1591(defun rcirc-next-active-buffer (arg)
1481 "Go to the next rcirc buffer with activity. 1592 "Switch to the next rcirc buffer with activity.
1482With prefix ARG, go to the next low priority buffer with activity. 1593With prefix ARG, go to the next low priority buffer with activity."
1483The function given by `rcirc-switch-to-buffer-function' is used to
1484show the buffer."
1485 (interactive "P") 1594 (interactive "P")
1486 (let* ((pair (rcirc-split-activity rcirc-activity)) 1595 (let* ((pair (rcirc-split-activity rcirc-activity))
1487 (lopri (car pair)) 1596 (lopri (car pair))
1488 (hipri (cdr pair))) 1597 (hipri (cdr pair)))
1489 (if (or (and (not arg) hipri) 1598 (if (or (and (not arg) hipri)
1490 (and arg lopri)) 1599 (and arg lopri))
1491 (progn 1600 (switch-to-buffer (car (if arg lopri hipri)) t)
1492 (unless (eq major-mode 'rcirc-mode)
1493 (setq rcirc-last-non-irc-buffer (current-buffer)))
1494 (funcall rcirc-switch-to-buffer-function
1495 (car (if arg lopri hipri))))
1496 (if (eq major-mode 'rcirc-mode) 1601 (if (eq major-mode 'rcirc-mode)
1497 (if (not (and rcirc-last-non-irc-buffer 1602 (switch-to-buffer (rcirc-non-irc-buffer))
1498 (buffer-live-p rcirc-last-non-irc-buffer)))
1499 (message "No IRC activity. Start something.")
1500 (message "No more IRC activity. Go back to work.")
1501 (funcall rcirc-switch-to-buffer-function rcirc-last-non-irc-buffer)
1502 (setq rcirc-last-non-irc-buffer nil))
1503 (message (concat 1603 (message (concat
1504 "No IRC activity." 1604 "No IRC activity."
1505 (when lopri 1605 (when lopri
@@ -1518,15 +1618,19 @@ activity. Only run if the buffer is not visible and
1518(defun rcirc-record-activity (buffer &optional type) 1618(defun rcirc-record-activity (buffer &optional type)
1519 "Record BUFFER activity with TYPE." 1619 "Record BUFFER activity with TYPE."
1520 (with-current-buffer buffer 1620 (with-current-buffer buffer
1521 (when (not (get-buffer-window (current-buffer) t)) 1621 (let ((old-activity rcirc-activity)
1522 (setq rcirc-activity 1622 (old-types rcirc-activity-types))
1523 (sort (add-to-list 'rcirc-activity (current-buffer)) 1623 (when (not (get-buffer-window (current-buffer) t))
1524 (lambda (b1 b2) 1624 (setq rcirc-activity
1525 (let ((t1 (with-current-buffer b1 rcirc-last-post-time)) 1625 (sort (add-to-list 'rcirc-activity (current-buffer))
1526 (t2 (with-current-buffer b2 rcirc-last-post-time))) 1626 (lambda (b1 b2)
1527 (time-less-p t2 t1))))) 1627 (let ((t1 (with-current-buffer b1 rcirc-last-post-time))
1528 (pushnew type rcirc-activity-types) 1628 (t2 (with-current-buffer b2 rcirc-last-post-time)))
1529 (rcirc-update-activity-string))) 1629 (time-less-p t2 t1)))))
1630 (pushnew type rcirc-activity-types)
1631 (unless (and (equal rcirc-activity old-activity)
1632 (member type old-types))
1633 (rcirc-update-activity-string)))))
1530 (run-hook-with-args 'rcirc-activity-hooks buffer)) 1634 (run-hook-with-args 'rcirc-activity-hooks buffer))
1531 1635
1532(defun rcirc-clear-activity (buffer) 1636(defun rcirc-clear-activity (buffer)
@@ -1535,6 +1639,12 @@ activity. Only run if the buffer is not visible and
1535 (with-current-buffer buffer 1639 (with-current-buffer buffer
1536 (setq rcirc-activity-types nil))) 1640 (setq rcirc-activity-types nil)))
1537 1641
1642(defun rcirc-clear-unread (buffer)
1643 "Erase the last read message arrow from BUFFER."
1644 (when (buffer-live-p buffer)
1645 (with-current-buffer buffer
1646 (set-marker overlay-arrow-position nil))))
1647
1538(defun rcirc-split-activity (activity) 1648(defun rcirc-split-activity (activity)
1539 "Return a cons cell with ACTIVITY split into (lopri . hipri)." 1649 "Return a cons cell with ACTIVITY split into (lopri . hipri)."
1540 (let (lopri hipri) 1650 (let (lopri hipri)
@@ -1546,6 +1656,9 @@ activity. Only run if the buffer is not visible and
1546 (add-to-list 'hipri buf t)))) 1656 (add-to-list 'hipri buf t))))
1547 (cons lopri hipri))) 1657 (cons lopri hipri)))
1548 1658
1659(defvar rcirc-update-activity-string-hook nil
1660 "Hook run whenever the activity string is updated.")
1661
1549;; TODO: add mouse properties 1662;; TODO: add mouse properties
1550(defun rcirc-update-activity-string () 1663(defun rcirc-update-activity-string ()
1551 "Update mode-line string." 1664 "Update mode-line string."
@@ -1554,19 +1667,18 @@ activity. Only run if the buffer is not visible and
1554 (hipri (cdr pair))) 1667 (hipri (cdr pair)))
1555 (setq rcirc-activity-string 1668 (setq rcirc-activity-string
1556 (cond ((or hipri lopri) 1669 (cond ((or hipri lopri)
1557 (concat "-" 1670 (concat (and hipri "[")
1558 (and hipri "[")
1559 (rcirc-activity-string hipri) 1671 (rcirc-activity-string hipri)
1560 (and hipri lopri ",") 1672 (and hipri lopri ",")
1561 (and lopri 1673 (and lopri
1562 (concat "(" 1674 (concat "("
1563 (rcirc-activity-string lopri) 1675 (rcirc-activity-string lopri)
1564 ")")) 1676 ")"))
1565 (and hipri "]") 1677 (and hipri "]")))
1566 "-"))
1567 ((not (null (rcirc-process-list))) 1678 ((not (null (rcirc-process-list)))
1568 "-[]-") 1679 "[]")
1569 (t ""))))) 1680 (t "[]")))
1681 (run-hooks 'rcirc-update-activity-string-hook)))
1570 1682
1571(defun rcirc-activity-string (buffers) 1683(defun rcirc-activity-string (buffers)
1572 (mapconcat (lambda (b) 1684 (mapconcat (lambda (b)
@@ -1586,33 +1698,47 @@ activity. Only run if the buffer is not visible and
1586 (with-current-buffer buffer 1698 (with-current-buffer buffer
1587 (or rcirc-short-buffer-name (buffer-name)))) 1699 (or rcirc-short-buffer-name (buffer-name))))
1588 1700
1589(defvar rcirc-current-buffer nil) 1701(defun rcirc-visible-buffers ()
1590(defun rcirc-window-configuration-change () 1702 "Return a list of the visible buffers that are in rcirc-mode."
1591 "Go through visible windows and remove buffers from activity list. 1703 (let (acc)
1592Also, clear the overlay arrow if the current buffer is now hidden."
1593 (let ((current-now-hidden t))
1594 (walk-windows (lambda (w) 1704 (walk-windows (lambda (w)
1595 (let ((buf (window-buffer w))) 1705 (with-current-buffer (window-buffer w)
1596 (with-current-buffer buf 1706 (when (eq major-mode 'rcirc-mode)
1597 (when (eq major-mode 'rcirc-mode) 1707 (push (current-buffer) acc)))))
1598 (rcirc-clear-activity buf))) 1708 acc))
1599 (when (eq buf rcirc-current-buffer) 1709
1600 (setq current-now-hidden nil))))) 1710(defvar rcirc-visible-buffers nil)
1601 ;; add overlay arrow if the buffer isn't displayed 1711(defun rcirc-window-configuration-change ()
1602 (when (and current-now-hidden 1712 (unless (minibuffer-window-active-p (minibuffer-window))
1603 rcirc-current-buffer 1713 ;; delay this until command has finished to make sure window is
1604 (buffer-live-p rcirc-current-buffer)) 1714 ;; actually visible before clearing activity
1605 (with-current-buffer rcirc-current-buffer 1715 (add-hook 'post-command-hook 'rcirc-window-configuration-change-1)))
1606 (when (and (eq major-mode 'rcirc-mode) 1716
1607 (marker-position overlay-arrow-position)) 1717(defun rcirc-window-configuration-change-1 ()
1608 (set-marker overlay-arrow-position nil))))) 1718 ;; clear activity and overlay arrows
1609 1719 (let* ((old-activity rcirc-activity)
1610 ;; remove any killed buffers from list 1720 (hidden-buffers rcirc-visible-buffers))
1611 (setq rcirc-activity 1721
1612 (delq nil (mapcar (lambda (buf) (when (buffer-live-p buf) buf)) 1722 (setq rcirc-visible-buffers (rcirc-visible-buffers))
1613 rcirc-activity))) 1723
1614 (rcirc-update-activity-string) 1724 (dolist (vbuf rcirc-visible-buffers)
1615 (setq rcirc-current-buffer (current-buffer))) 1725 (setq hidden-buffers (delq vbuf hidden-buffers))
1726 ;; clear activity for all visible buffers
1727 (rcirc-clear-activity vbuf))
1728
1729 ;; clear unread arrow from recently hidden buffers
1730 (dolist (hbuf hidden-buffers)
1731 (rcirc-clear-unread hbuf))
1732
1733 ;; remove any killed buffers from list
1734 (setq rcirc-activity
1735 (delq nil (mapcar (lambda (buf) (when (buffer-live-p buf) buf))
1736 rcirc-activity)))
1737 ;; update the mode-line string
1738 (unless (equal old-activity rcirc-activity)
1739 (rcirc-update-activity-string)))
1740
1741 (remove-hook 'post-command-hook 'rcirc-window-configuration-change-1))
1616 1742
1617 1743
1618;;; buffer name abbreviation 1744;;; buffer name abbreviation
@@ -1722,8 +1848,9 @@ Also, clear the overlay arrow if the current buffer is now hidden."
1722 (car (split-string channel))))) 1848 (car (split-string channel)))))
1723 (rcirc-send-string process (concat "JOIN " channel)) 1849 (rcirc-send-string process (concat "JOIN " channel))
1724 (when (not (eq (selected-window) (minibuffer-window))) 1850 (when (not (eq (selected-window) (minibuffer-window)))
1725 (funcall rcirc-switch-to-buffer-function buffer)))) 1851 (switch-to-buffer buffer))))
1726 1852
1853;; TODO: /part #channel reason, or consider removing #channel altogether
1727(defun-rcirc-command part (channel) 1854(defun-rcirc-command part (channel)
1728 "Part CHANNEL." 1855 "Part CHANNEL."
1729 (interactive "sPart channel: ") 1856 (interactive "sPart channel: ")
@@ -1902,7 +2029,7 @@ keywords when no KEYWORD is given."
1902 word-boundary)) 2029 word-boundary))
1903 (optional 2030 (optional
1904 (and "/" 2031 (and "/"
1905 (1+ (char "-a-zA-Z0-9_=!?#$\@~`%&*+|\\/:;.,{}[]()")) 2032 (1+ (char "-a-zA-Z0-9_='!?#$\@~`%&*+|\\/:;.,{}[]()"))
1906 (char "-a-zA-Z0-9_=#$\@~`%&*+|\\/:;{}[]()"))))) 2033 (char "-a-zA-Z0-9_=#$\@~`%&*+|\\/:;{}[]()")))))
1907 "Regexp matching URLs. Set to nil to disable URL features in rcirc.") 2034 "Regexp matching URLs. Set to nil to disable URL features in rcirc.")
1908 2035
@@ -1932,38 +2059,25 @@ keywords when no KEYWORD is given."
1932 2059
1933 2060
1934(defvar rcirc-markup-text-functions 2061(defvar rcirc-markup-text-functions
1935 '(rcirc-markup-body-text 2062 '(rcirc-markup-attributes
1936 rcirc-markup-attributes
1937 rcirc-markup-my-nick 2063 rcirc-markup-my-nick
1938 rcirc-markup-urls 2064 rcirc-markup-urls
1939 rcirc-markup-keywords 2065 rcirc-markup-keywords
1940 rcirc-markup-bright-nicks) 2066 rcirc-markup-bright-nicks
2067 rcirc-markup-fill)
2068
1941 "List of functions used to manipulate text before it is printed. 2069 "List of functions used to manipulate text before it is printed.
1942 2070
1943Each function takes three arguments, PROCESS, SENDER, RESPONSE 2071Each function takes two arguments, SENDER, RESPONSE. The buffer
1944and CHANNEL-BUFFER. The current buffer is temporary buffer that 2072is narrowed with the text to be printed and the point is at the
1945contains the text to manipulate. Each function works on the text 2073beginning of the `rcirc-text' propertized text.")
1946in this buffer.")
1947 2074
1948(defun rcirc-markup-text (process sender response text) 2075(defun rcirc-markup-timestamp (sender response)
1949 "Return TEXT with properties added based on various patterns." 2076 (goto-char (point-min))
1950 (let ((channel-buffer (current-buffer))) 2077 (insert (rcirc-facify (format-time-string rcirc-time-format)
1951 (with-temp-buffer 2078 'rcirc-timestamp)))
1952 (insert text)
1953 (goto-char (point-min))
1954 (dolist (fn rcirc-markup-text-functions)
1955 (save-excursion
1956 (funcall fn process sender response channel-buffer)))
1957 (buffer-substring (point-min) (point-max)))))
1958 2079
1959(defun rcirc-markup-body-text (process sender response channel-buffer) 2080(defun rcirc-markup-attributes (sender response)
1960 ;; We add the text property `rcirc-text' to identify this as the
1961 ;; body text.
1962 (add-text-properties (point-min) (point-max)
1963 (list 'rcirc-text (buffer-substring-no-properties
1964 (point-min) (point-max)))))
1965
1966(defun rcirc-markup-attributes (process sender response channel-buffer)
1967 (while (re-search-forward "\\([\C-b\C-_\C-v]\\).*?\\(\\1\\|\C-o\\)" nil t) 2081 (while (re-search-forward "\\([\C-b\C-_\C-v]\\).*?\\(\\1\\|\C-o\\)" nil t)
1968 (rcirc-add-face (match-beginning 0) (match-end 0) 2082 (rcirc-add-face (match-beginning 0) (match-end 0)
1969 (case (char-after (match-beginning 1)) 2083 (case (char-after (match-beginning 1))
@@ -1979,19 +2093,21 @@ in this buffer.")
1979 (while (re-search-forward "\C-o+" nil t) 2093 (while (re-search-forward "\C-o+" nil t)
1980 (delete-region (match-beginning 0) (match-end 0)))) 2094 (delete-region (match-beginning 0) (match-end 0))))
1981 2095
1982(defun rcirc-markup-my-nick (process sender response channel-buffer) 2096(defun rcirc-markup-my-nick (sender response)
1983 (with-syntax-table rcirc-nick-syntax-table 2097 (with-syntax-table rcirc-nick-syntax-table
1984 (while (re-search-forward (concat "\\b" 2098 (while (re-search-forward (concat "\\b"
1985 (regexp-quote (rcirc-nick process)) 2099 (regexp-quote (rcirc-nick
2100 (rcirc-buffer-process)))
1986 "\\b") 2101 "\\b")
1987 nil t) 2102 nil t)
1988 (rcirc-add-face (match-beginning 0) (match-end 0) 2103 (rcirc-add-face (match-beginning 0) (match-end 0)
1989 'rcirc-nick-in-message) 2104 'rcirc-nick-in-message)
1990 (when (string= response "PRIVMSG") 2105 (when (string= response "PRIVMSG")
1991 (rcirc-add-face (point-min) (point-max) 'rcirc-nick-in-message-full-line) 2106 (rcirc-add-face (point-min) (point-max)
1992 (rcirc-record-activity channel-buffer 'nick))))) 2107 'rcirc-nick-in-message-full-line)
2108 (rcirc-record-activity (current-buffer) 'nick)))))
1993 2109
1994(defun rcirc-markup-urls (process sender response channel-buffer) 2110(defun rcirc-markup-urls (sender response)
1995 (while (re-search-forward rcirc-url-regexp nil t) 2111 (while (re-search-forward rcirc-url-regexp nil t)
1996 (let ((start (match-beginning 0)) 2112 (let ((start (match-beginning 0))
1997 (end (match-end 0))) 2113 (end (match-end 0)))
@@ -1999,30 +2115,41 @@ in this buffer.")
1999 (add-text-properties start end (list 'mouse-face 'highlight 2115 (add-text-properties start end (list 'mouse-face 'highlight
2000 'keymap rcirc-browse-url-map)) 2116 'keymap rcirc-browse-url-map))
2001 ;; record the url 2117 ;; record the url
2002 (let ((url (buffer-substring-no-properties start end))) 2118 (push (buffer-substring-no-properties start end) rcirc-urls))))
2003 (with-current-buffer channel-buffer 2119
2004 (push url rcirc-urls)))))) 2120(defun rcirc-markup-keywords (sender response)
2005 2121 (when (and (string= response "PRIVMSG")
2006(defun rcirc-markup-keywords (process sender response channel-buffer) 2122 (not (string= sender (rcirc-nick (rcirc-buffer-process)))))
2007 (let* ((target (with-current-buffer channel-buffer (or rcirc-target ""))) 2123 (let* ((target (or rcirc-target ""))
2008 (keywords (delq nil (mapcar (lambda (keyword) 2124 (keywords (delq nil (mapcar (lambda (keyword)
2009 (when (not (string-match keyword target)) 2125 (when (not (string-match keyword
2010 keyword)) 2126 target))
2011 rcirc-keywords)))) 2127 keyword))
2012 (when keywords 2128 rcirc-keywords))))
2013 (while (re-search-forward (regexp-opt keywords 'words) nil t) 2129 (when keywords
2014 (rcirc-add-face (match-beginning 0) (match-end 0) 'rcirc-keyword) 2130 (while (re-search-forward (regexp-opt keywords 'words) nil t)
2015 (when (and (string= response "PRIVMSG") 2131 (rcirc-add-face (match-beginning 0) (match-end 0) 'rcirc-keyword)
2016 (not (string= sender (rcirc-nick process)))) 2132 (rcirc-record-activity (current-buffer) 'keyword))))))
2017 (rcirc-record-activity channel-buffer 'keyword)))))) 2133
2018 2134(defun rcirc-markup-bright-nicks (sender response)
2019(defun rcirc-markup-bright-nicks (process sender response channel-buffer)
2020 (when (and rcirc-bright-nicks 2135 (when (and rcirc-bright-nicks
2021 (string= response "NAMES")) 2136 (string= response "NAMES"))
2022 (with-syntax-table rcirc-nick-syntax-table 2137 (with-syntax-table rcirc-nick-syntax-table
2023 (while (re-search-forward (regexp-opt rcirc-bright-nicks 'words) nil t) 2138 (while (re-search-forward (regexp-opt rcirc-bright-nicks 'words) nil t)
2024 (rcirc-add-face (match-beginning 0) (match-end 0) 2139 (rcirc-add-face (match-beginning 0) (match-end 0)
2025 'rcirc-bright-nick))))) 2140 'rcirc-bright-nick)))))
2141
2142(defun rcirc-markup-fill (sender response)
2143 (when (not (string= response "372")) ; /motd
2144 (let ((fill-prefix
2145 (or rcirc-fill-prefix
2146 (make-string (- (point) (line-beginning-position)) ?\s)))
2147 (fill-column (cond ((eq rcirc-fill-column 'frame-width)
2148 (1- (frame-width)))
2149 (rcirc-fill-column
2150 rcirc-fill-column)
2151 (t fill-column))))
2152 (fill-region (point) (point-max) nil t))))
2026 2153
2027;;; handlers 2154;;; handlers
2028;; these are called with the server PROCESS, the SENDER, which is a 2155;; these are called with the server PROCESS, the SENDER, which is a
@@ -2099,8 +2226,7 @@ in this buffer.")
2099 ;; if the buffer is still around, make it inactive 2226 ;; if the buffer is still around, make it inactive
2100 (let ((buffer (rcirc-get-buffer process channel))) 2227 (let ((buffer (rcirc-get-buffer process channel)))
2101 (when buffer 2228 (when buffer
2102 (with-current-buffer buffer 2229 (rcirc-disconnect-buffer buffer)))))
2103 (setq rcirc-target nil))))))
2104 2230
2105(defun rcirc-handler-PART (process sender args text) 2231(defun rcirc-handler-PART (process sender args text)
2106 (let* ((channel (car args)) 2232 (let* ((channel (car args))
@@ -2169,7 +2295,7 @@ in this buffer.")
2169 (when rcirc-auto-authenticate-flag (rcirc-authenticate)))))) 2295 (when rcirc-auto-authenticate-flag (rcirc-authenticate))))))
2170 2296
2171(defun rcirc-handler-PING (process sender args text) 2297(defun rcirc-handler-PING (process sender args text)
2172 (rcirc-send-string process (concat "PONG " (car args)))) 2298 (rcirc-send-string process (concat "PONG :" (car args))))
2173 2299
2174(defun rcirc-handler-PONG (process sender args text) 2300(defun rcirc-handler-PONG (process sender args text)
2175 ;; do nothing 2301 ;; do nothing
@@ -2289,7 +2415,7 @@ Passwords are stored in `rcirc-authinfo' (which see)."
2289 process 2415 process
2290 (concat 2416 (concat
2291 "PRIVMSG chanserv :identify " 2417 "PRIVMSG chanserv :identify "
2292 (cadr args) " " (car args)))) 2418 (car args) " " (cadr args))))
2293 ((equal method 'bitlbee) 2419 ((equal method 'bitlbee)
2294 (rcirc-send-string 2420 (rcirc-send-string
2295 process 2421 process
@@ -2314,7 +2440,8 @@ Passwords are stored in `rcirc-authinfo' (which see)."
2314 (format "%s sent unsupported ctcp: %s" sender text) 2440 (format "%s sent unsupported ctcp: %s" sender text)
2315 t) 2441 t)
2316 (funcall handler process target sender args) 2442 (funcall handler process target sender args)
2317 (if (not (string= request "ACTION")) 2443 (unless (or (string= request "ACTION")
2444 (string= request "KEEPALIVE"))
2318 (rcirc-print process sender "CTCP" target 2445 (rcirc-print process sender "CTCP" target
2319 (format "%s" text) t)))))) 2446 (format "%s" text) t))))))
2320 2447