Replace some uses of erc-error
* lisp/erc/erc-button.el (erc-button--display-error-notice-with-keys-and-warn): Use `erc--lwarn' so the warnings buffer is overridable for testing. * lisp/erc/erc-sasl.el (erc-sasl-mode, erc-sasl-enable): Signal an `error' instead of calling `erc-error', which continues execution. In this special case, the session cannot continue initializing, since connection registration can't reasonably be expected to complete successfully. (erc-sasl--destroy): Don't run `erc-quit-hook', and issue a warning of level `:error' to get users' attention instead of calling `ding'. * lisp/erc/erc-speedbar.el (erc-speedbar--emulate-sidebar-set-window-preserve-size): Don't set window parameters. Doing this basically made `erc-speedbar-toggle-nicknames-window-lock' unusable. (erc-speedbar--toggle-nicknames-sidebar): Manually unlock the window after toggling. (erc-nickbar-mode, erc-nickbar-enable, erc-nickbar-disable): Don't `ding' when called in a non-ERC buffer, and make sure to call `erc-speedbar--ensure' from an ERC buffer. Also, don't disable minor-mode var when speedbar buffer doesn't exist because that doesn't ensure it'll be created the next time around, and users may count on the activation state remaining consistent. (erc-speedbar-toggle-nicknames-window-lock): Make usable from lisp with explicit numeric arg. * lisp/erc/erc-status-sidebar.el (erc-bufbar-mode, erc-bufbar-enable): Only create the side window from an erc-mode buffer to ensure the ratio is preserved when burying the current buffer, e.g., with `custom-buffer-done'. * lisp/erc/erc.el (erc--warnings-buffer-name, erc--lwarn): New function, an analog of `lwarn', that allows for overriding the warnings buffer with the new variable `erc--warnings-buffer-name'. (erc-cmd-SERVER): Add comment. * test/lisp/erc/erc-scenarios-sasl.el (erc-scenarios-sasl--plain-fail): Expect warning instead of error. * test/lisp/erc/erc-scenarios-status-sidebar.el (erc-scenarios-status-sidebar--bufbar): Refresh when interactive as well. * test/lisp/erc/resources/sasl/plain-failed.eld: Expect EOF instead of "CAP END". (Bug#63595)
This commit is contained in:
parent
23d692ed01
commit
34fe0b5c87
8 changed files with 70 additions and 53 deletions
|
@ -869,8 +869,8 @@ non-strings, concatenate leading string members before applying
|
|||
(with-syntax-table lisp-mode-syntax-table
|
||||
(skip-syntax-forward "^-"))
|
||||
(forward-char)
|
||||
(display-warning
|
||||
'erc (buffer-substring-no-properties (point) (point-max))))))
|
||||
(erc--lwarn
|
||||
'erc :warning (buffer-substring-no-properties (point) (point-max))))))
|
||||
|
||||
(provide 'erc-button)
|
||||
|
||||
|
|
|
@ -332,8 +332,8 @@ This doesn't solicit or validate a suite of supported mechanisms."
|
|||
(client (erc-sasl--create-client mech)))
|
||||
(unless client
|
||||
(erc-display-error-notice
|
||||
nil (format "Unknown or unsupported SASL mechanism: %s" mech))
|
||||
(erc-error "Unknown or unsupported SASL mechanism: %s" mech))
|
||||
nil (format "Unknown or unsupported SASL mechanism: `%s'" mech))
|
||||
(error "Unknown or unsupported SASL mechanism: `%s'" mech))
|
||||
(setf (erc-sasl--state-client erc-sasl--state) client))))
|
||||
((kill-local-variable 'erc-sasl--state)
|
||||
(kill-local-variable 'erc-sasl--options))
|
||||
|
@ -370,9 +370,10 @@ This doesn't solicit or validate a suite of supported mechanisms."
|
|||
(setq data (concat (substring data end) (and (= end 400) "+"))))))))
|
||||
|
||||
(defun erc-sasl--destroy (proc)
|
||||
(run-hook-with-args 'erc-quit-hook proc)
|
||||
"Destroy process PROC and warn user that their settings are likely faulty."
|
||||
(delete-process proc)
|
||||
(erc-error "Disconnected from %s; please review SASL settings" proc))
|
||||
(erc--lwarn 'erc-sasl :error
|
||||
"Disconnected from %s; please review SASL settings" proc))
|
||||
|
||||
(define-erc-response-handler (902)
|
||||
"Handle an ERR_NICKLOCKED response." nil
|
||||
|
|
|
@ -453,10 +453,7 @@ The INDENT level is ignored."
|
|||
`(display-buffer-in-side-window
|
||||
. ((side . right)
|
||||
(window-width . ,erc-speedbar-nicknames-window-width)))))
|
||||
(erc-status-sidebar-set-window-preserve-size)
|
||||
(when-let ((window (get-buffer-window speedbar-buffer)))
|
||||
(set-window-parameter window 'no-other-window nil)
|
||||
(internal-show-cursor window t))))
|
||||
(erc-status-sidebar-set-window-preserve-size)))
|
||||
|
||||
(defun erc-speedbar--status-sidebar-mode--unhook ()
|
||||
"Remove hooks installed by `erc-status-sidebar-mode'."
|
||||
|
@ -504,7 +501,8 @@ The INDENT level is ignored."
|
|||
(speedbar-set-mode-line-format)))
|
||||
(when (or (not force) (>= arg 0))
|
||||
(with-selected-frame speedbar-frame
|
||||
(erc-speedbar--emulate-sidebar-set-window-preserve-size)))))
|
||||
(erc-speedbar--emulate-sidebar-set-window-preserve-size)
|
||||
(erc-speedbar-toggle-nicknames-window-lock -1)))))
|
||||
(when-let (((or (not force) (>= arg 0)))
|
||||
(speedbar-frame-parameters (backquote-list*
|
||||
'(visibility . nil)
|
||||
|
@ -522,7 +520,8 @@ The INDENT level is ignored."
|
|||
;; Emacs in the meantime.
|
||||
(make-frame-invisible speedbar-frame)
|
||||
(select-frame (setq speedbar-frame (previous-frame)))
|
||||
(erc-speedbar--emulate-sidebar-set-window-preserve-size))))
|
||||
(erc-speedbar--emulate-sidebar-set-window-preserve-size)
|
||||
(erc-speedbar-toggle-nicknames-window-lock -1))))
|
||||
(cl-assert (not (cdr (erc-speedbar--get-timers))) t))
|
||||
|
||||
(defun erc-speedbar--ensure (&optional force)
|
||||
|
@ -563,12 +562,10 @@ such a thing and can reproduce it, please file a bug report with
|
|||
(and-let* ((speedbar-buffer)
|
||||
(win (get-buffer-window speedbar-buffer 'all-frames))
|
||||
((eq speedbar-frame (window-frame win))))))
|
||||
(if speedbar-buffer
|
||||
(erc-speedbar--ensure 'force)
|
||||
(setq erc-nickbar-mode nil)
|
||||
(when (derived-mode-p 'erc-mode)
|
||||
(erc-error "Not initializing `erc-nickbar-mode' in %s"
|
||||
(current-buffer))))))
|
||||
(when-let ((buf (or (and (derived-mode-p 'erc-mode) (current-buffer))
|
||||
(car (erc-buffer-filter #'erc--server-buffer-p)))))
|
||||
(with-current-buffer buf
|
||||
(erc-speedbar--ensure 'force)))))
|
||||
((remove-hook 'erc--setup-buffer-hook #'erc-speedbar--ensure)
|
||||
(when erc-track-mode
|
||||
(setq erc-track--switch-fallback-blockers
|
||||
|
@ -609,15 +606,21 @@ such a thing and can reproduce it, please file a bug report with
|
|||
;; erc-speedbar.el resets this to nil.
|
||||
(setq speedbar-buffer nil)))
|
||||
|
||||
(defun erc-speedbar-toggle-nicknames-window-lock ()
|
||||
"Toggle whether nicknames window is selectable with \\[other-window]."
|
||||
(interactive)
|
||||
(defun erc-speedbar-toggle-nicknames-window-lock (arg)
|
||||
"Toggle whether nicknames window is selectable with \\[other-window].
|
||||
When arg is a number, lock the window if non-negative, otherwise
|
||||
unlock."
|
||||
(interactive "P")
|
||||
(unless erc-nickbar-mode
|
||||
(user-error "`erc-nickbar-mode' inactive"))
|
||||
(when-let ((window (get-buffer-window speedbar-buffer)))
|
||||
(let ((val (window-parameter window 'no-other-window)))
|
||||
(set-window-parameter window 'no-other-window (not val))
|
||||
(message "nick-window: %s" (if val "selectable" "protected")))))
|
||||
(let ((val (cond ((natnump arg) t)
|
||||
((integerp arg) nil)
|
||||
(t (not (window-parameter window
|
||||
'no-other-window))))))
|
||||
(set-window-parameter window 'no-other-window val)
|
||||
(unless (numberp arg)
|
||||
(message "nick-window: %s" (if val "protected" "selectable"))))))
|
||||
|
||||
|
||||
;;;; Nicks integration
|
||||
|
|
|
@ -257,12 +257,13 @@ current frame only."
|
|||
" Add `track' to `erc-modules' to silence this message."))
|
||||
(erc-track-mode +1))
|
||||
(add-hook 'erc--setup-buffer-hook #'erc-status-sidebar--open)
|
||||
(unless erc--updating-modules-p
|
||||
(if (erc-with-server-buffer erc-server-connected)
|
||||
(erc-status-sidebar--open)
|
||||
(when (derived-mode-p 'erc-mode)
|
||||
(erc-error "Not initializing `erc-bufbar-mode' in %s"
|
||||
(current-buffer))))))
|
||||
;; Preserve side-window dimensions after `custom-buffer-done'.
|
||||
(when-let (((not erc--updating-modules-p))
|
||||
(buf (or (and (derived-mode-p 'erc-mode) (current-buffer))
|
||||
(car (erc-buffer-filter
|
||||
(lambda () erc-server-connected))))))
|
||||
(with-current-buffer buf
|
||||
(erc-status-sidebar--open))))
|
||||
((remove-hook 'erc--setup-buffer-hook #'erc-status-sidebar--open)
|
||||
(erc-status-sidebar-close 'all-frames)
|
||||
(when-let ((arg erc--module-toggle-prefix-arg)
|
||||
|
|
|
@ -2880,6 +2880,15 @@ message instead, to make debugging easier."
|
|||
(apply #'message args)
|
||||
(beep)))
|
||||
|
||||
(defvar erc--warnings-buffer-name nil
|
||||
"Name of possibly existing alternate warnings buffer for unit tests.")
|
||||
|
||||
(defun erc--lwarn (type level format-string &rest args)
|
||||
"Issue a warning of TYPE and LEVEL with FORMAT-STRING and ARGS."
|
||||
(let ((message (substitute-command-keys
|
||||
(apply #'format-message format-string args))))
|
||||
(display-warning type message level erc--warnings-buffer-name)))
|
||||
|
||||
;;; Debugging the protocol
|
||||
|
||||
(defvar erc-debug-irc-protocol-time-format "%FT%T.%6N%z "
|
||||
|
@ -5032,6 +5041,8 @@ connection or, with -A, all applicable connections.
|
|||
|
||||
(put 'erc-cmd-RECONNECT 'process-not-needed t)
|
||||
|
||||
;; FIXME use less speculative error message or lose `condition-case',
|
||||
;; since most connection failures don't signal anything.
|
||||
(defun erc-cmd-SERVER (server)
|
||||
"Connect to SERVER, leaving existing connection intact."
|
||||
(erc-log (format "cmd: SERVER: %s" server))
|
||||
|
|
|
@ -149,23 +149,25 @@
|
|||
(erc-modules (cons 'sasl erc-modules))
|
||||
(erc-sasl-password "wrong")
|
||||
(erc-sasl-mechanism 'plain)
|
||||
(expect (erc-d-t-make-expecter))
|
||||
(buf nil))
|
||||
(erc--warnings-buffer-name "*ERC test warnings*")
|
||||
(warnings-buffer (get-buffer-create erc--warnings-buffer-name))
|
||||
(expect (erc-d-t-make-expecter)))
|
||||
|
||||
(ert-info ("Connect")
|
||||
(setq buf (erc :server "127.0.0.1"
|
||||
:port port
|
||||
:nick "tester"
|
||||
:user "tester"
|
||||
:full-name "tester"))
|
||||
(let ((err (should-error
|
||||
(with-current-buffer buf
|
||||
(funcall expect 20 "Connection failed!")))))
|
||||
(should (string-search "please review" (cadr err)))
|
||||
(with-current-buffer buf
|
||||
(funcall expect 10 "Opening connection")
|
||||
(funcall expect 20 "SASL authentication failed")
|
||||
(should-not (erc-server-process-alive)))))))
|
||||
(with-current-buffer (erc :server "127.0.0.1"
|
||||
:port port
|
||||
:nick "tester"
|
||||
:user "tester"
|
||||
:full-name "tester")
|
||||
(funcall expect 10 "Opening connection")
|
||||
(funcall expect 20 "SASL authentication failed")
|
||||
(funcall expect 20 "Connection failed!")
|
||||
(should-not (erc-server-process-alive)))
|
||||
|
||||
(with-current-buffer warnings-buffer
|
||||
(funcall expect 10 "please review SASL settings")))
|
||||
|
||||
(when noninteractive
|
||||
(should-not (get-buffer "*ERC test warnings*"))))
|
||||
|
||||
(defun erc-scenarios--common--sasl (mech)
|
||||
(erc-scenarios-common-with-cleanup
|
||||
|
|
|
@ -64,8 +64,7 @@
|
|||
(let ((obuf (window-buffer))) ; *scratch*
|
||||
(set-window-buffer (selected-window) "#foo")
|
||||
(erc-d-t-wait-for 5
|
||||
(when noninteractive
|
||||
(erc-status-sidebar-refresh))
|
||||
(erc-status-sidebar-refresh)
|
||||
(with-current-buffer "*ERC Status*"
|
||||
(and (marker-position erc-status-sidebar--active-marker)
|
||||
(goto-char erc-status-sidebar--active-marker)
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
;; -*- mode: lisp-data; -*-
|
||||
((cap-req 10 "CAP REQ :sasl"))
|
||||
((nick 1 "NICK tester"))
|
||||
((user 1 "USER tester 0 * :tester")
|
||||
((nick 10 "NICK tester"))
|
||||
((user 10 "USER tester 0 * :tester")
|
||||
(0.0 ":irc.foonet.org NOTICE * :*** Looking up your hostname...")
|
||||
(0.0 ":irc.foonet.org NOTICE * :*** Found your hostname")
|
||||
(0.0 ":irc.foonet.org CAP * ACK :cap-notify sasl"))
|
||||
|
||||
((authenticate-plain 3.2 "AUTHENTICATE PLAIN")
|
||||
((authenticate-plain 10 "AUTHENTICATE PLAIN")
|
||||
(0.0 ":irc.foonet.org AUTHENTICATE +"))
|
||||
|
||||
((authenticate-gimme 3.2 "AUTHENTICATE AHRlc3RlcgB3cm9uZw==")
|
||||
((authenticate-gimme 10 "AUTHENTICATE AHRlc3RlcgB3cm9uZw==")
|
||||
(0.0 ":irc.foonet.org 900 * * tester :You are now logged in as tester")
|
||||
(0.0 ":irc.foonet.org 904 * :SASL authentication failed: Invalid account credentials"))
|
||||
|
||||
((cap-end 3.2 "CAP END"))
|
||||
((eof 10 EOF))
|
||||
|
|
Loading…
Add table
Reference in a new issue