(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)
(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))
(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
`(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'."
(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)
;; 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)
(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
;; 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
" 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)
(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 "
(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))
(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
(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)
;; -*- 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))