Function: erc-status-sidebar-refresh

erc-status-sidebar-refresh is an interactive and byte-compiled function defined in erc-status-sidebar.el.gz.

Signature

(erc-status-sidebar-refresh)

Documentation

Update the content of the sidebar.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-status-sidebar.el.gz
(defun erc-status-sidebar-refresh ()
  "Update the content of the sidebar."
  (interactive)
  (pcase-let* ((`(,list-fn ,sort-fn ,name-fn ,fmt-fn ,insert-fn)
                (pcase erc-status-sidebar-style
                  ('channels-only (list #'erc-channel-list
                                        erc-status-sidebar-channel-sort
                                        #'erc-status-sidebar-get-channame
                                        erc-status-sidebar-channel-format
                                        #'erc-status-sidebar-default-insert))
                  ((or 'all-mixed 'all-queries-first 'all-channels-first)
                   '(erc-status-sidebar-all-target-buffers
                     erc-status-sidebar-default-allsort
                     erc-status-sidebar-prefer-target-as-name
                     erc-status-sidebar-default-chan-format
                     erc-status-sidebar-pad-hierarchy))
                  (v v)))
               (chanlist (apply sort-fn (funcall list-fn nil) nil))
               (windows nil))
    (with-current-buffer (erc-status-sidebar-get-buffer)
      (dolist (window (get-buffer-window-list nil nil t))
        (push (cons window (window-start window)) windows))
      (erc-status-sidebar-writable
       (delete-region (point-min) (point-max))
       (goto-char (point-min))
       (if erc-status-sidebar--active-marker
           (set-marker erc-status-sidebar--active-marker nil)
         (setq erc-status-sidebar--active-marker (make-marker)))
       (dolist (chanbuf chanlist)
         (let* ((tup (seq-find (lambda (tup) (eq (car tup) chanbuf))
                               erc-modified-channels-alist))
                (count (if tup (cadr tup)))
                (face (if tup (cddr tup)))
                (face (if (or (not (buffer-live-p chanbuf))
                              (not (erc-server-process-alive chanbuf)))
                          `(shadow ,face)
                        face))
                (channame (apply fmt-fn
                                 (copy-sequence (funcall name-fn chanbuf))
                                 count face nil))
                (cnlen (length channame)))
           (put-text-property 0 cnlen 'erc-buf chanbuf channame)
           (put-text-property 0 cnlen 'mouse-face 'highlight channame)
           (put-text-property
            0 cnlen 'help-echo
            "mouse-1: switch to buffer in other window" channame)
           (funcall insert-fn channame chanbuf chanlist)))
       (when windows
         (map-apply #'set-window-start windows))
       (when (and erc-status-sidebar-highlight-active-buffer
                  (marker-buffer erc-status-sidebar--active-marker))
         (goto-char erc-status-sidebar--active-marker)
         (require 'hl-line)
         (unless hl-line-mode (hl-line-mode +1))
         (hl-line-highlight))))))