Function: erc-speedbar--ensure
erc-speedbar--ensure is a byte-compiled function defined in
erc-speedbar.el.gz.
Signature
(erc-speedbar--ensure &optional FORCEP)
Documentation
Perform common setup for erc-nickbar-mode(var)/erc-nickbar-mode(fun).
Without FORCEP, return early when the calling context isn't associated with an ERC session.
Source Code
;; Defined in /usr/src/emacs/lisp/erc/erc-speedbar.el.gz
(defun erc-speedbar--ensure (&optional forcep)
"Perform common setup for `erc-nickbar-mode'.
Without FORCEP, return early when the calling context isn't
associated with an ERC session."
(save-excursion
(when (or (erc-server-buffer) forcep)
(when erc-track-mode
(cl-pushnew '(derived-mode . speedbar-mode)
erc-track--switch-fallback-blockers :test #'equal))
(unless speedbar-update-flag
(erc-button--display-error-notice-with-keys
(erc-server-buffer)
"Module `nickbar' needs `speedbar-update-flag' to be non-nil"
(and (not (display-graphic-p)) " in text terminals")
". Setting to t for the current Emacs session."
" Customize it permanently to avoid this message.")
(setq speedbar-update-flag t))
(when-let (((null speedbar-buffer))
(speedbar-frame-parameters (backquote-list*
'(visibility . nil)
'(no-other-frame . t)
speedbar-frame-parameters))
(speedbar-after-create-hook #'erc-speedbar--emulate-sidebar)
(original-frame (selected-frame)))
(erc-install-speedbar-variables)
;; Run before toggling mode to prevent timer from being
;; created twice.
(speedbar-change-initial-expansion-list "ERC")
(speedbar-frame-mode 1)
;; The setup steps below can't go in the "create hook" because
;; the frame with `window-main-window' will be raised and
;; steal focus if you switch away from Emacs in the meantime.
(let ((frame speedbar-frame))
(cl-assert (not (eq speedbar-frame original-frame)))
(select-frame (setq speedbar-frame original-frame))
(delete-frame frame))
;; Allow deleting (our) `speedbar-frame' with the mouse.
(with-current-buffer speedbar-buffer
(kill-local-variable 'dframe-delete-frame-function)
(setq dframe-delete-frame-function
#'erc-speedbar--handle-delete-frame)))
(with-selected-frame speedbar-frame
(erc-speedbar--emulate-sidebar-set-window-preserve-size)
(erc-speedbar-toggle-nicknames-window-lock -1))
(cl-assert (null (cdr (erc-speedbar--get-timers))))
(with-current-buffer speedbar-buffer
(setq speedbar-update-flag t)
(speedbar-set-mode-line-format)))))