-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy patherc.el
6535 lines (5705 loc) · 217 KB
/
erc.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;; erc.el --- An Emacs Internet Relay Chat client
;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
;; 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
;; Author: Alexander L. Belikoff ([email protected])
;; Contributors: Sergey Berezin ([email protected]),
;; Mario Lang ([email protected]),
;; Alex Schroeder ([email protected])
;; Andreas Fuchs ([email protected])
;; Gergely Nagy ([email protected])
;; David Edmondson ([email protected])
;; Maintainer: Michael Olson ([email protected])
;; Keywords: IRC, chat, client, Internet
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; ERC is a powerful, modular, and extensible IRC client for Emacs.
;; For more information, see the following URLs:
;; * http://sv.gnu.org/projects/erc/
;; * http://www.emacswiki.org/cgi-bin/wiki/ERC
;; As of 2006-06-13, ERC development is now hosted on Savannah
;; (http://sv.gnu.org/projects/erc). I invite everyone who wants to
;; hack on it to contact me <[email protected]> in order to get write
;; access to the shared Arch archive.
;; Installation:
;; Put erc.el in your load-path, and put (require 'erc) in your .emacs.
;; Configuration:
;; Use M-x customize-group RET erc RET to get an overview
;; of all the variables you can tweak.
;; Usage:
;; To connect to an IRC server, do
;;
;; M-x erc RET
;;
;; After you are connected to a server, you can use C-h m or have a look at
;; the ERC menu.
;;; History:
;;
;;; Code:
(defconst erc-version-string "Version 5.3"
"ERC version. This is used by function `erc-version'.")
(eval-when-compile (require 'cl))
(require 'font-lock)
(require 'pp)
(require 'thingatpt)
(require 'erc-compat)
(defvar erc-official-location
"http://emacswiki.org/cgi-bin/wiki/ERC (mailing list: [email protected])"
"Location of the ERC client on the Internet.")
(defgroup erc nil
"Emacs Internet Relay Chat client."
:link '(url-link "http://www.emacswiki.org/cgi-bin/wiki/ERC")
:prefix "erc-"
:group 'applications)
(defgroup erc-buffers nil
"Creating new ERC buffers"
:group 'erc)
(defgroup erc-display nil
"Settings for how various things are displayed"
:group 'erc)
(defgroup erc-mode-line-and-header nil
"Displaying information in the mode-line and header"
:group 'erc-display)
(defgroup erc-ignore nil
"Ignoring certain messages"
:group 'erc)
(defgroup erc-query nil
"Using separate buffers for private discussions"
:group 'erc)
(defgroup erc-quit-and-part nil
"Quitting and parting channels"
:group 'erc)
(defgroup erc-paranoia nil
"Know what is sent and received; control the display of sensitive data."
:group 'erc)
(defgroup erc-scripts nil
"Running scripts at startup and with /LOAD"
:group 'erc)
(require 'erc-backend)
;; compatibility with older ERC releases
(if (fboundp 'defvaralias)
(progn
(defvaralias 'erc-announced-server-name 'erc-server-announced-name)
(erc-make-obsolete-variable 'erc-announced-server-name
'erc-server-announced-name
"ERC 5.1")
(defvaralias 'erc-process 'erc-server-process)
(erc-make-obsolete-variable 'erc-process 'erc-server-process "ERC 5.1")
(defvaralias 'erc-default-coding-system 'erc-server-coding-system)
(erc-make-obsolete-variable 'erc-default-coding-system
'erc-server-coding-system
"ERC 5.1"))
(message (concat "ERC: The function `defvaralias' is not bound. See the "
"NEWS file for variable name changes since ERC 5.0.4.")))
(defalias 'erc-send-command 'erc-server-send)
(erc-make-obsolete 'erc-send-command 'erc-server-send "ERC 5.1")
;; tunable connection and authentication parameters
(defcustom erc-server nil
"IRC server to use if one is not provided.
See function `erc-compute-server' for more details on connection
parameters and authentication."
:group 'erc
:type '(choice (const :tag "None" nil)
(string :tag "Server")))
(defcustom erc-port nil
"IRC port to use if not specified.
This can be either a string or a number."
:group 'erc
:type '(choice (const :tag "None" nil)
(integer :tag "Port number")
(string :tag "Port string")))
(defcustom erc-nick nil
"Nickname to use if one is not provided.
This can be either a string, or a list of strings.
In the latter case, if the first nick in the list is already in use,
other nicks are tried in the list order.
See function `erc-compute-nick' for more details on connection
parameters and authentication."
:group 'erc
:type '(choice (const :tag "None" nil)
(string :tag "Nickname")
(repeat (string :tag "Nickname"))))
(defcustom erc-nick-uniquifier "`"
"The string to append to the nick if it is already in use."
:group 'erc
:type 'string)
(defcustom erc-try-new-nick-p t
"If the nickname you chose isn't available, and this option is non-nil,
ERC should automatically attempt to connect with another nickname.
You can manually set another nickname with the /NICK command."
:group 'erc
:type 'boolean)
(defcustom erc-user-full-name nil
"User full name.
This can be either a string or a function to call.
See function `erc-compute-full-name' for more details on connection
parameters and authentication."
:group 'erc
:type '(choice (const :tag "No name" nil)
(string :tag "Name")
(function :tag "Get from function"))
:set (lambda (sym val)
(if (functionp val)
(set sym (funcall val))
(set sym val))))
(defvar erc-password nil
"Password to use when authenticating to an IRC server.
It is not strictly necessary to provide this, since ERC will
prompt you for it.")
(defcustom erc-user-mode nil
"Initial user modes to be set after a connection is established."
:group 'erc
:type '(choice (const nil) string function))
(defcustom erc-prompt-for-password t
"Asks before using the default password, or whether to enter a new one."
:group 'erc
:type 'boolean)
(defcustom erc-warn-about-blank-lines t
"Warn the user if they attempt to send a blank line."
:group 'erc
:type 'boolean)
(defcustom erc-send-whitespace-lines nil
"If set to non-nil, send lines consisting of only whitespace."
:group 'erc
:type 'boolean)
(defcustom erc-hide-prompt nil
"If non-nil, do not display the prompt for commands.
\(A command is any input starting with a '/').
See also the variables `erc-prompt' and `erc-command-indicator'."
:group 'erc-display
:type 'boolean)
;; tunable GUI stuff
(defcustom erc-show-my-nick t
"If non-nil, display one's own nickname when sending a message.
If non-nil, \"<nickname>\" will be shown.
If nil, only \"> \" will be shown."
:group 'erc-display
:type 'boolean)
(define-widget 'erc-message-type 'set
"A set of standard IRC Message types."
:args '((const "JOIN")
(const "KICK")
(const "NICK")
(const "PART")
(const "QUIT")
(const "MODE")
(repeat :inline t :tag "Others" (string :tag "IRC Message Type"))))
(defcustom erc-hide-list nil
"*List of IRC type messages to hide.
A typical value would be '(\"JOIN\" \"PART\" \"QUIT\")."
:group 'erc-ignore
:type 'erc-message-type)
(defvar erc-session-password nil
"The password used for the current session.")
(make-variable-buffer-local 'erc-session-password)
(defcustom erc-disconnected-hook nil
"Run this hook with arguments (NICK IP REASON) when disconnected.
This happens before automatic reconnection. Note, that
`erc-server-QUIT-functions' might not be run when we disconnect,
simply because we do not necessarily receive the QUIT event."
:group 'erc-hooks
:type 'hook)
(defcustom erc-complete-functions nil
"These functions get called when the user hits TAB in ERC.
Each function in turn is called until one returns non-nil to
indicate it has handled the input."
:group 'erc-hooks
:type 'hook)
(defcustom erc-join-hook nil
"Hook run when we join a channel. Hook functions are called
without arguments, with the current buffer set to the buffer of
the new channel.
See also `erc-server-JOIN-functions', `erc-part-hook'."
:group 'erc-hooks
:type 'hook)
(defcustom erc-quit-hook nil
"Hook run when processing a quit command directed at our nick.
The hook receives one argument, the current PROCESS.
See also `erc-server-QUIT-functions' and `erc-disconnected-hook'."
:group 'erc-hooks
:type 'hook)
(defcustom erc-part-hook nil
"Hook run when processing a PART message directed at our nick.
The hook receives one argument, the current BUFFER.
See also `erc-server-QUIT-functions', `erc-quit-hook' and
`erc-disconnected-hook'."
:group 'erc-hooks
:type 'hook)
(defcustom erc-kick-hook nil
"Hook run when processing a KICK message directed at our nick.
The hook receives one argument, the current BUFFER.
See also `erc-server-PART-functions' and `erc-part-hook'."
:group 'erc-hooks
:type 'hook)
(defcustom erc-nick-changed-functions nil
"List of functions run when your nick was successfully changed.
Each function should accept two arguments, NEW-NICK and OLD-NICK."
:group 'erc-hooks
:type 'hook)
(defcustom erc-connect-pre-hook '(erc-initialize-log-marker)
"Hook called just before `erc' calls `erc-connect'.
Functions are passed a buffer as the first argument."
:group 'erc-hooks
:type 'hook)
(defvar erc-channel-users nil
"A hash table of members in the current channel, which
associates nicknames with cons cells of the form:
\(USER . MEMBER-DATA) where USER is a pointer to an
erc-server-user struct, and MEMBER-DATA is a pointer to an
erc-channel-user struct.")
(make-variable-buffer-local 'erc-channel-users)
(defvar erc-server-users nil
"A hash table of users on the current server, which associates
nicknames with erc-server-user struct instances.")
(make-variable-buffer-local 'erc-server-users)
(defun erc-downcase (string)
"Convert STRING to IRC standard conforming downcase."
(let ((s (downcase string))
(c '((?\[ . ?\{)
(?\] . ?\})
(?\\ . ?\|)
(?~ . ?^))))
(save-match-data
(while (string-match "[]\\[~]" s)
(aset s (match-beginning 0)
(cdr (assq (aref s (match-beginning 0)) c)))))
s))
(defmacro erc-with-server-buffer (&rest body)
"Execute BODY in the current ERC server buffer.
If no server buffer exists, return nil."
(let ((buffer (make-symbol "buffer")))
`(let ((,buffer (erc-server-buffer)))
(when (buffer-live-p ,buffer)
(with-current-buffer ,buffer
,@body)))))
(put 'erc-with-server-buffer 'lisp-indent-function 0)
(put 'erc-with-server-buffer 'edebug-form-spec '(body))
(defstruct (erc-server-user (:type vector) :named)
;; User data
nickname host login full-name info
;; Buffers
;;
;; This is an alist of the form (BUFFER . CHANNEL-DATA), where
;; CHANNEL-DATA is either nil or an erc-channel-user struct.
(buffers nil)
)
(defstruct (erc-channel-user (:type vector) :named)
op voice
;; Last message time (in the form of the return value of
;; (current-time)
;;
;; This is useful for ordered name completion.
(last-message-time nil))
(defsubst erc-get-channel-user (nick)
"Finds the (USER . CHANNEL-DATA) element corresponding to NICK
in the current buffer's `erc-channel-users' hash table."
(gethash (erc-downcase nick) erc-channel-users))
(defsubst erc-get-server-user (nick)
"Finds the USER corresponding to NICK in the current server's
`erc-server-users' hash table."
(erc-with-server-buffer
(gethash (erc-downcase nick) erc-server-users)))
(defsubst erc-add-server-user (nick user)
"This function is for internal use only.
Adds USER with nickname NICK to the `erc-server-users' hash table."
(erc-with-server-buffer
(puthash (erc-downcase nick) user erc-server-users)))
(defsubst erc-remove-server-user (nick)
"This function is for internal use only.
Removes the user with nickname NICK from the `erc-server-users'
hash table. This user is not removed from the
`erc-channel-users' lists of other buffers.
See also: `erc-remove-user'."
(erc-with-server-buffer
(remhash (erc-downcase nick) erc-server-users)))
(defun erc-change-user-nickname (user new-nick)
"This function is for internal use only.
Changes the nickname of USER to NEW-NICK in the
`erc-server-users' hash table. The `erc-channel-users' lists of
other buffers are also changed."
(let ((nick (erc-server-user-nickname user)))
(setf (erc-server-user-nickname user) new-nick)
(erc-with-server-buffer
(remhash (erc-downcase nick) erc-server-users)
(puthash (erc-downcase new-nick) user erc-server-users))
(dolist (buf (erc-server-user-buffers user))
(if (buffer-live-p buf)
(with-current-buffer buf
(let ((cdata (erc-get-channel-user nick)))
(remhash (erc-downcase nick) erc-channel-users)
(puthash (erc-downcase new-nick) cdata
erc-channel-users)))))))
(defun erc-remove-channel-user (nick)
"This function is for internal use only.
Removes the user with nickname NICK from the `erc-channel-users'
list for this channel. If this user is not in the
`erc-channel-users' list of any other buffers, the user is also
removed from the server's `erc-server-users' list.
See also: `erc-remove-server-user' and `erc-remove-user'."
(let ((channel-data (erc-get-channel-user nick)))
(when channel-data
(let ((user (car channel-data)))
(setf (erc-server-user-buffers user)
(delq (current-buffer)
(erc-server-user-buffers user)))
(remhash (erc-downcase nick) erc-channel-users)
(if (null (erc-server-user-buffers user))
(erc-remove-server-user nick))))))
(defun erc-remove-user (nick)
"This function is for internal use only.
Removes the user with nickname NICK from the `erc-server-users'
list as well as from all `erc-channel-users' lists.
See also: `erc-remove-server-user' and
`erc-remove-channel-user'."
(let ((user (erc-get-server-user nick)))
(when user
(let ((buffers (erc-server-user-buffers user)))
(dolist (buf buffers)
(if (buffer-live-p buf)
(with-current-buffer buf
(remhash (erc-downcase nick) erc-channel-users)
(run-hooks 'erc-channel-members-changed-hook)))))
(erc-remove-server-user nick))))
(defun erc-remove-channel-users ()
"This function is for internal use only.
Removes all users in the current channel. This is called by
`erc-server-PART' and `erc-server-QUIT'."
(when (and erc-server-connected
(erc-server-process-alive)
(hash-table-p erc-channel-users))
(maphash (lambda (nick cdata)
(erc-remove-channel-user nick))
erc-channel-users)
(clrhash erc-channel-users)))
(defsubst erc-channel-user-op-p (nick)
"Return t if NICK is an operator in the current channel."
(and nick
(hash-table-p erc-channel-users)
(let ((cdata (erc-get-channel-user nick)))
(and cdata (cdr cdata)
(erc-channel-user-op (cdr cdata))))))
(defsubst erc-channel-user-voice-p (nick)
"Return t if NICK has voice in the current channel."
(and nick
(hash-table-p erc-channel-users)
(let ((cdata (erc-get-channel-user nick)))
(and cdata (cdr cdata)
(erc-channel-user-voice (cdr cdata))))))
(defun erc-get-channel-user-list ()
"Returns a list of users in the current channel. Each element
of the list is of the form (USER . CHANNEL-DATA), where USER is
an erc-server-user struct, and CHANNEL-DATA is either `nil' or an
erc-channel-user struct.
See also: `erc-sort-channel-users-by-activity'"
(let (users)
(if (hash-table-p erc-channel-users)
(maphash (lambda (nick cdata)
(setq users (cons cdata users)))
erc-channel-users))
users))
(defun erc-get-server-nickname-list ()
"Returns a list of known nicknames on the current server."
(erc-with-server-buffer
(let (nicks)
(when (hash-table-p erc-server-users)
(maphash (lambda (n user)
(setq nicks
(cons (erc-server-user-nickname user)
nicks)))
erc-server-users)
nicks))))
(defun erc-get-channel-nickname-list ()
"Returns a list of known nicknames on the current channel."
(let (nicks)
(when (hash-table-p erc-channel-users)
(maphash (lambda (n cdata)
(setq nicks
(cons (erc-server-user-nickname (car cdata))
nicks)))
erc-channel-users)
nicks)))
(defun erc-get-server-nickname-alist ()
"Returns an alist of known nicknames on the current server."
(erc-with-server-buffer
(let (nicks)
(when (hash-table-p erc-server-users)
(maphash (lambda (n user)
(setq nicks
(cons (cons (erc-server-user-nickname user) nil)
nicks)))
erc-server-users)
nicks))))
(defun erc-get-channel-nickname-alist ()
"Returns an alist of known nicknames on the current channel."
(let (nicks)
(when (hash-table-p erc-channel-users)
(maphash (lambda (n cdata)
(setq nicks
(cons (cons (erc-server-user-nickname (car cdata)) nil)
nicks)))
erc-channel-users)
nicks)))
(defun erc-sort-channel-users-by-activity (list)
"Sorts LIST such that users which have spoken most recently are
listed first. LIST must be of the form (USER . CHANNEL-DATA).
See also: `erc-get-channel-user-list'."
(sort list
(lambda (x y)
(when (and
(cdr x) (cdr y))
(let ((tx (erc-channel-user-last-message-time (cdr x)))
(ty (erc-channel-user-last-message-time (cdr y))))
(if tx
(if ty
(time-less-p ty tx)
t)
nil))))))
(defun erc-sort-channel-users-alphabetically (list)
"Sort LIST so that users' nicknames are in alphabetical order.
LIST must be of the form (USER . CHANNEL-DATA).
See also: `erc-get-channel-user-list'."
(sort list
(lambda (x y)
(when (and
(cdr x) (cdr y))
(let ((nickx (downcase (erc-server-user-nickname (car x))))
(nicky (downcase (erc-server-user-nickname (car y)))))
(if nickx
(if nicky
(string-lessp nickx nicky)
t)
nil))))))
(defvar erc-channel-topic nil
"A topic string for the channel. Should only be used in channel-buffers.")
(make-variable-buffer-local 'erc-channel-topic)
(defvar erc-channel-modes nil
"List of strings representing channel modes.
E.g. '(\"i\" \"m\" \"s\" \"b Quake!*@*\")
\(not sure the ban list will be here, but why not)")
(make-variable-buffer-local 'erc-channel-modes)
(defvar erc-insert-marker nil
"The place where insertion of new text in erc buffers should happen.")
(make-variable-buffer-local 'erc-insert-marker)
(defvar erc-input-marker nil
"The marker where input should be inserted.")
(make-variable-buffer-local 'erc-input-marker)
(defun erc-string-no-properties (string)
"Return a copy of STRING will all text-properties removed."
(let ((newstring (copy-sequence string)))
(set-text-properties 0 (length newstring) nil newstring)
newstring))
(defcustom erc-prompt "ERC>"
"Prompt used by ERC. Trailing whitespace is not required."
:group 'erc-display
:type '(choice string function))
(defun erc-prompt ()
"Return the input prompt as a string.
See also the variable `erc-prompt'."
(let ((prompt (if (functionp erc-prompt)
(funcall erc-prompt)
erc-prompt)))
(if (> (length prompt) 0)
(concat prompt " ")
prompt)))
(defcustom erc-command-indicator nil
"Indicator used by ERC for showing commands.
If non-nil, this will be used in the ERC buffer to indicate
commands (i.e., input starting with a '/').
If nil, the prompt will be constructed from the variable `erc-prompt'."
:group 'erc-display
:type '(choice (const nil) string function))
(defun erc-command-indicator ()
"Return the command indicator prompt as a string.
This only has any meaning if the variable `erc-command-indicator' is non-nil."
(and erc-command-indicator
(let ((prompt (if (functionp erc-command-indicator)
(funcall erc-command-indicator)
erc-command-indicator)))
(if (> (length prompt) 0)
(concat prompt " ")
prompt))))
(defcustom erc-notice-prefix "*** "
"*Prefix for all notices."
:group 'erc-display
:type 'string)
(defcustom erc-notice-highlight-type 'all
"*Determines how to highlight notices.
See `erc-notice-prefix'.
The following values are allowed:
'prefix - highlight notice prefix only
'all - highlight the entire notice
Any other value disables notice's highlighting altogether."
:group 'erc-display
:type '(choice (const :tag "highlight notice prefix only" prefix)
(const :tag "highlight the entire notice" all)
(const :tag "don't highlight notices at all" nil)))
(defcustom erc-echo-notice-hook nil
"*Specifies a list of functions to call to echo a private
notice. Each function is called with four arguments, the string
to display, the parsed server message, the target buffer (or
nil), and the sender. The functions are called in order, until a
function evaluates to non-nil. These hooks are called after
those specified in `erc-echo-notice-always-hook'.
See also: `erc-echo-notice-always-hook',
`erc-echo-notice-in-default-buffer',
`erc-echo-notice-in-target-buffer',
`erc-echo-notice-in-minibuffer',
`erc-echo-notice-in-server-buffer',
`erc-echo-notice-in-active-non-server-buffer',
`erc-echo-notice-in-active-buffer',
`erc-echo-notice-in-user-buffers',
`erc-echo-notice-in-user-and-target-buffers',
`erc-echo-notice-in-first-user-buffer'"
:group 'erc-hooks
:type 'hook
:options '(erc-echo-notice-in-default-buffer
erc-echo-notice-in-target-buffer
erc-echo-notice-in-minibuffer
erc-echo-notice-in-server-buffer
erc-echo-notice-in-active-non-server-buffer
erc-echo-notice-in-active-buffer
erc-echo-notice-in-user-buffers
erc-echo-notice-in-user-and-target-buffers
erc-echo-notice-in-first-user-buffer))
(defcustom erc-echo-notice-always-hook
'(erc-echo-notice-in-default-buffer)
"*Specifies a list of functions to call to echo a private
notice. Each function is called with four arguments, the string
to display, the parsed server message, the target buffer (or
nil), and the sender. The functions are called in order, and all
functions are called. These hooks are called before those
specified in `erc-echo-notice-hook'.
See also: `erc-echo-notice-hook',
`erc-echo-notice-in-default-buffer',
`erc-echo-notice-in-target-buffer',
`erc-echo-notice-in-minibuffer',
`erc-echo-notice-in-server-buffer',
`erc-echo-notice-in-active-non-server-buffer',
`erc-echo-notice-in-active-buffer',
`erc-echo-notice-in-user-buffers',
`erc-echo-notice-in-user-and-target-buffers',
`erc-echo-notice-in-first-user-buffer'"
:group 'erc-hooks
:type 'hook
:options '(erc-echo-notice-in-default-buffer
erc-echo-notice-in-target-buffer
erc-echo-notice-in-minibuffer
erc-echo-notice-in-server-buffer
erc-echo-notice-in-active-non-server-buffer
erc-echo-notice-in-active-buffer
erc-echo-notice-in-user-buffers
erc-echo-notice-in-user-and-target-buffers
erc-echo-notice-in-first-user-buffer))
;; other tunable parameters
(defcustom erc-whowas-on-nosuchnick nil
"*If non-nil, do a whowas on a nick if no such nick."
:group 'erc
:type 'boolean)
(defcustom erc-verbose-server-ping nil
"*If non-nil, show every time you get a PING or PONG from the server."
:group 'erc-paranoia
:type 'boolean)
(defcustom erc-public-away-p nil
"*Let others know you are back when you are no longer marked away.
This happens in this form:
* <nick> is back (gone for <time>)
Many consider it impolite to do so automatically."
:group 'erc
:type 'boolean)
(defcustom erc-away-nickname nil
"*The nickname to take when you are marked as being away."
:group 'erc
:type '(choice (const nil)
string))
(defcustom erc-paranoid nil
"If non-nil, then all incoming CTCP requests will be shown."
:group 'erc-paranoia
:type 'boolean)
(defcustom erc-disable-ctcp-replies nil
"Disable replies to CTCP requests that require a reply.
If non-nil, then all incoming CTCP requests that normally require
an automatic reply (like VERSION or PING) will be ignored. Good to
set if some hacker is trying to flood you away."
:group 'erc-paranoia
:type 'boolean)
(defcustom erc-anonymous-login t
"Be paranoid, don't give away your machine name."
:group 'erc-paranoia
:type 'boolean)
(defcustom erc-prompt-for-channel-key nil
"Prompt for channel key when using `erc-join-channel' interactively."
:group 'erc
:type 'boolean)
(defcustom erc-email-userid "user"
"Use this as your email user ID."
:group 'erc
:type 'string)
(defcustom erc-system-name nil
"Use this as the name of your system.
If nil, ERC will call `system-name' to get this information."
:group 'erc
:type '(choice (const :tag "Default system name" nil)
string))
(defcustom erc-ignore-list nil
"*List of regexps matching user identifiers to ignore.
A user identifier has the form \"nick!login@host\". If an
identifier matches, the message from the person will not be
processed."
:group 'erc-ignore
:type '(repeat regexp))
(make-variable-buffer-local 'erc-ignore-list)
(defcustom erc-ignore-reply-list nil
"*List of regexps matching user identifiers to ignore completely.
This differs from `erc-ignore-list' in that it also ignores any
messages directed at the user.
A user identifier has the form \"nick!login@host\".
If an identifier matches, or a message is addressed to a nick
whose identifier matches, the message will not be processed.
CAVEAT: ERC doesn't know about the user and host of anyone who
was already in the channel when you joined, but never said
anything, so it won't be able to match the user and host of those
people. You can update the ERC internal info using /WHO *."
:group 'erc-ignore
:type '(repeat regexp))
(defvar erc-flood-protect t
"*If non-nil, flood protection is enabled.
Flooding is sending too much information to the server in too
short of an interval, which may cause the server to terminate the
connection.
See `erc-server-flood-margin' for other flood-related parameters.")
;; Script parameters
(defcustom erc-startup-file-list
(list (concat erc-user-emacs-directory ".ercrc.el")
(concat erc-user-emacs-directory ".ercrc")
"~/.ercrc.el" "~/.ercrc" ".ercrc.el" ".ercrc")
"List of files to try for a startup script.
The first existent and readable one will get executed.
If the filename ends with `.el' it is presumed to be an Emacs Lisp
script and it gets (load)ed. Otherwise it is treated as a bunch of
regular IRC commands."
:group 'erc-scripts
:type '(repeat file))
(defcustom erc-script-path nil
"List of directories to look for a script in /load command.
The script is first searched in the current directory, then in each
directory in the list."
:group 'erc-scripts
:type '(repeat directory))
(defcustom erc-script-echo t
"*If non-nil, echo the IRC script commands locally."
:group 'erc-scripts
:type 'boolean)
(defvar erc-last-saved-position nil
"A marker containing the position the current buffer was last saved at.")
(make-variable-buffer-local 'erc-last-saved-position)
(defcustom erc-kill-buffer-on-part nil
"Kill the channel buffer on PART.
This variable should probably stay nil, as ERC can reuse buffers if
you rejoin them later."
:group 'erc-quit-and-part
:type 'boolean)
(defcustom erc-kill-queries-on-quit nil
"Kill all query (also channel) buffers of this server on QUIT.
See the variable `erc-kill-buffer-on-part' for details."
:group 'erc-quit-and-part
:type 'boolean)
(defcustom erc-kill-server-buffer-on-quit nil
"Kill the server buffer of the process on QUIT."
:group 'erc-quit-and-part
:type 'boolean)
(defcustom erc-quit-reason-various-alist nil
"Alist of possible arguments to the /quit command.
Each element has the form:
(REGEXP RESULT)
If REGEXP matches the argument to /quit, then its relevant RESULT
will be used. RESULT may be either a string, or a function. If
a function, it should return the quit message as a string.
If no elements match, then the empty string is used.
As an example:
(setq erc-quit-reason-various-alist
'((\"zippy\" erc-quit-reason-zippy)
(\"xmms\" dme:now-playing)
(\"version\" erc-quit-reason-normal)
(\"home\" \"Gone home !\")
(\"^$\" \"Default Reason\")))
If the user types \"/quit zippy\", then a Zippy the Pinhead quotation
will be used as the quit message."
:group 'erc-quit-and-part
:type '(repeat (list regexp (choice (string) (function)))))
(defcustom erc-part-reason-various-alist nil
"Alist of possible arguments to the /part command.
Each element has the form:
(REGEXP RESULT)
If REGEXP matches the argument to /part, then its relevant RESULT
will be used. RESULT may be either a string, or a function. If
a function, it should return the part message as a string.
If no elements match, then the empty string is used.
As an example:
(setq erc-part-reason-various-alist
'((\"zippy\" erc-part-reason-zippy)
(\"xmms\" dme:now-playing)
(\"version\" erc-part-reason-normal)
(\"home\" \"Gone home !\")
(\"^$\" \"Default Reason\")))
If the user types \"/part zippy\", then a Zippy the Pinhead quotation
will be used as the part message."
:group 'erc-quit-and-part
:type '(repeat (list regexp (choice (string) (function)))))
(defcustom erc-quit-reason 'erc-quit-reason-normal
"*A function which returns the reason for quitting.
The function is passed a single argument, the string typed by the
user after \"/quit\"."
:group 'erc-quit-and-part
:type '(choice (const erc-quit-reason-normal)
(const erc-quit-reason-zippy)
(const erc-quit-reason-various)
(symbol)))
(defcustom erc-part-reason 'erc-part-reason-normal
"A function which returns the reason for parting a channel.
The function is passed a single argument, the string typed by the
user after \"/PART\"."
:group 'erc-quit-and-part
:type '(choice (const erc-part-reason-normal)
(const erc-part-reason-zippy)
(const erc-part-reason-various)
(symbol)))
(defvar erc-grab-buffer-name "*erc-grab*"
"The name of the buffer created by `erc-grab-region'.")
;; variables available for IRC scripts
(defvar erc-user-information "ERC User"
"USER_INFORMATION IRC variable.")
;; Hooks
(defgroup erc-hooks nil
"Hook variables for fancy customizations of ERC."
:group 'erc)
(defcustom erc-mode-hook nil
"Hook run after `erc-mode' setup is finished."
:group 'erc-hooks
:type 'hook
:options '(erc-add-scroll-to-bottom))
(defcustom erc-timer-hook nil
"Put functions which should get called more or less periodically here.
The idea is that servers always play ping pong with the client, and so there
is no need for any idle-timer games with Emacs."
:group 'erc-hooks
:type 'hook)
(defcustom erc-insert-pre-hook nil
"Hook called first when some text is inserted through `erc-display-line'.
It gets called with one argument, STRING.
To be able to modify the inserted text, use `erc-insert-modify-hook' instead.
Filtering functions can set `erc-insert-this' to nil to avoid
display of that particular string at all."
:group 'erc-hooks
:type 'hook)
(defcustom erc-send-pre-hook nil
"Hook called first when some text is sent through `erc-send-current-line'.
It gets called with one argument, STRING.
To change the text that will be sent, set the variable STR which is
used in `erc-send-current-line'.
To change the text inserted into the buffer without changing the text
that will be sent, use `erc-send-modify-hook' instead.
Filtering functions can set `erc-send-this' to nil to avoid sending of
that particular string at all and `erc-insert-this' to prevent