annotate lisp/erc/erc-capab.el @ 76297:35a8988b02f7

(type-break-get-previous-time): Handle end-of-file errors specially so they don't get reported wrong in .emacs.
author Richard M. Stallman <rms@gnu.org>
date Sun, 04 Mar 2007 17:50:46 +0000
parents 7a3f13e2dd57
children 2fae574a2382
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
75346
7a3f13e2dd57 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 75259
diff changeset
3 ;; Copyright (C) 2006, 2007 Free Software Foundation, Inc.
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
4
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
5 ;; GNU Emacs is free software; you can redistribute it and/or modify
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
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
7 ;; the Free Software Foundation; either version 2, or (at your option)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
8 ;; any later version.
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
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
16 ;; along with GNU Emacs; see the file COPYING. If not, write to the
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
17 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
18 ;; Boston, MA 02110-1301, USA.
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 ;;; Commentary:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
21
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
22 ;; 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
23 ;; flagging of unidentified users on servers running dancer-ircd or
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
24 ;; hyperion. freenode.net supports this capability, for example.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
25
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
26 ;; With CAPAB IDENTIFY-MSG and IDENTIFY-CTCP enabled, messages from
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
27 ;; 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
28 ;; 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
29 ;; 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
30 ;; to be identified in order to receive these marked messages.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
31
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
32 ;; 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
33 ;; `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
34 ;; nickname if the nickname is not identified.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
35
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
36 ;; 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
37 ;; 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
38 ;; 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
39 ;; unidentified nickname prefix will not be added to messages.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
40
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
41 ;; Visit <http://freenode.net/faq.shtml#spoofing> and
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
42 ;; <http://freenode.net/faq.shtml#registering> to find further
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
43 ;; explanations of this capability.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
44
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
45 ;; 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
46 ;; unidentified users:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
47 ;; "We recommend that you add an asterisk before the nick, and
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
48 ;; optionally either highlight or colourize the line in some
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
49 ;; appropriate fashion, if the user is not identified."
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 ;;; Usage:
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 ;; Put the following in your ~/.emacs file.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
54
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
55 ;; (require 'erc-capab)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
56 ;; (erc-capab-identify-mode 1)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
57
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
58 ;; `erc-capab-identify-prefix' will now be added to the beginning of
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
59 ;; unidentified users' nicknames. The default is an asterisk, "*". If
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
60 ;; the value of this variable is nil or you disable this module (see
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 "*"
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
76 "The prefix used for unidentified users."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
77 :group 'erc-capab
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
78 :type '(choice string (const nil)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
79
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
80 ;;; Define module:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
81
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
82 (define-erc-response-handler (290)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
83 "Handle dancer-ircd CAPAB messages." nil nil)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
84
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
85 ;;;###autoload (autoload 'erc-capab-identify-mode "erc-capab" nil t)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
86 (define-erc-module capab-identify nil
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
87 "Handle dancer-ircd's CAPAB IDENTIFY-MSG and IDENTIFY-CTCP."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
88 ;; 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
89 ((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
90 (add-hook 'erc-server-290-functions 'erc-capab-identify-activate)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
91 (add-hook 'erc-server-PRIVMSG-functions
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
92 'erc-capab-identify-remove/set-identified-flag)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
93 (add-hook 'erc-server-NOTICE-functions
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
94 'erc-capab-identify-remove/set-identified-flag)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
95 (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
96 (mapc (lambda (buffer)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
97 (when buffer
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
98 (with-current-buffer buffer (erc-capab-identify-setup))))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
99 (erc-buffer-list 'erc-open-server-buffer-p)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
100 ((remove-hook 'erc-server-005-functions 'erc-capab-identify-setup)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
101 (remove-hook 'erc-server-290-functions 'erc-capab-identify-activate)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
102 ;; 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
103 ;; 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
104 (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
105
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
106 ;;; Variables:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
107
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
108 (defvar erc-capab-identify-activated nil
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
109 "CAPAB IDENTIFY-MSG has been activated.")
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
110 (make-variable-buffer-local 'erc-capab-identify-activated)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
111
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
112 (defvar erc-capab-identify-sent nil
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
113 "CAPAB IDENTIFY-MSG and IDENTIFY-CTCP messages have been sent.")
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
114 (make-variable-buffer-local 'erc-capab-identify-sent)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
115
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
116 ;;; Functions:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
117
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
118 (defun erc-capab-identify-setup (&optional proc parsed)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
119 "Set up CAPAB IDENTIFY on the current server.
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 Optional argument PROC is the current server's process.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
122 Optional argument PARSED is the current message, a response struct.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
123
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
124 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
125 `erc-server-005-functions'."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
126 (unless erc-capab-identify-sent
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
127 (erc-capab-send-identify-messages)))
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 (defun erc-capab-send-identify-messages ()
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
130 "Send CAPAB IDENTIFY messages if the server supports it."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
131 (when (and (stringp erc-server-version)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
132 (string-match "^\\(dancer-ircd\\|hyperion\\)" erc-server-version)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
133 ;; could possibly check for '("IRCD" . "dancer") in
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
134 ;; `erc-server-parameters' instead of looking for a specific name
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
135 ;; in `erc-server-version'
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
136 (assoc "CAPAB" erc-server-parameters))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
137 (erc-log "Sending CAPAB IDENTIFY-MSG and IDENTIFY-CTCP")
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
138 (erc-server-send "CAPAB IDENTIFY-MSG")
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
139 (erc-server-send "CAPAB IDENTIFY-CTCP")
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
140 (setq erc-capab-identify-sent t)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
141
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
142
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
143 (defun erc-capab-identify-activate (proc parsed)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
144 "Set `erc-capab-identify-activated' and display an activation message.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
145
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
146 PROC is the current server's process.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
147 PARSED is an `erc-parsed' response struct."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
148 (when (or (string= "IDENTIFY-MSG" (erc-response.contents parsed))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
149 (string= "IDENTIFY-CTCP" (erc-response.contents parsed)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
150 (setq erc-capab-identify-activated t)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
151 (erc-display-message
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
152 parsed 'notice 'active (format "%s activated"
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
153 (erc-response.contents parsed)))))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
154
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
155 (defun erc-capab-identify-remove/set-identified-flag (proc parsed)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
156 "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
157
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
158 PROC is the current server's process.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
159 PARSED is an `erc-parsed' response struct."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
160 (let ((msg (erc-response.contents parsed)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
161 (when (and erc-capab-identify-activated
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
162 (string-match "^\\([-\\+]\\)\\(.+\\)$" msg))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
163 (setf (erc-response.contents parsed)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
164 (if erc-capab-identify-mode
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
165 (erc-propertize (match-string 2 msg)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
166 'erc-identified
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
167 (if (string= (match-string 1 msg) "+")
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
168 1
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
169 0))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
170 (match-string 2 msg)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
171 nil)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
172
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
173 (defun erc-capab-identify-add-prefix ()
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
174 "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
175 (when (and erc-capab-identify-prefix
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
176 (erc-with-server-buffer erc-capab-identify-activated))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
177 (goto-char (or (erc-find-parsed-property) (point-min)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
178 (let ((nickname (erc-capab-get-unidentified-nickname
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
179 (erc-get-parsed-vector (point)))))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
180 (when (and nickname
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
181 (goto-char (point-min))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
182 ;; 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
183 (re-search-forward (regexp-quote nickname) nil t))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
184 (goto-char (match-beginning 0))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
185 (insert (erc-propertize erc-capab-identify-prefix
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
186 'face (get-char-property (- (point) 1)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
187 'face)))))))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
188
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
189 (defun erc-capab-get-unidentified-nickname (parsed)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
190 "Return the nickname of the user if unidentified.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
191 PARSED is an `erc-parsed' response struct."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
192 (when (and (erc-response-p parsed)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
193 (equal 0 (get-text-property 0 'erc-identified
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
194 (erc-response.contents parsed))))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
195 (let ((nickuserhost (erc-get-parsed-vector-nick parsed)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
196 (when nickuserhost
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
197 (nth 0 (erc-parse-user nickuserhost))))))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
198
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
199 (provide 'erc-capab)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
200
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
201 ;; arch-tag: 27b6d668-7ee5-4e47-b9f0-27d7a4362062
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
202 ;;; erc-capab.el ends here