comparison lisp/erc/erc-capab.el @ 76856:2fae574a2382

Release ERC 5.2. I have updated the version of ERC to 5.2, since it fixes a bug with C-c C-SPC being bound globally by default. For the full list of changes in this version, see etc/ERC-NEWS. Revision: emacs@sv.gnu.org/emacs--devo--0--patch-687 Creator: Michael Olson <mwolson@gnu.org>
author Miles Bader <miles@gnu.org>
date Sun, 01 Apr 2007 13:36:38 +0000
parents 7a3f13e2dd57
children 85d67fae9a94
comparison
equal deleted inserted replaced
76855:e6686c0a3d45 76856:2fae574a2382
54 54
55 ;; (require 'erc-capab) 55 ;; (require 'erc-capab)
56 ;; (erc-capab-identify-mode 1) 56 ;; (erc-capab-identify-mode 1)
57 57
58 ;; `erc-capab-identify-prefix' will now be added to the beginning of 58 ;; `erc-capab-identify-prefix' will now be added to the beginning of
59 ;; unidentified users' nicknames. The default is an asterisk, "*". If 59 ;; unidentified users' nicknames. The default is an asterisk, "*".
60 ;; the value of this variable is nil or you disable this module (see 60 ;; You can customize the prefix and the face used to display it,
61 ;; `erc-capab-identify-unidentified'. If the value of
62 ;; `erc-capab-identify-prefix' is nil or you disable this module (see
61 ;; `erc-capab-identify-disable'), no prefix will be inserted, but the 63 ;; `erc-capab-identify-disable'), no prefix will be inserted, but the
62 ;; flag sent by the server will still be stripped. 64 ;; flag sent by the server will still be stripped.
63 65
64 ;;; Code: 66 ;;; Code:
65 67
71 (defgroup erc-capab nil 73 (defgroup erc-capab nil
72 "Support for dancer-ircd's CAPAB settings." 74 "Support for dancer-ircd's CAPAB settings."
73 :group 'erc) 75 :group 'erc)
74 76
75 (defcustom erc-capab-identify-prefix "*" 77 (defcustom erc-capab-identify-prefix "*"
76 "The prefix used for unidentified users." 78 "The prefix used for unidentified users.
79
80 If you change this from the default \"*\", be sure to use a
81 character not found in IRC nicknames to avoid confusion."
77 :group 'erc-capab 82 :group 'erc-capab
78 :type '(choice string (const nil))) 83 :type '(choice string (const nil)))
79 84
85 (defface erc-capab-identify-unidentified '((t)) ; same as `erc-default-face'
86 "Face to use for `erc-capab-identify-prefix'."
87 :group 'erc-capab
88 :group 'erc-faces)
89
80 ;;; Define module: 90 ;;; Define module:
81
82 (define-erc-response-handler (290)
83 "Handle dancer-ircd CAPAB messages." nil nil)
84 91
85 ;;;###autoload (autoload 'erc-capab-identify-mode "erc-capab" nil t) 92 ;;;###autoload (autoload 'erc-capab-identify-mode "erc-capab" nil t)
86 (define-erc-module capab-identify nil 93 (define-erc-module capab-identify nil
87 "Handle dancer-ircd's CAPAB IDENTIFY-MSG and IDENTIFY-CTCP." 94 "Handle dancer-ircd's CAPAB IDENTIFY-MSG and IDENTIFY-CTCP."
88 ;; append so that `erc-server-parameters' is already set by `erc-server-005' 95 ;; append so that `erc-server-parameters' is already set by `erc-server-005'
122 Optional argument PARSED is the current message, a response struct. 129 Optional argument PARSED is the current message, a response struct.
123 130
124 These arguments are sent to this function when called as a hook in 131 These arguments are sent to this function when called as a hook in
125 `erc-server-005-functions'." 132 `erc-server-005-functions'."
126 (unless erc-capab-identify-sent 133 (unless erc-capab-identify-sent
127 (erc-capab-send-identify-messages))) 134 (erc-capab-identify-send-messages)))
128 135
129 (defun erc-capab-send-identify-messages () 136 (defun erc-capab-identify-send-messages ()
130 "Send CAPAB IDENTIFY messages if the server supports it." 137 "Send CAPAB IDENTIFY messages if the server supports it."
131 (when (and (stringp erc-server-version) 138 (when (and (stringp erc-server-version)
132 (string-match "^\\(dancer-ircd\\|hyperion\\)" erc-server-version) 139 (string-match "^\\(dancer-ircd\\|hyperion\\)" erc-server-version)
133 ;; could possibly check for '("IRCD" . "dancer") in 140 ;; could possibly check for '("IRCD" . "dancer") in
134 ;; `erc-server-parameters' instead of looking for a specific name 141 ;; `erc-server-parameters' instead of looking for a specific name
173 (defun erc-capab-identify-add-prefix () 180 (defun erc-capab-identify-add-prefix ()
174 "Add `erc-capab-identify-prefix' to nickname if user is unidentified." 181 "Add `erc-capab-identify-prefix' to nickname if user is unidentified."
175 (when (and erc-capab-identify-prefix 182 (when (and erc-capab-identify-prefix
176 (erc-with-server-buffer erc-capab-identify-activated)) 183 (erc-with-server-buffer erc-capab-identify-activated))
177 (goto-char (or (erc-find-parsed-property) (point-min))) 184 (goto-char (or (erc-find-parsed-property) (point-min)))
178 (let ((nickname (erc-capab-get-unidentified-nickname 185 (let ((nickname (erc-capab-identify-get-unidentified-nickname
179 (erc-get-parsed-vector (point))))) 186 (erc-get-parsed-vector (point)))))
180 (when (and nickname 187 (when (and nickname
181 (goto-char (point-min)) 188 (goto-char (point-min))
182 ;; assuming the first use of `nickname' is the sender's nick 189 ;; assuming the first use of `nickname' is the sender's nick
183 (re-search-forward (regexp-quote nickname) nil t)) 190 (re-search-forward (regexp-quote nickname) nil t))
184 (goto-char (match-beginning 0)) 191 (goto-char (match-beginning 0))
185 (insert (erc-propertize erc-capab-identify-prefix 192 (insert (erc-propertize erc-capab-identify-prefix
186 'face (get-char-property (- (point) 1) 193 'face 'erc-capab-identify-unidentified))))))
187 'face))))))) 194
188 195 (defun erc-capab-identify-get-unidentified-nickname (parsed)
189 (defun erc-capab-get-unidentified-nickname (parsed)
190 "Return the nickname of the user if unidentified. 196 "Return the nickname of the user if unidentified.
191 PARSED is an `erc-parsed' response struct." 197 PARSED is an `erc-parsed' response struct."
192 (when (and (erc-response-p parsed) 198 (when (and (erc-response-p parsed)
193 (equal 0 (get-text-property 0 'erc-identified 199 (equal 0 (get-text-property 0 'erc-identified
194 (erc-response.contents parsed)))) 200 (erc-response.contents parsed))))