Function: erc-settings--set-modules

erc-settings--set-modules is an autoloaded and byte-compiled function defined in erc-settings.el.gz.

Signature

(erc-settings--set-modules ID TARGET TARGET-SERVER-BUFFER)

Documentation

Set erc-modules locally if an entry exists for the current buffer.

In server buffers, bind all matching entries, not just erc-modules. Expect TARGET to be a string or nil and ID to be a symbol. When TARGET is non-nil, borrow local values from TARGET-SERVER-BUFFER to temporarily bind identifying variables sought by match conditions.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-settings.el.gz
;;;###autoload
(defun erc-settings--set-modules (id target target-server-buffer)
  "Set `erc-modules' locally if an entry exists for the current buffer.
In server buffers, bind all matching entries, not just `erc-modules'.
Expect TARGET to be a string or nil and ID to be a symbol.  When TARGET
is non-nil, borrow local values from TARGET-SERVER-BUFFER to temporarily
bind identifying variables sought by match conditions."
  (when (and erc-settings (or erc-settings-mode (memq 'settings erc-modules)))
    ;; Shadow `erc-networks--id' for (id . <id>), `erc--target' for
    ;; (target . <target>), etc.  Although predicates of interest, like
    ;; `erc-query-buffer-p', may call on `buffer-local-value', its
    ;; `buffer' argument will be the current buffer, which doesn't yet
    ;; have any buffer-local bindings.
    (cl-assert (not (local-variable-p 'erc-networks--id)))
    (cl-assert (not (local-variable-p 'erc-network)))
    (cl-assert (not (local-variable-p 'erc--target)))
    (let ((erc-networks--id
           (or (and id (erc-networks--id-create id))
               (and target (buffer-local-value 'erc-networks--id
                                               target-server-buffer)))))
      (if target
          (if-let*
              ((erc-network (buffer-local-value 'erc-network
                                                target-server-buffer))
               (erc--target (erc--target-from-string target))
               (bindings (erc-settings--gather-bindings (current-buffer)))
               (entry (assq 'erc-modules bindings)))
              (erc-settings--set-value 'erc-modules (nth 1 entry) (cddr entry))
            (when-let* ((old-value (with-current-buffer target-server-buffer
                                     (and (local-variable-p 'erc-modules)
                                          erc-modules))))
              (setq-local erc-modules old-value)))
        (erc-settings-bind)))))