Function: erc-nicks-mode

erc-nicks-mode is an interactive and byte-compiled function defined in erc-nicks.el.gz.

Signature

(erc-nicks-mode &optional ARG)

Documentation

Toggle ERC nicks mode locally.

If called interactively, enable erc-nicks-mode(var)/erc-nicks-mode(fun) if ARG is positive, and disable it otherwise. If called from Lisp, enable the mode if ARG is omitted or nil.

Uniquely colorize nicknames in target buffers.

This module is local per connection.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-nicks.el.gz
(define-erc-module nicks nil
  "Uniquely colorize nicknames in target buffers.

This module is local per connection."
  ((if erc--target
       (progn
         (erc-with-server-buffer
           (unless erc-nicks-mode
             (erc--warn-once-before-connect 'erc-nicks-mode
               "Module `nicks' must be enabled or disabled session-wide."
               " Toggling it in individual target buffers is unsupported.")
             (erc-nicks-mode +1))) ; but do it anyway
         (setq erc-nicks--downcased-skip-nicks
               (mapcar #'erc-downcase erc-nicks-skip-nicks)
               erc-nicks--fg-rgb (erc-with-server-buffer erc-nicks--fg-rgb))
         (add-function :filter-return (local 'erc-button--modify-nick-function)
                       #'erc-nicks--highlight-button '((depth . 80)))
         (erc-button--phantom-users-mode +1))
     (unless erc-button-mode
       (unless (memq 'button erc-modules)
         (erc--warn-once-before-connect 'erc-nicks-mode
           "Enabling default global module `button' needed by local"
           " module `nicks'. This will impact \C-]all\C-] ERC"
           " sessions. Add `button' to `erc-modules' to avoid this"
           " warning. See Info:\"(erc) Modules\" for more."))
       (erc-button-mode +1))
     (when (equal erc-nicks-bg-color "unspecified-bg")
       (let ((temp (if (eq (erc-nicks--bg-mode) 'light) "white" "black")))
         (erc-button--display-error-notice-with-keys
          "Module `nicks' unable to determine background color.  Setting to \""
          temp "\" globally.  Please see `erc-nicks-bg-color'.")
         (custom-set-variables (list 'erc-nicks-bg-color temp))))
     (setq erc-nicks--fg-rgb
           (or (color-name-to-rgb
                (face-foreground 'erc-default-face nil 'default))
               (color-name-to-rgb
                (readable-foreground-color erc-nicks-bg-color))))
     (erc-nicks--init-pool)
     (erc--restore-initialize-priors erc-nicks-mode
       erc-nicks--face-table (make-hash-table :test #'equal)))
   (setf (alist-get "Edit face" erc-button--nick-popup-alist nil nil #'equal)
         #'erc-nicks-customize-face)
   (erc-nicks--setup-track-integration)
   (add-hook 'erc-track-mode-hook #'erc-nicks--setup-track-integration 50 t)
   (advice-add 'widget-create-child-and-convert :filter-args
               #'erc-nicks--redirect-face-widget-link))
  ((kill-local-variable 'erc-nicks--face-table)
   (kill-local-variable 'erc-nicks--bg-mode-value)
   (kill-local-variable 'erc-nicks--bg-luminance)
   (kill-local-variable 'erc-nicks--fg-rgb)
   (kill-local-variable 'erc-nicks--colors-len)
   (kill-local-variable 'erc-nicks--colors-pool)
   (kill-local-variable 'erc-nicks--downcased-skip-nicks)
   (when (fboundp 'erc-button--phantom-users-mode)
     (erc-button--phantom-users-mode -1))
   (remove-function (local 'erc-track--face-reject-function)
                    #'erc-nicks--reject-uninterned-faces)
   (remove-function (local 'erc-button--modify-nick-function)
                    #'erc-nicks--highlight-button)
   (remove-function (local 'erc-track--alt-normals-function)
                    #'erc-nicks--track-prioritize)
   (remove-function (local 'erc-track--alt-normals-function)
                    #'erc-nicks--track-always)
   (remove-hook 'erc-track-mode-hook #'erc-nicks--setup-track-integration t)
   (setf (alist-get "Edit face"
                    erc-button--nick-popup-alist nil 'remove #'equal)
         nil)
   (unless erc-button--nick-popup-alist
     (kill-local-variable 'erc-button--nick-popup-alist)))
  localp)