;; Andreas Fuchs (afs@void.at)
;; Gergely Nagy (algernon@midgard.debian.net)
;; David Edmondson (dme@dme.org)
-;; Kelvin White <kelvin.white77@gmail.com>
+;; Kelvin White (kwhite@gnu.org)
;; Maintainer: emacs-devel@gnu.org
;; Keywords: IRC, chat, client, Internet
-;; Version: 5.3
+
;; This file is part of GNU Emacs.
;;; History:
;;
-;;; Code:
-
-(defconst erc-version-string "Version 5.3"
+(defconst erc-version-string (format "\C-bERC\C-b (IRC client for Emacs %s)" emacs-version)
"ERC version. This is used by function `erc-version'.")
+;;; Code:
+
(eval-when-compile (require 'cl-lib))
(require 'font-lock)
(require 'pp)
:set (lambda (sym val)
(set sym (if (functionp val) (funcall val) val))))
+(defcustom erc-rename-buffers nil
+ "When this is set to t, buffers will be renamed to network name if available"
+ :group 'erc
+ :type 'boolean)
+
(defvar erc-password nil
"Password to use when authenticating to an IRC server.
It is not strictly necessary to provide this, since ERC will
(concat "\n" (pp-to-string val))
(format " %S\n" val)))))
(apropos-internal "^erc-" 'custom-variable-p))))
- (current-buffer)) t)
+ (current-buffer))
+ t)
(t nil)))
(defalias 'erc-cmd-VAR 'erc-cmd-SET)
(defalias 'erc-cmd-VARIABLE 'erc-cmd-SET)
(signal 'wrong-number-of-arguments ""))))
(defalias 'erc-cmd-Q 'erc-cmd-QUERY)
+(defun erc-quit/part-reason-default ()
+ "Default quit/part message."
+ (format "\C-bERC\C-b (IRC client for Emacs %s)" emacs-version))
+
+
(defun erc-quit-reason-normal (&optional s)
"Normal quit message.
If S is non-nil, it will be used as the quit reason."
- (or s
- (format "\C-bERC\C-b %s (IRC client for Emacs)"; - \C-b%s\C-b"
- erc-version-string) ; erc-official-location)
- ))
+ (or s (erc-quit/part-reason-default)))
(defun erc-quit-reason-zippy (&optional s)
"Zippy quit message.
(or s
(if (fboundp 'yow)
(erc-replace-regexp-in-string "\n" "" (yow))
- (erc-quit-reason-normal))))
+ (erc-quit/part-reason-default))))
(make-obsolete 'erc-quit-reason-zippy "it will be removed." "24.4")
((functionp res) (funcall res))
((stringp res) res)
(s s)
- (t (erc-quit-reason-normal)))))
+ (t (erc-quit/part-reason-default)))))
(defun erc-part-reason-normal (&optional s)
"Normal part message.
-If S is non-nil, it will be used as the quit reason."
- (or s
- (format "\C-bERC\C-b %s (IRC client for Emacs)"; - \C-b%s\C-b"
- erc-version-string) ; erc-official-location)
- ))
+If S is non-nil, it will be used as the part reason."
+ (or s (erc-quit/part-reason-default)))
(defun erc-part-reason-zippy (&optional s)
"Zippy part message.
(or s
(if (fboundp 'yow)
(erc-replace-regexp-in-string "\n" "" (yow))
- (erc-part-reason-normal))))
+ (erc-quit/part-reason-default))))
(make-obsolete 'erc-part-reason-zippy "it will be removed." "24.4")
((functionp res) (funcall res))
((stringp res) res)
(s s)
- (t (erc-part-reason-normal)))))
+ (t (erc-quit/part-reason-default)))))
(defun erc-cmd-QUIT (reason)
"Disconnect from the current server.
(defun erc-cmd-SV ()
"Say the current ERC and Emacs version into channel."
- (erc-send-message (format "I'm using ERC %s with %s %s (%s%s) of %s."
- erc-version-string
+ (erc-send-message (format "I'm using ERC with %s %s (%s%s) of %s."
(if (featurep 'xemacs) "XEmacs" "GNU Emacs")
emacs-version
system-configuration
(insert (read-from-minibuffer "Message: "
(string (if (featurep 'xemacs)
last-command-char
- last-command-event)) read-map))
+ last-command-event))
+ read-map))
(erc-send-current-line)))
(defvar erc-action-history-list ()
host (regexp-quote host))
(or (when (string-match (concat "^\\(Read error\\) to "
nick "\\[" host "\\]: "
- "\\(.+\\)$") reason)
+ "\\(.+\\)$")
+ reason)
(concat (match-string 1 reason) ": " (match-string 2 reason)))
(when (string-match (concat "^\\(Ping timeout\\) for "
- nick "\\[" host "\\]$") reason)
+ nick "\\[" host "\\]$")
+ reason)
(match-string 1 reason))
reason))
(defun erc-format-nick (&optional user _channel-data)
"Return the nickname of USER.
See also `erc-format-nick-function'."
- (let ((nick (erc-server-user-nickname user)))
- (concat (erc-propertize
- (erc-get-user-mode-prefix nick)
- 'face 'erc-nick-prefix-face) nick)))
+ (when user (erc-server-user-nickname user)))
(defun erc-get-user-mode-prefix (user)
(when user
(t ""))))
(defun erc-format-@nick (&optional user channel-data)
- "Format the nickname of USER showing if USER is an operator or has voice.
-Operators have \"@\" and users with voice have \"+\" as a prefix.
-Use CHANNEL-DATA to determine op and voice status.
-See also `erc-format-nick-function'."
+ "Format the nickname of USER showing if USER has a voice, is an
+operator, half-op, admin or owner. Owners have \"~\", admins have
+\"&\", operators have \"@\" and users with voice have \"+\" as a
+prefix. Use CHANNEL-DATA to determine op and voice status. See
+also `erc-format-nick-function'."
(when user
(let ((nick (erc-server-user-nickname user)))
(concat (erc-propertize
(erc-get-user-mode-prefix nick)
- 'face 'erc-nick-prefix-face) nick nick))))
+ 'face 'erc-nick-prefix-face)
+ nick))))
(defun erc-format-my-nick ()
"Return the beginning of this user's message, correctly propertized."
(unless erc-disable-ctcp-replies
(erc-send-ctcp-notice
nick (format
- "VERSION \C-bERC\C-b %s - an IRC client for emacs (\C-b%s\C-b)"
- erc-version-string
+ "VERSION \C-bERC\C-b - an IRC client for Emacs %s (\C-b%s\C-b)"
+ emacs-version
erc-official-location)))
nil)
(let ((updatep t))
(setq name item op 'off voice 'off halfop 'off admin 'off owner 'off)
(if (rassq (elt item 0) prefix)
- (cond ((= (length item) 1)
- (setq updatep nil))
- ((eq (elt item 0) voice-ch)
- (setq name (substring item 1)
- voice 'on))
- ((eq (elt item 0) hop-ch)
- (setq name (substring item 1)
- halfop 'on))
- ((eq (elt item 0) op-ch)
- (setq name (substring item 1)
- op 'on))
- ((eq (elt item 0) adm-ch)
- (setq name (substring item 1)
- admin 'on))
- ((eq (elt item 0) own-ch)
- (setq name (substring item 1)
- owner 'on))
- (t (setq name (substring item 1)))))
+ (if (= (length item) 1)
+ (setq updatep nil)
+ (setq name (substring item 1))
+ (setf (pcase (aref item 0)
+ ((pred (eq voice-ch)) voice)
+ ((pred (eq hop-ch)) halfop)
+ ((pred (eq op-ch)) op)
+ ((pred (eq adm-ch)) admin)
+ ((pred (eq own-ch)) owner))
+ 'on)))
(when updatep
(puthash (erc-downcase name) t
erc-channel-new-member-names)
(or (and erc-flood-protect (erc-split-line line))
(list line))))
(split-string str "\n"))
- ;; Insert the prompt along with the command.
- (erc-display-command str)
(erc-process-input-line (concat str "\n") t nil))
t)))))
nick login host
(if full-name (format " (%s)" full-name) "")
(if (or voice halfop op admin owner)
- (format " and is +%s%s on %s"
+ (format " and is +%s%s%s%s%s on %s"
(if voice "v" "")
(if halfop "h" "")
(if op "o" "")
(cond ((erc-default-target)
(concat (erc-string-no-properties (erc-default-target))
"@" network-name))
- (network-name network-name)
+ ((and network-name
+ (not (get-buffer network-name)))
+ (when erc-rename-buffers
+ (rename-buffer network-name))
+ network-name)
(t (buffer-name (current-buffer))))))
(defun erc-format-away-status ()
If optional argument HERE is non-nil, insert version number at point."
(interactive "P")
(let ((version-string
- (format "ERC %s (GNU Emacs %s)" erc-version-string emacs-version)))
+ (format "ERC (IRC client for Emacs %s)" emacs-version)))
(if here
(insert version-string)
(if (called-interactively-p 'interactive)