From beb60a9027ce61b4fa5b003804a46fefc4916c6f Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Wed, 8 Nov 2023 19:14:55 -0800 Subject: [PATCH] Make ERC's error-notice formatting more consistent * lisp/erc/erc-backend.el (erc--server-propagate-failed-connection): Include leading three-asterisk notice prefix when reporting process exit status, and set the `erc-msg' text property to `notice-error'. (erc-schedule-reconnect): Include leading notice prefix when inserting `reconnecting' message. * lisp/erc/erc.el (erc-process-input-line, erc-cmd-PART, erc-cmd-TOPIC): Display `no-target' messages as "error notices". (erc-message-english-disconnected, erc-message-english-disconnected-noreconnect): Hard-code standard value of `erc-notice-prefix' into message text for consistency during formatting and insertion. * test/lisp/erc/erc-tests.el (erc--refresh-prompt): Expect notice prefix before `no-target' message. (Bug#67031) --- 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 @@ error data is something ERC recognizes. Print an explanation to 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 @@ When `erc-server-reconnect-attempts' is a number, increment (- 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 @@ this function from interpreting the line as a command." (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 @@ Otherwise leave the channel indicated by LINE." (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 @@ be displayed." (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 @@ All windows are opened in the current frame." (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 @@ (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.39.2