Function: erc--define-channel-user-status-compat-getter

erc--define-channel-user-status-compat-getter is a macro defined in erc.el.gz.

Signature

(erc--define-channel-user-status-compat-getter NAME C D)

Documentation

Define accessor with gv getter for historical erc-channel-user slot NAME.

Expect NAME to be a string, C to be its traditionally associated letter, and D to be its fallback power-of-2 integer for non-ERC buffers. Unlike pre-ERC-5.6 accessors, do not bother generating a compiler macro for inlining calls to these adapters.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defmacro erc--define-channel-user-status-compat-getter (name c d)
  "Define accessor with gv getter for historical `erc-channel-user' slot NAME.
Expect NAME to be a string, C to be its traditionally associated letter,
and D to be its fallback power-of-2 integer for non-ERC buffers.  Unlike
pre-ERC-5.6 accessors, do not bother generating a compiler macro for
inlining calls to these adapters."
  `(defun ,(intern (concat "erc-channel-user-" name)) (u)
     ,(concat
       "Get equivalent of pre-5.6 `" name "' slot for `erc-channel-user'."
       "\nUse a fallback value in non-ERC buffers.  Treat an unadvertised"
       "\nstatus according to `erc-channel-user-signal-if-status-unknown'.")
     (declare (gv-setter
               (lambda (v)
                 (macroexp-let2 nil v v
                   (,'\`(let* ((val (erc-channel-user-status ,',u))
                               (p (erc--parsed-prefix))
                               (n (if p (or (erc--get-prefix-flag ,c p) 0) ,d))
                               (nop (and p ,',v (zerop n))) ; unsupportedp
                               (rv (and (not nop) ,',v)))
                          (when (and nop
                                     erc-channel-user-signal-if-status-unknown)
                            (error "Unsupported status prefix: %c" ,c))
                          (unless nop
                            (setf (erc-channel-user-status ,',u)
                                  (if ,',v
                                      (logior val n)
                                    (logand val (lognot n)))))
                          rv))))))
     (let* ((p (erc--parsed-prefix))
            (n (if p (erc--get-prefix-flag ,c p) ,d)))
       (and n (= n (logand n (erc-channel-user-status u)))))))