Function: erc-get-channel-membership-prefix
erc-get-channel-membership-prefix is a byte-compiled function defined
in erc.el.gz.
Signature
(erc-get-channel-membership-prefix NICK-OR-CUSR)
Documentation
Return channel membership prefix for NICK-OR-CUSR as a string.
Ensure returned string has a help-echo text property with the
corresponding verbose membership type, like "voice", as its
value. Expect NICK-OR-CUSR to be an erc-channel-user object or
a string nickname, not necessarily downcased. When called in a
logically connected ERC buffer, use advertised prefix mappings.
For compatibility reasons, don't error when NICK-OR-CUSR is null,
but return nil instead of the empty string. Otherwise, always
return a possibly empty string.
Aliases
erc-get-user-mode-prefix (obsolete since 30.1)
Source Code
;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defun erc-get-channel-membership-prefix (nick-or-cusr)
"Return channel membership prefix for NICK-OR-CUSR as a string.
Ensure returned string has a `help-echo' text property with the
corresponding verbose membership type, like \"voice\", as its
value. Expect NICK-OR-CUSR to be an `erc-channel-user' object or
a string nickname, not necessarily downcased. When called in a
logically connected ERC buffer, use advertised prefix mappings.
For compatibility reasons, don't error when NICK-OR-CUSR is null,
but return nil instead of the empty string. Otherwise, always
return a possibly empty string."
(when nick-or-cusr
(when (stringp nick-or-cusr)
(setq nick-or-cusr (and erc-channel-members
(cdr (erc-get-channel-member nick-or-cusr)))))
(cond
((null nick-or-cusr) "")
;; Special-case most common value.
((zerop (erc-channel-user-status nick-or-cusr)) "")
;; For compatibility, first check whether a parsed prefix exists.
((and-let* ((pfx-obj (erc--parsed-prefix)))
(catch 'done
(pcase-dolist (`(,letter . ,pfx)
(erc--parsed-prefix-alist pfx-obj))
(when (erc--cusr-status-p nick-or-cusr letter)
(throw 'done
(pcase letter
(?q (propertize (string pfx) 'help-echo "owner"))
(?a (propertize (string pfx) 'help-echo "admin"))
(?o (propertize (string pfx) 'help-echo "operator"))
(?h (propertize (string pfx) 'help-echo "half-op"))
(?v (propertize (string pfx) 'help-echo "voice"))
(_ (string pfx))))))
"")))
(t
(cond ((erc-channel-user-owner nick-or-cusr)
(propertize "~" 'help-echo "owner"))
((erc-channel-user-admin nick-or-cusr)
(propertize "&" 'help-echo "admin"))
((erc-channel-user-op nick-or-cusr)
(propertize "@" 'help-echo "operator"))
((erc-channel-user-halfop nick-or-cusr)
(propertize "%" 'help-echo "half-op"))
((erc-channel-user-voice nick-or-cusr)
(propertize "+" 'help-echo "voice"))
(t ""))))))