Function: erc-update-mode-line-buffer

erc-update-mode-line-buffer is a byte-compiled function defined in erc.el.gz.

Signature

(erc-update-mode-line-buffer BUFFER)

Documentation

Update the mode line in a single ERC buffer BUFFER.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
;; TODO when ERC drops Emacs 28, replace the expressions in the format
;; spec below with functions.
(defun erc-update-mode-line-buffer (buffer)
  "Update the mode line in a single ERC buffer BUFFER."
  (with-current-buffer buffer
    (let ((spec `((?a . ,(erc-format-away-status))
                  (?l . ,(erc-format-lag-time))
                  (?m . ,(or erc--mode-line-mode-string ""))
                  (?n . ,(or (erc-current-nick) ""))
                  (?N . ,(erc-format-network))
                  (?o . ,(or (erc-controls-strip erc-channel-topic) ""))
                  (?p . ,(erc-port-to-string erc-session-port))
                  (?s . ,(erc-format-target-and/or-server))
                  (?S . ,(erc-format-target-and/or-network))
                  (?t . ,(erc-format-target))))
          (process-status (cond ((erc-server-process-alive buffer)
                                 (unless erc-server-connected
                                   ": connecting"))
                                ((erc-with-server-buffer
                                   erc--server-reconnect-timer)
                                 erc--mode-line-process-reconnecting)
                                (t
                                 ": CLOSED")))
          (face (cond ((eq erc-header-line-face-method nil)
                       nil)
                      ((functionp erc-header-line-face-method)
                       (funcall erc-header-line-face-method))
                      (t
                       'erc-header-line))))
      (setq mode-line-buffer-identification
            (list (format-spec erc-mode-line-format spec)))
      (setq mode-line-process process-status)
      (let ((header (if erc-header-line-format
                        (format-spec erc-header-line-format spec)
                      nil)))
        (cond (erc-header-line-uses-tabbar-p
               (when (boundp 'tabbar--local-hlf)
                 (setq-local tabbar--local-hlf header-line-format))
               (kill-local-variable 'header-line-format))
              ((null header)
               (setq header-line-format nil))
              (erc-header-line-uses-help-echo-p
               (let ((help-echo (with-temp-buffer
                                  (insert header)
                                  (fill-region (point-min) (point-max))
                                  (buffer-string))))
                 (setq header-line-format
                       (string-replace
                        "%"
                        "%%"
                        (if face
                            (propertize header 'help-echo help-echo 'face face)
                          (propertize header 'help-echo help-echo))))))
              (t (setq header-line-format
                       (if face
                           (propertize header 'face face)
                         header))))))
    (force-mode-line-update)))