annotate lisp/erc/erc-capab.el @ 103429:8f7555e94264

Document changes to end-of-defun-function, clarifying entry for beginning-of-defun-function.
author Alan Mackenzie <acm@muc.de>
date Mon, 15 Jun 2009 09:05:17 +0000
parents a9dc0e7c3f2b
children 1d1d5d9bd884
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1 ;;; erc-capab.el --- support for dancer-ircd and hyperion's CAPAB
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2
100908
a9dc0e7c3f2b Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 96363
diff changeset
3 ;; Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
4
94660
2a734255bcc7 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79706
diff changeset
5 ;; GNU Emacs is free software: you can redistribute it and/or modify
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
6 ;; it under the terms of the GNU General Public License as published by
94660
2a734255bcc7 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79706
diff changeset
7 ;; the Free Software Foundation, either version 3 of the License, or
2a734255bcc7 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79706
diff changeset
8 ;; (at your option) any later version.
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
9
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is distributed in the hope that it will be useful,
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
13 ;; GNU General Public License for more details.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
14
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
15 ;; You should have received a copy of the GNU General Public License
94660
2a734255bcc7 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79706
diff changeset
16 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
17
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
18 ;;; Commentary:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
19
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
20 ;; This file defines the ERC module `erc-capab-identify', which allows
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
21 ;; flagging of unidentified users on servers running dancer-ircd or
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
22 ;; hyperion. freenode.net supports this capability, for example.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
23
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
24 ;; With CAPAB IDENTIFY-MSG and IDENTIFY-CTCP enabled, messages from
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
25 ;; users who have identified themselves to NickServ will have a plus
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
26 ;; sign and messages from unidentified users will have a minus sign
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
27 ;; added as a prefix. Note that it is not necessary for your nickname
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
28 ;; to be identified in order to receive these marked messages.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
29
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
30 ;; The plus or minus sign is removed from the message, and a prefix,
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
31 ;; `erc-capab-identify-prefix', is inserted in the front of the user's
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
32 ;; nickname if the nickname is not identified.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
33
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
34 ;; Please note that once this has been enabled on a server, there is no
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
35 ;; way to tell the server to stop sending marked messages. If you
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
36 ;; disable this module, it will continue removing message flags, but the
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
37 ;; unidentified nickname prefix will not be added to messages.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
38
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
39 ;; Visit <http://freenode.net/faq.shtml#spoofing> and
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
40 ;; <http://freenode.net/faq.shtml#registering> to find further
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
41 ;; explanations of this capability.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
42
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
43 ;; From freenode.net's web site (not there anymore) on how to mark
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
44 ;; unidentified users:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
45 ;; "We recommend that you add an asterisk before the nick, and
96363
f9d35151b907 American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents: 94660
diff changeset
46 ;; optionally either highlight or colorize the line in some
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
47 ;; appropriate fashion, if the user is not identified."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
48
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
49 ;;; Usage:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
50
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
51 ;; Put the following in your ~/.emacs file.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
52
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
53 ;; (require 'erc-capab)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
54 ;; (erc-capab-identify-mode 1)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
55
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
56 ;; `erc-capab-identify-prefix' will now be added to the beginning of
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
57 ;; unidentified users' nicknames. The default is an asterisk, "*".
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
58 ;; You can customize the prefix and the face used to display it,
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
59 ;; `erc-capab-identify-unidentified'. If the value of
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
60 ;; `erc-capab-identify-prefix' is nil or you disable this module (see
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
61 ;; `erc-capab-identify-disable'), no prefix will be inserted, but the
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
62 ;; flag sent by the server will still be stripped.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
63
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
64 ;;; Code:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
65
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
66 (require 'erc)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
67 (eval-when-compile (require 'cl))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
68
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
69 ;;; Customization:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
70
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
71 (defgroup erc-capab nil
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
72 "Support for dancer-ircd's CAPAB settings."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
73 :group 'erc)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
74
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
75 (defcustom erc-capab-identify-prefix "*"
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
76 "The prefix used for unidentified users.
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
77
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
78 If you change this from the default \"*\", be sure to use a
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
79 character not found in IRC nicknames to avoid confusion."
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
80 :group 'erc-capab
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
81 :type '(choice string (const nil)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
82
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
83 (defface erc-capab-identify-unidentified '((t)) ; same as `erc-default-face'
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
84 "Face to use for `erc-capab-identify-prefix'."
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
85 :group 'erc-capab
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
86 :group 'erc-faces)
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
87
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
88 ;;; Define module:
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
89
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
90 ;;;###autoload (autoload 'erc-capab-identify-mode "erc-capab" nil t)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
91 (define-erc-module capab-identify nil
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
92 "Handle dancer-ircd's CAPAB IDENTIFY-MSG and IDENTIFY-CTCP."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
93 ;; append so that `erc-server-parameters' is already set by `erc-server-005'
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
94 ((add-hook 'erc-server-005-functions 'erc-capab-identify-setup t)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
95 (add-hook 'erc-server-290-functions 'erc-capab-identify-activate)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
96 (add-hook 'erc-server-PRIVMSG-functions
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
97 'erc-capab-identify-remove/set-identified-flag)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
98 (add-hook 'erc-server-NOTICE-functions
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
99 'erc-capab-identify-remove/set-identified-flag)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
100 (add-hook 'erc-insert-modify-hook 'erc-capab-identify-add-prefix t)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
101 (mapc (lambda (buffer)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
102 (when buffer
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
103 (with-current-buffer buffer (erc-capab-identify-setup))))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
104 (erc-buffer-list 'erc-open-server-buffer-p)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
105 ((remove-hook 'erc-server-005-functions 'erc-capab-identify-setup)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
106 (remove-hook 'erc-server-290-functions 'erc-capab-identify-activate)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
107 ;; we don't remove the `erc-capab-identify-remove/set-identified-flag' hooks
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
108 ;; because there doesn't seem to be a way to tell the server to turn it off
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
109 (remove-hook 'erc-insert-modify-hook 'erc-capab-identify-add-prefix)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
110
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
111 ;;; Variables:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
112
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
113 (defvar erc-capab-identify-activated nil
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
114 "CAPAB IDENTIFY-MSG has been activated.")
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
115 (make-variable-buffer-local 'erc-capab-identify-activated)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
116
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
117 (defvar erc-capab-identify-sent nil
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
118 "CAPAB IDENTIFY-MSG and IDENTIFY-CTCP messages have been sent.")
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
119 (make-variable-buffer-local 'erc-capab-identify-sent)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
120
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
121 ;;; Functions:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
122
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
123 (defun erc-capab-identify-setup (&optional proc parsed)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
124 "Set up CAPAB IDENTIFY on the current server.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
125
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
126 Optional argument PROC is the current server's process.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
127 Optional argument PARSED is the current message, a response struct.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
128
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
129 These arguments are sent to this function when called as a hook in
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
130 `erc-server-005-functions'."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
131 (unless erc-capab-identify-sent
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
132 (erc-capab-identify-send-messages)))
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
133
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
134 (defun erc-capab-identify-send-messages ()
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
135 "Send CAPAB IDENTIFY messages if the server supports it."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
136 (when (and (stringp erc-server-version)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
137 (string-match "^\\(dancer-ircd\\|hyperion\\)" erc-server-version)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
138 ;; could possibly check for '("IRCD" . "dancer") in
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
139 ;; `erc-server-parameters' instead of looking for a specific name
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
140 ;; in `erc-server-version'
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
141 (assoc "CAPAB" erc-server-parameters))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
142 (erc-log "Sending CAPAB IDENTIFY-MSG and IDENTIFY-CTCP")
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
143 (erc-server-send "CAPAB IDENTIFY-MSG")
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
144 (erc-server-send "CAPAB IDENTIFY-CTCP")
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
145 (setq erc-capab-identify-sent t)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
146
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
147
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
148 (defun erc-capab-identify-activate (proc parsed)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
149 "Set `erc-capab-identify-activated' and display an activation message.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
150
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
151 PROC is the current server's process.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
152 PARSED is an `erc-parsed' response struct."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
153 (when (or (string= "IDENTIFY-MSG" (erc-response.contents parsed))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
154 (string= "IDENTIFY-CTCP" (erc-response.contents parsed)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
155 (setq erc-capab-identify-activated t)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
156 (erc-display-message
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
157 parsed 'notice 'active (format "%s activated"
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
158 (erc-response.contents parsed)))))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
159
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
160 (defun erc-capab-identify-remove/set-identified-flag (proc parsed)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
161 "Remove PARSED message's id flag and add the `erc-identified' text property.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
162
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
163 PROC is the current server's process.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
164 PARSED is an `erc-parsed' response struct."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
165 (let ((msg (erc-response.contents parsed)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
166 (when (and erc-capab-identify-activated
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
167 (string-match "^\\([-\\+]\\)\\(.+\\)$" msg))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
168 (setf (erc-response.contents parsed)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
169 (if erc-capab-identify-mode
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
170 (erc-propertize (match-string 2 msg)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
171 'erc-identified
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
172 (if (string= (match-string 1 msg) "+")
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
173 1
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
174 0))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
175 (match-string 2 msg)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
176 nil)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
177
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
178 (defun erc-capab-identify-add-prefix ()
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
179 "Add `erc-capab-identify-prefix' to nickname if user is unidentified."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
180 (when (and erc-capab-identify-prefix
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
181 (erc-with-server-buffer erc-capab-identify-activated))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
182 (goto-char (or (erc-find-parsed-property) (point-min)))
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
183 (let ((nickname (erc-capab-identify-get-unidentified-nickname
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
184 (erc-get-parsed-vector (point)))))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
185 (when (and nickname
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
186 (goto-char (point-min))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
187 ;; assuming the first use of `nickname' is the sender's nick
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
188 (re-search-forward (regexp-quote nickname) nil t))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
189 (goto-char (match-beginning 0))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
190 (insert (erc-propertize erc-capab-identify-prefix
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
191 'face 'erc-capab-identify-unidentified))))))
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
192
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
193 (defun erc-capab-identify-get-unidentified-nickname (parsed)
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
194 "Return the nickname of the user if unidentified.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
195 PARSED is an `erc-parsed' response struct."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
196 (when (and (erc-response-p parsed)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
197 (equal 0 (get-text-property 0 'erc-identified
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
198 (erc-response.contents parsed))))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
199 (let ((nickuserhost (erc-get-parsed-vector-nick parsed)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
200 (when nickuserhost
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
201 (nth 0 (erc-parse-user nickuserhost))))))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
202
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
203 (provide 'erc-capab)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
204
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
205 ;; arch-tag: 27b6d668-7ee5-4e47-b9f0-27d7a4362062
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
206 ;;; erc-capab.el ends here