From 2f5095294b7df8489fbb4c6ab9e75ad5fe1b2462 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Wed, 8 Nov 2023 19:14:55 -0800 Subject: [PATCH 1/5] [5.6] Make ERC error-notice formatting more consistent * lisp/erc/erc-backend.el (erc--server-propagate-failed-connection): Print leading notice prefix when reporting process exit status, and set `erc-msg' type to `notice-error'. (erc-schedule-reconnect): Print leading notice prefix when printing `reconnecting' message. * lisp/erc/erc.el (erc-process-input-line, erc-cmd-PART, erc-cmd-TOPIC): Print `no-target' messages as error notices. (erc-message-english-disconnected, erc-message-english-disconnected-noreconnect): Hard-code standard "***" notice prefix into message text, for consistency. * test/lisp/erc/erc-tests.el (erc--refresh-prompt): Expect notice prefix before `no-target' message. --- lisp/erc/erc-backend.el | 4 ++-- lisp/erc/erc.el | 11 ++++++----- test/lisp/erc/erc-tests.el | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 4b5edaa77d2..32d891cd1c6 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -728,7 +728,7 @@ erc--server-propagate-failed-connection the server buffer in any case." (when (eq (process-status process) 'failed) (erc-display-message - nil 'error (process-buffer process) + nil '(notice error) (process-buffer process) (format "Process exit status: %S" (process-exit-status process))) (pcase (process-exit-status process) (111 @@ -995,7 +995,7 @@ erc-schedule-reconnect (- erc-server-reconnect-attempts (cl-incf erc-server-reconnect-count (or incr 1))))) (proc (buffer-local-value 'erc-server-process buffer))) - (erc-display-message nil 'error buffer 'reconnecting + (erc-display-message nil '(notice error) buffer 'reconnecting ?m erc-server-reconnect-timeout ?i (if count erc-server-reconnect-count "N") ?n (if count erc-server-reconnect-attempts "A")) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index fd57cb9d6a0..2d8f388328d 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -3729,7 +3729,7 @@ erc-process-input-line (let ((r (erc-default-target))) (if r (funcall erc-send-input-line-function r line force) - (erc-display-message nil 'error (current-buffer) 'no-target) + (erc-display-message nil '(notice error) (current-buffer) 'no-target) nil))))) (defconst erc--shell-parse-regexp @@ -4581,7 +4581,7 @@ erc-cmd-PART (format "PART %s" ch) (format "PART %s :%s" ch reason)) nil ch)) - (erc-display-message nil 'error (current-buffer) 'no-target))) + (erc-display-message nil '(notice error) (current-buffer) 'no-target))) t) (t nil))) (put 'erc-cmd-PART 'do-not-parse-args t) @@ -4921,7 +4921,7 @@ erc-cmd-TOPIC (progn (erc-log (format "cmd: TOPIC [%s]: %s" ch topic)) (erc-server-send (format "TOPIC %s :%s" ch topic) nil ch)) - (erc-display-message nil 'error (current-buffer) 'no-target))) + (erc-display-message nil '(notice error) (current-buffer) 'no-target))) t) (t nil))) (defalias 'erc-cmd-T #'erc-cmd-TOPIC) @@ -8194,9 +8194,10 @@ erc-define-catalog (flood-ctcp-off . "FLOOD PROTECTION: Automatic CTCP responses turned off.") (flood-strict-mode . "FLOOD PROTECTION: Switched to Strict Flood Control mode.") - (disconnected . "\n\nConnection failed! Re-establishing connection...\n") + (disconnected + . "\n\n*** Connection failed! Re-establishing connection...\n") (disconnected-noreconnect - . "\n\nConnection failed! Not re-establishing connection.\n") + . "\n\n*** Connection failed! Not re-establishing connection.\n") (reconnecting . "Reconnecting in %ms: attempt %i/%n ...") (reconnect-canceled . "Canceled %u reconnect timer with %cs to go...") (finished . "\n\n*** ERC finished ***\n") diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 916b394c8ff..2898ca7be75 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -317,7 +317,7 @@ erc--refresh-prompt (insert "Howdy") (erc-send-current-line) (save-excursion (forward-line -1) - (should (looking-at "No target")) + (should (looking-at (rx "*** No target"))) (forward-line -1) (should (looking-at " Howdy"))) (should (looking-back "ServNet 6> ")) -- 2.41.0