diff options
Diffstat (limited to 'lisp/erc/erc.el')
-rw-r--r-- | lisp/erc/erc.el | 350 |
1 files changed, 198 insertions, 152 deletions
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index dd7f50fb381..73202016ba7 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -1,4 +1,4 @@ -;; erc.el --- An Emacs Internet Relay Chat client -*- lexical-binding:t -*- +;;; erc.el --- An Emacs Internet Relay Chat client -*- lexical-binding:t -*- ;; Copyright (C) 1997-2021 Free Software Foundation, Inc. @@ -9,6 +9,7 @@ ;; Andreas Fuchs (afs@void.at) ;; Gergely Nagy (algernon@midgard.debian.net) ;; David Edmondson (dme@dme.org) +;; Michael Olson (mwolson@gnu.org) ;; Kelvin White (kwhite@gnu.org) ;; Maintainer: Amin Bandali <bandali@gnu.org> ;; Keywords: IRC, chat, client, Internet @@ -47,11 +48,12 @@ ;; ;; 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: +;; or +;; +;; M-x erc-tls RET ;; +;; to connect over TLS (encrypted). Once you are connected to a +;; server, you can use C-h m or have a look at the ERC menu. ;;; Code: @@ -114,17 +116,6 @@ "Running scripts at startup and with /LOAD" :group 'erc) -;; compatibility with older ERC releases - -(define-obsolete-variable-alias 'erc-announced-server-name - 'erc-server-announced-name "ERC 5.1") -(define-obsolete-variable-alias 'erc-process 'erc-server-process "ERC 5.1") -(define-obsolete-variable-alias 'erc-default-coding-system - 'erc-server-coding-system "ERC 5.1") - -(define-obsolete-function-alias 'erc-send-command - 'erc-server-send "ERC 5.1") - (require 'erc-backend) ;; tunable connection and authentication parameters @@ -256,7 +247,7 @@ A typical value would be \(\"JOIN\" \"PART\" \"QUIT\")." (defcustom erc-network-hide-list nil "A list of IRC networks to hide message types from. -A typical value would be \((\"freenode\" \"MODE\") +A typical value would be \((\"Libera.Chat\" \"MODE\") \(\"OFTC\" \"JOIN\" \"QUIT\"))." :version "25.1" :group 'erc-ignore @@ -1144,31 +1135,31 @@ which the local user typed." (defvar erc-mode-map (let ((map (make-sparse-keymap))) - (define-key map "\C-m" 'erc-send-current-line) - (define-key map "\C-a" 'erc-bol) - (define-key map [home] 'erc-bol) - (define-key map "\C-c\C-a" 'erc-bol) - (define-key map "\C-c\C-b" 'erc-switch-to-buffer) - (define-key map "\C-c\C-c" 'erc-toggle-interpret-controls) - (define-key map "\C-c\C-d" 'erc-input-action) - (define-key map "\C-c\C-e" 'erc-toggle-ctcp-autoresponse) - (define-key map "\C-c\C-f" 'erc-toggle-flood-control) - (define-key map "\C-c\C-i" 'erc-invite-only-mode) - (define-key map "\C-c\C-j" 'erc-join-channel) - (define-key map "\C-c\C-n" 'erc-channel-names) - (define-key map "\C-c\C-o" 'erc-get-channel-mode-from-keypress) - (define-key map "\C-c\C-p" 'erc-part-from-channel) - (define-key map "\C-c\C-q" 'erc-quit-server) - (define-key map "\C-c\C-r" 'erc-remove-text-properties-region) - (define-key map "\C-c\C-t" 'erc-set-topic) - (define-key map "\C-c\C-u" 'erc-kill-input) - (define-key map "\C-c\C-x" 'erc-quit-server) - (define-key map "\M-\t" 'ispell-complete-word) - (define-key map "\t" 'completion-at-point) + (define-key map "\C-m" #'erc-send-current-line) + (define-key map "\C-a" #'erc-bol) + (define-key map [home] #'erc-bol) + (define-key map "\C-c\C-a" #'erc-bol) + (define-key map "\C-c\C-b" #'erc-switch-to-buffer) + (define-key map "\C-c\C-c" #'erc-toggle-interpret-controls) + (define-key map "\C-c\C-d" #'erc-input-action) + (define-key map "\C-c\C-e" #'erc-toggle-ctcp-autoresponse) + (define-key map "\C-c\C-f" #'erc-toggle-flood-control) + (define-key map "\C-c\C-i" #'erc-invite-only-mode) + (define-key map "\C-c\C-j" #'erc-join-channel) + (define-key map "\C-c\C-n" #'erc-channel-names) + (define-key map "\C-c\C-o" #'erc-get-channel-mode-from-keypress) + (define-key map "\C-c\C-p" #'erc-part-from-channel) + (define-key map "\C-c\C-q" #'erc-quit-server) + (define-key map "\C-c\C-r" #'erc-remove-text-properties-region) + (define-key map "\C-c\C-t" #'erc-set-topic) + (define-key map "\C-c\C-u" #'erc-kill-input) + (define-key map "\C-c\C-x" #'erc-quit-server) + (define-key map "\M-\t" #'ispell-complete-word) + (define-key map "\t" #'completion-at-point) ;; Suppress `font-lock-fontify-block' key binding since it ;; destroys face properties. - (define-key map [remap font-lock-fontify-block] 'undefined) + (define-key map [remap font-lock-fontify-block] #'undefined) map) "ERC keymap.") @@ -1303,7 +1294,9 @@ With a prefix argument ARG, enable %s if ARG is positive, and disable it otherwise. If called from Lisp, enable the mode if ARG is omitted or nil. %s" name name doc) - nil nil nil + ;; FIXME: We don't know if this group exists, so this `:group' may + ;; actually just silence a valid warning about the fact that the var + ;; is not associated with any group. :global ,(not local-p) :group (quote ,group) (if ,mode (,enable) @@ -1324,12 +1317,10 @@ if ARG is omitted or nil. ,@disable-body) ,(when (and alias (not (eq name alias))) `(defalias - (quote - ,(intern + ',(intern (format "erc-%s-mode" - (downcase (symbol-name alias))))) - (quote - ,mode))) + (downcase (symbol-name alias)))) + #',mode)) ;; For find-function and find-variable. (put ',mode 'definition-name ',name) (put ',enable 'definition-name ',name) @@ -1489,7 +1480,7 @@ Defaults to the server buffer." ;; activation -(defconst erc-default-server "chat.freenode.net" +(defconst erc-default-server "irc.libera.chat" "IRC server to use if it cannot be detected otherwise.") (defconst erc-default-port 6667 @@ -1756,7 +1747,7 @@ nil." (ignore res) res))) -(define-obsolete-function-alias 'erc-iswitchb 'erc-switch-to-buffer "25.1") +(define-obsolete-function-alias 'erc-iswitchb #'erc-switch-to-buffer "25.1") (defun erc--switch-to-buffer (&optional arg) (read-buffer "Switch to ERC buffer: " (when (boundp 'erc-modified-channels-alist) @@ -1865,7 +1856,7 @@ removed from the list will be disabled." :get (lambda (sym) ;; replace outdated names with their newer equivalents (erc-migrate-modules (symbol-value sym))) - :initialize 'custom-initialize-default + :initialize #'custom-initialize-default :set (lambda (sym val) ;; disable modules which have just been removed (when (and (boundp 'erc-modules) erc-modules val) @@ -1981,7 +1972,8 @@ removed from the list will be disabled." (switch-to-buffer buffer))))) (defun erc-open (&optional server port nick full-name - connect passwd tgt-list channel process) + connect passwd tgt-list channel process + client-certificate) "Connect to SERVER on PORT as NICK with FULL-NAME. If CONNECT is non-nil, connect to the server. Otherwise assume @@ -1991,6 +1983,13 @@ target CHANNEL. Use PASSWD as user password on the server. If TGT-LIST is non-nil, use it to initialize `erc-default-recipients'. +CLIENT-CERTIFICATE, if non-nil, should either be a list where the +first element is the file name of the private key corresponding +to a client certificate and the second element is the file name +of the client certificate itself to use when connecting over TLS, +or t, which means that `auth-source' will be queried for the +private key and the certificate. + Returns the buffer for the given server or channel." (let ((server-announced-name (when (and (boundp 'erc-session-server) (string= server erc-session-server)) @@ -2073,6 +2072,8 @@ Returns the buffer for the given server or channel." (if (functionp secret) (funcall secret) secret)))) + ;; client certificate (only useful if connecting over TLS) + (setq erc-session-client-certificate client-certificate) ;; debug output buffer (setq erc-dbuf (when erc-log-p @@ -2093,7 +2094,10 @@ Returns the buffer for the given server or channel." (run-hook-with-args 'erc-connect-pre-hook buffer) (when connect - (erc-server-connect erc-session-server erc-session-port buffer)) + (erc-server-connect erc-session-server + erc-session-port + buffer + erc-session-client-certificate)) (erc-update-mode-line) ;; Now display the buffer in a window as per user wishes. @@ -2136,33 +2140,34 @@ If no buffer matches, return nil." (erc-current-nick-p nick))))) (defcustom erc-before-connect nil - "Hook called before connecting to a server. -This hook gets executed before `erc' actually invokes `erc-mode' -with your input data. The functions in here get called with three -parameters, SERVER, PORT and NICK." + "Functions called before connecting to a server. +The functions in this variable gets executed before `erc' +actually invokes `erc-mode' with your input data. The functions +in here get called with three parameters, SERVER, PORT and NICK." :group 'erc-hooks - :type 'hook) + :type '(repeat function)) (defcustom erc-after-connect nil - "Hook called after connecting to a server. -This hook gets executed when an end of MOTD has been received. All -functions in here get called with the parameters SERVER and NICK." + "Functions called after connecting to a server. +This functions in this variable gets executed when an end of MOTD +has been received. All functions in here get called with the +parameters SERVER and NICK." :group 'erc-hooks - :type 'hook) + :type '(repeat function)) ;;;###autoload (defun erc-select-read-args () "Prompt the user for values of nick, server, port, and password." (let (user-input server port nick passwd) - (setq user-input (read-from-minibuffer + (setq user-input (read-string "IRC server: " - (erc-compute-server) nil nil 'erc-server-history-list)) + (erc-compute-server) 'erc-server-history-list)) (if (string-match "\\(.*\\):\\(.*\\)\\'" user-input) (setq port (erc-string-to-port (match-string 2 user-input)) user-input (match-string 1 user-input)) (setq port - (erc-string-to-port (read-from-minibuffer + (erc-string-to-port (read-string "IRC port: " (erc-port-to-string (erc-compute-port)))))) @@ -2171,13 +2176,12 @@ functions in here get called with the parameters SERVER and NICK." user-input (match-string 2 user-input)) (setq nick (if (erc-already-logged-in server port nick) - (read-from-minibuffer + (read-string (erc-format-message 'nick-in-use ?n nick) - nick - nil nil 'erc-nick-history-list) - (read-from-minibuffer + nick 'erc-nick-history-list) + (read-string "Nickname: " (erc-compute-nick nick) - nil nil 'erc-nick-history-list)))) + 'erc-nick-history-list)))) (setq server user-input) @@ -2196,10 +2200,9 @@ functions in here get called with the parameters SERVER and NICK." ;; bnc with the same nick. actually it would be nice to have ;; bncs transparent, so that erc-compute-buffer-name displays ;; the server one is connected to. - (setq nick (read-from-minibuffer + (setq nick (read-string (erc-format-message 'nick-in-use ?n nick) - nick - nil nil 'erc-nick-history-list))) + nick 'erc-nick-history-list))) (list :server server :port port :nick nick :password passwd))) ;;;###autoload @@ -2211,45 +2214,90 @@ functions in here get called with the parameters SERVER and NICK." "ERC is a powerful, modular, and extensible IRC client. This function is the main entry point for ERC. -It permits you to select connection parameters, and then starts ERC. +It allows selecting connection parameters, and then starts ERC. Non-interactively, it takes the keyword arguments (server (erc-compute-server)) (port (erc-compute-port)) (nick (erc-compute-nick)) password - (full-name (erc-compute-full-name))) + (full-name (erc-compute-full-name)) That is, if called with - (erc :server \"chat.freenode.net\" :full-name \"Harry S Truman\") + (erc :server \"irc.libera.chat\" :full-name \"J. Random Hacker\") -then the server and full-name will be set to those values, whereas -`erc-compute-port', `erc-compute-nick' and `erc-compute-full-name' will -be invoked for the values of the other parameters." +then the server and full-name will be set to those values, +whereas `erc-compute-port' and `erc-compute-nick' will be invoked +for the values of the other parameters." (interactive (erc-select-read-args)) (erc-open server port nick full-name t password)) ;;;###autoload -(defalias 'erc-select 'erc) -(defalias 'erc-ssl 'erc-tls) +(defalias 'erc-select #'erc) +(defalias 'erc-ssl #'erc-tls) ;;;###autoload -(defun erc-tls (&rest r) - "Interactively select TLS connection parameters and run ERC. -Arguments are the same as for `erc'." +(cl-defun erc-tls (&key (server (erc-compute-server)) + (port (erc-compute-port)) + (nick (erc-compute-nick)) + password + (full-name (erc-compute-full-name)) + client-certificate) + "ERC is a powerful, modular, and extensible IRC client. +This function is the main entry point for ERC over TLS. + +It allows selecting connection parameters, and then starts ERC +over TLS. + +Non-interactively, it takes the keyword arguments + (server (erc-compute-server)) + (port (erc-compute-port)) + (nick (erc-compute-nick)) + password + (full-name (erc-compute-full-name)) + client-certificate + +That is, if called with + + (erc-tls :server \"irc.libera.chat\" :full-name \"J. Random Hacker\") + +then the server and full-name will be set to those values, +whereas `erc-compute-port' and `erc-compute-nick' will be invoked +for the values of their respective parameters. + +CLIENT-CERTIFICATE, if non-nil, should either be a list where the +first element is the certificate key file name, and the second +element is the certificate file name itself, or t, which means +that `auth-source' will be queried for the key and the +certificate. Authenticating using a TLS client certificate is +also refered to as \"CertFP\" (Certificate Fingerprint) +authentication by various IRC networks. + +Example usage: + + (erc-tls :server \"irc.libera.chat\" :port 6697 + :client-certificate + '(\"/home/bandali/my-cert.key\" + \"/home/bandali/my-cert.crt\"))" (interactive (let ((erc-default-port erc-default-port-tls)) (erc-select-read-args))) (let ((erc-server-connect-function 'erc-open-tls-stream)) - (apply #'erc r))) + (erc-open server port nick full-name t password + nil nil nil client-certificate))) -(defun erc-open-tls-stream (name buffer host port) +(defun erc-open-tls-stream (name buffer host port &rest parameters) "Open an TLS stream to an IRC server. -The process will be given the name NAME, its target buffer will be -BUFFER. HOST and PORT specify the connection target." - (open-network-stream name buffer host port - :nowait t - :type 'tls)) +The process will be given the name NAME, its target buffer will +be BUFFER. HOST and PORT specify the connection target. +PARAMETERS should be a sequence of keywords and values, per +`open-network-stream'." + (let ((p (plist-put parameters :type 'tls)) + args) + (unless (plist-member p :nowait) + (setq p (plist-put p :nowait t))) + (setq args `(,name ,buffer ,host ,port ,@p)) + (apply #'open-network-stream args))) ;;; Displaying error messages @@ -2335,7 +2383,7 @@ If ARG is non-nil, show the *erc-protocol* buffer." (use-local-map (make-sparse-keymap)) (local-set-key (kbd "t") 'erc-toggle-debug-irc-protocol)) (add-hook 'kill-buffer-hook - #'(lambda () (setq erc-debug-irc-protocol nil)) + (lambda () (setq erc-debug-irc-protocol nil)) nil 'local) (goto-char (point-max)) (let ((inhibit-read-only t)) @@ -2853,14 +2901,14 @@ VALUE is computed by evaluating the rest of LINE in Lisp." (val (read (match-string 2 line)))) (if (boundp var) (progn - (set var (eval val)) + (set var (eval val t)) (erc-display-message nil nil 'active (format "Set %S to %S" var val)) t) (setq var (read (match-string 1 line))) (if (boundp var) (progn - (set var (eval val)) + (set var (eval val t)) (erc-display-message nil nil 'active (format "Set %S to %S" var val)) t) @@ -2882,8 +2930,8 @@ VALUE is computed by evaluating the rest of LINE in Lisp." (current-buffer)) t) (t nil))) -(defalias 'erc-cmd-VAR 'erc-cmd-SET) -(defalias 'erc-cmd-VARIABLE 'erc-cmd-SET) +(defalias 'erc-cmd-VAR #'erc-cmd-SET) +(defalias 'erc-cmd-VARIABLE #'erc-cmd-SET) (put 'erc-cmd-SET 'do-not-parse-args t) (put 'erc-cmd-SET 'process-not-needed t) @@ -2959,9 +3007,9 @@ If no USER argument is specified, list the contents of `erc-ignore-list'." (if (null (erc-with-server-buffer erc-ignore-list)) (erc-display-line (erc-make-notice "Ignore list is empty") 'active) (erc-display-line (erc-make-notice "Ignore list:") 'active) - (mapc #'(lambda (item) - (erc-display-line (erc-make-notice item) - 'active)) + (mapc (lambda (item) + (erc-display-line (erc-make-notice item) + 'active)) (erc-with-server-buffer erc-ignore-list)))) t) @@ -3011,7 +3059,7 @@ If no USER argument is specified, list the contents of `erc-ignore-list'." (car user-data)) ops))))) erc-channel-users)) - (setq ops (sort ops 'string-lessp)) + (setq ops (sort ops #'string-lessp)) (if ops (erc-display-message nil 'notice (current-buffer) 'ops @@ -3110,7 +3158,7 @@ For a list of user commands (/join /part, ...): (message "Type C-h m to get additional information about keybindings.") t)) -(defalias 'erc-cmd-H 'erc-cmd-HELP) +(defalias 'erc-cmd-H #'erc-cmd-HELP) (put 'erc-cmd-HELP 'process-not-needed t) (defun erc-server-join-channel (server channel &optional secret) @@ -3143,8 +3191,8 @@ were most recently invited. See also `invitation'." (when chnl ;; Prevent double joining of same channel on same server. (let* ((joined-channels - (mapcar #'(lambda (chanbuf) - (with-current-buffer chanbuf (erc-default-target))) + (mapcar (lambda (chanbuf) + (with-current-buffer chanbuf (erc-default-target))) (erc-channel-list erc-server-process))) (server (with-current-buffer (process-buffer erc-server-process) (or erc-session-server erc-server-announced-name))) @@ -3156,8 +3204,8 @@ were most recently invited. See also `invitation'." (erc-server-join-channel server chnl key))))) t) -(defalias 'erc-cmd-CHANNEL 'erc-cmd-JOIN) -(defalias 'erc-cmd-J 'erc-cmd-JOIN) +(defalias 'erc-cmd-CHANNEL #'erc-cmd-JOIN) +(defalias 'erc-cmd-J #'erc-cmd-JOIN) (defvar-local erc-channel-new-member-names nil "If non-nil, a names list is currently being received. @@ -3181,7 +3229,7 @@ command." (erc-server-send (concat "NAMES " tgt))) (erc-display-message nil 'error (current-buffer) 'no-default-channel))) t) -(defalias 'erc-cmd-N 'erc-cmd-NAMES) +(defalias 'erc-cmd-N #'erc-cmd-NAMES) (defun erc-cmd-KICK (target &optional reason-or-nick &rest reasonwords) "Kick the user indicated in LINE from the current channel. @@ -3251,7 +3299,7 @@ If SERVER is non-nil, use that, rather than the current server." (erc-log (format "cmd: %s" send)) (erc-server-send send) t)) -(defalias 'erc-cmd-WI 'erc-cmd-WHOIS) +(defalias 'erc-cmd-WI #'erc-cmd-WHOIS) (defun erc-cmd-WHOAMI () "Display whois information about yourself." @@ -3399,8 +3447,9 @@ to send. If only one word is given, display the mode of that target. -A list of valid mode strings for Freenode may be found at -URL `http://freenode.net/using_the_network.shtml'." +A list of valid mode strings for Libera.Chat may be found at +`https://libera.chat/guides/channelmodes' and +`https://libera.chat/guides/usermodes'." (cond ((string-match "^\\s-\\(.*\\)$" line) (let ((s (match-string 1 line))) @@ -3422,7 +3471,7 @@ The rest is the message to send." The rest of LINE is the message to send." (erc-message "PRIVMSG" line)) -(defalias 'erc-cmd-M 'erc-cmd-MSG) +(defalias 'erc-cmd-M #'erc-cmd-MSG) (put 'erc-cmd-MSG 'do-not-parse-args t) (defun erc-cmd-SQUERY (line) @@ -3477,7 +3526,7 @@ Otherwise leave the channel indicated by LINE." (t nil))) (put 'erc-cmd-PART 'do-not-parse-args t) -(defalias 'erc-cmd-LEAVE 'erc-cmd-PART) +(defalias 'erc-cmd-LEAVE #'erc-cmd-PART) (defun erc-cmd-PING (recipient) "Ping RECIPIENT." @@ -3521,7 +3570,7 @@ The type of query window/frame/etc will depend on the value of If USER is omitted, close the current query buffer if one exists - except this is broken now ;-)" (interactive - (list (read-from-minibuffer "Start a query with: " nil))) + (list (read-string "Start a query with: "))) (let ((session-buffer (erc-server-buffer)) (erc-join-buffer erc-query-display)) (if user @@ -3529,7 +3578,7 @@ If USER is omitted, close the current query buffer if one exists ;; currently broken, evil hack to display help anyway ;(erc-delete-query)))) (signal 'wrong-number-of-arguments "")))) -(defalias 'erc-cmd-Q 'erc-cmd-QUERY) +(defalias 'erc-cmd-Q #'erc-cmd-QUERY) (defun erc-quit/part-reason-default () "Default quit/part message." @@ -3548,7 +3597,7 @@ If S is non-nil, it will be used as the quit reason." If S is non-nil, it will be used as the quit reason." (or s (if (fboundp 'yow) - (replace-regexp-in-string "\n" "" (yow)) + (string-replace "\n" "" (yow)) (erc-quit/part-reason-default)))) (make-obsolete 'erc-quit-reason-zippy "it will be removed." "24.4") @@ -3575,7 +3624,7 @@ If S is non-nil, it will be used as the part reason." If S is non-nil, it will be used as the quit reason." (or s (if (fboundp 'yow) - (replace-regexp-in-string "\n" "" (yow)) + (string-replace "\n" "" (yow)) (erc-quit/part-reason-default)))) (make-obsolete 'erc-part-reason-zippy "it will be removed." "24.4") @@ -3624,9 +3673,9 @@ the message given by REASON." t) (t nil))) -(defalias 'erc-cmd-BYE 'erc-cmd-QUIT) -(defalias 'erc-cmd-EXIT 'erc-cmd-QUIT) -(defalias 'erc-cmd-SIGNOFF 'erc-cmd-QUIT) +(defalias 'erc-cmd-BYE #'erc-cmd-QUIT) +(defalias 'erc-cmd-EXIT #'erc-cmd-QUIT) +(defalias 'erc-cmd-SIGNOFF #'erc-cmd-QUIT) (put 'erc-cmd-QUIT 'do-not-parse-args t) (put 'erc-cmd-QUIT 'process-not-needed t) @@ -3645,7 +3694,7 @@ the message given by REASON." (kill-buffer buffer))))) t) -(defalias 'erc-cmd-GQ 'erc-cmd-GQUIT) +(defalias 'erc-cmd-GQ #'erc-cmd-GQUIT) (put 'erc-cmd-GQUIT 'do-not-parse-args t) (put 'erc-cmd-GQUIT 'process-not-needed t) @@ -3743,7 +3792,7 @@ the message given by REASON." (erc-server-send (concat "TIME " args))) t) (t (erc-server-send "TIME")))) -(defalias 'erc-cmd-DATE 'erc-cmd-TIME) +(defalias 'erc-cmd-DATE #'erc-cmd-TIME) (defun erc-cmd-TOPIC (topic) "Set or request the topic for a channel. @@ -3784,7 +3833,7 @@ be displayed." (erc-display-message nil 'error (current-buffer) 'no-target))) t) (t nil))) -(defalias 'erc-cmd-T 'erc-cmd-TOPIC) +(defalias 'erc-cmd-T #'erc-cmd-TOPIC) (put 'erc-cmd-TOPIC 'do-not-parse-args t) (defun erc-cmd-APPENDTOPIC (topic) @@ -3796,7 +3845,7 @@ be displayed." ;; strip trailing ^O (when (string-match "\\(.*\\)\C-o" oldtopic) (erc-cmd-TOPIC (concat (match-string 1 oldtopic) topic))))) -(defalias 'erc-cmd-AT 'erc-cmd-APPENDTOPIC) +(defalias 'erc-cmd-AT #'erc-cmd-APPENDTOPIC) (put 'erc-cmd-APPENDTOPIC 'do-not-parse-args t) (defun erc-cmd-CLEARTOPIC (&optional channel) @@ -3820,6 +3869,8 @@ The property `received-from-server' indicates whether or not the ban list has been requested from the server.") (put 'erc-channel-banlist 'received-from-server nil) +(defvar erc-fill-column) + (defun erc-cmd-BANLIST () "Pretty-print the contents of `erc-channel-banlist'. @@ -3890,7 +3941,7 @@ The ban list is fetched from the server if necessary." (put 'erc-channel-banlist 'received-from-server nil))))) t) -(defalias 'erc-cmd-BL 'erc-cmd-BANLIST) +(defalias 'erc-cmd-BL #'erc-cmd-BANLIST) (defun erc-cmd-MASSUNBAN () "Mass Unban. @@ -3932,7 +3983,7 @@ Unban all currently banned users in the current channel." (erc-group-list bans 3)))) t)))) -(defalias 'erc-cmd-MUB 'erc-cmd-MASSUNBAN) +(defalias 'erc-cmd-MUB #'erc-cmd-MASSUNBAN) ;;;; End of IRC commands @@ -4033,8 +4084,7 @@ If FACE is non-nil, it will be used to propertize the prompt. If it is nil, "Interactively input a user action and send it to IRC." (interactive "") (erc-set-active-buffer (current-buffer)) - (let ((action (read-from-minibuffer - "Action: " nil nil nil 'erc-action-history-list))) + (let ((action (read-string "Action: " nil 'erc-action-history-list))) (if (not (string-match "^\\s-*$" action)) (erc-send-action (erc-default-target) action)))) @@ -4051,24 +4101,25 @@ If `point' is at the beginning of a channel name, use that as default." (completing-read (format-prompt "Join channel" chnl) table nil nil nil nil chnl)) (when (or current-prefix-arg erc-prompt-for-channel-key) - (read-from-minibuffer "Channel key (RET for none): " nil)))) + (read-string "Channel key (RET for none): ")))) (erc-cmd-JOIN channel (when (>= (length key) 1) key))) (defun erc-part-from-channel (reason) "Part from the current channel and prompt for a REASON." (interactive + ;; FIXME: Has this ever worked? We're in the interactive-spec, so the + ;; argument `reason' can't be in scope yet! + ;;(if (and (boundp 'reason) (stringp reason) (not (string= reason ""))) + ;; reason (list - (if (and (boundp 'reason) (stringp reason) (not (string= reason ""))) - reason - (read-from-minibuffer (concat "Reason for leaving " (erc-default-target) - ": "))))) + (read-string (concat "Reason for leaving " (erc-default-target) ": ")))) (erc-cmd-PART (concat (erc-default-target)" " reason))) (defun erc-set-topic (topic) "Prompt for a TOPIC for the current channel." (interactive (list - (read-from-minibuffer + (read-string (concat "Set topic of " (erc-default-target) ": ") (when erc-channel-topic (let ((ss (split-string erc-channel-topic "\C-o"))) @@ -4080,7 +4131,7 @@ If `point' is at the beginning of a channel name, use that as default." (defun erc-set-channel-limit (&optional limit) "Set a LIMIT for the current channel. Remove limit if nil. Prompt for one if called interactively." - (interactive (list (read-from-minibuffer + (interactive (list (read-string (format "Limit for %s (RET to remove limit): " (erc-default-target))))) (let ((tgt (erc-default-target))) @@ -4091,7 +4142,7 @@ Prompt for one if called interactively." (defun erc-set-channel-key (&optional key) "Set a KEY for the current channel. Remove key if nil. Prompt for one if called interactively." - (interactive (list (read-from-minibuffer + (interactive (list (read-string (format "Key for %s (RET to remove key): " (erc-default-target))))) (let ((tgt (erc-default-target))) @@ -4102,7 +4153,7 @@ Prompt for one if called interactively." (defun erc-quit-server (reason) "Disconnect from current server after prompting for REASON. `erc-quit-reason' works with this just like with `erc-cmd-QUIT'." - (interactive (list (read-from-minibuffer + (interactive (list (read-string (format "Reason for quitting %s: " (or erc-server-announced-name erc-session-server))))) @@ -4133,7 +4184,7 @@ This places `point' just after the prompt, or at the beginning of the line." (defun erc-complete-word-at-point () (run-hook-with-args-until-success 'erc-complete-functions)) -(define-obsolete-function-alias 'erc-complete-word 'completion-at-point "24.1") +(define-obsolete-function-alias 'erc-complete-word #'completion-at-point "24.1") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; @@ -4161,9 +4212,9 @@ Displays PROC and PARSED appropriately using `erc-display-message'." (mapconcat #'identity (let (res) - (mapc #'(lambda (x) - (if (stringp x) - (setq res (append res (list x))))) + (mapc (lambda (x) + (if (stringp x) + (setq res (append res (list x))))) parsed) res) " "))) @@ -4551,10 +4602,10 @@ See also: `erc-echo-notice-in-user-buffers', ;; Remove the unbanned masks from the ban list (setq erc-channel-banlist (cl-delete-if - #'(lambda (y) - (member (upcase (cdr y)) - (mapcar #'upcase - (cdr (split-string mode))))) + (lambda (y) + (member (upcase (cdr y)) + (mapcar #'upcase + (cdr (split-string mode))))) erc-channel-banlist))) ((string-match "^\\+" mode) ;; Add the banned mask(s) to the ban list @@ -5181,7 +5232,7 @@ TOPIC string to the current topic." "Sort LIST-OF-STRINGS in lexicographic order. Side-effect free." - (sort (copy-sequence list-of-strings) 'string<)) + (sort (copy-sequence list-of-strings) #'string<)) (defun erc-parse-modes (mode-string) "Parse MODE-STRING into a list. @@ -5536,7 +5587,7 @@ This returns non-nil only if we actually send anything." (when (and (erc-input-sendp state) erc-send-this) (let ((string (erc-input-string state))) - (if (or (string-match "\n" string) + (if (or (string-search "\n" string) (not (string-match erc-command-regexp string))) (mapc (lambda (line) @@ -6118,11 +6169,11 @@ non-nil value is found. ;; time routines -(define-obsolete-function-alias 'erc-string-to-emacs-time 'string-to-number +(define-obsolete-function-alias 'erc-string-to-emacs-time #'string-to-number "27.1") -(defalias 'erc-emacs-time-to-erc-time 'float-time) -(defalias 'erc-current-time 'float-time) +(defalias 'erc-emacs-time-to-erc-time #'float-time) +(defalias 'erc-current-time #'float-time) (defun erc-time-diff (t1 t2) "Return the absolute value of the difference in seconds between T1 and T2." @@ -6289,7 +6340,6 @@ The following characters are replaced: (defcustom erc-header-line-format "%n on %t (%m,%l) %o" "A string to be formatted and shown in the header-line in `erc-mode'. -Only used starting in Emacs 21. Set this to nil if you do not want the header line to be displayed. @@ -6478,7 +6528,7 @@ if `erc-away' is non-nil." (fill-region (point-min) (point-max)) (buffer-string)))) (setq header-line-format - (replace-regexp-in-string + (string-replace "%" "%%" (if face @@ -6754,7 +6804,7 @@ functions." nick user host channel (if (not (string= reason "")) (format ": %s" - (replace-regexp-in-string "%" "%%" reason)) + (string-replace "%" "%%" reason)) ""))))) @@ -6905,7 +6955,3 @@ Otherwise, connect to HOST:PORT as USER and /join CHANNEL." (require 'erc-goodies) ;;; erc.el ends here -;; -;; Local Variables: -;; outline-regexp: ";;+" -;; End: |