[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 7db500b50be 09/19: Make erc-get-user-mode-prefix more flexible
From: |
F. Jason Park |
Subject: |
master 7db500b50be 09/19: Make erc-get-user-mode-prefix more flexible |
Date: |
Sun, 17 Dec 2023 23:21:39 -0500 (EST) |
branch: master
commit 7db500b50be5f59ce65785a2cc35a8587e7e6cd1
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
Make erc-get-user-mode-prefix more flexible
* etc/ERC-NEWS: Mention renaming of `erc-get-user-mode-prefix'.
* lisp/erc/erc-speedbar.el (erc-speedbar-insert-user): Use
`erc-get-channel-membership-prefix' so that nicks in the nickbar can
have prefixes beyond just those for "voice" and "op".
* lisp/erc/erc.el (erc-get-user-mode-prefix,
erc-get-channel-membership-prefix): Rename former to latter because
"user mode" suggests the function somehow involves user modes, but it
exclusively concerns channel modes. Also, overload the only parameter
in order to avoid redundantly looking up `erc-channel-user' object
with every predicate call. In the near future, ERC will likely need
to offer an alternate version of this function that returns multiple
prefixes instead of just one.
(erc-format-@nick): Actually use the `channel-data' parameter.
(erc-format-my-nick, erc--format-channel-status-prefix): Use new name
for function `erc-get-user-mode-prefix'. (Bug#63595) (Bug#67677)
---
etc/ERC-NEWS | 7 +++++++
lisp/erc/erc-speedbar.el | 4 +---
lisp/erc/erc.el | 30 ++++++++++++++++++++----------
3 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/etc/ERC-NEWS b/etc/ERC-NEWS
index 3bb302e1dd2..b89c5228e32 100644
--- a/etc/ERC-NEWS
+++ b/etc/ERC-NEWS
@@ -437,6 +437,13 @@ The 'fill' module is now defined by 'define-erc-module'.
The same
goes for ERC's imenu integration, which has 'imenu' now appearing in
the default value of 'erc-modules'.
+*** Function 'erc-get-user-mode-prefix' renamed.
+This utility has been renamed to 'erc-get-channel-membership-prefix'
+to better reflect its role of delivering a formatted "status prefix",
+like "+" (for "voice"), and to avoid confusion with user modes, like
+"+i" (for "invisible"). Additionally, its lone parameter is now
+overloaded to accept an 'erc-channel-user' object as well as a string.
+
*** Hidden messages contain a preceding rather than trailing newline.
ERC has traditionally only offered to hide messages involving fools,
but plans are to make hiding more powerful. Anyone depending on the
diff --git a/lisp/erc/erc-speedbar.el b/lisp/erc/erc-speedbar.el
index 93be7b9f074..90d7376fc0c 100644
--- a/lisp/erc/erc-speedbar.el
+++ b/lisp/erc/erc-speedbar.el
@@ -319,9 +319,7 @@ a list of four items: the userhost, the GECOS, the current
(info (erc-server-user-info user))
(login (erc-server-user-login user))
(name (erc-server-user-full-name user))
- (voice (and cuser (erc-channel-user-voice cuser)))
- (op (and cuser (erc-channel-user-op cuser)))
- (nick-str (concat (if op "@" "") (if voice "+" "") nick))
+ (nick-str (concat (erc-get-channel-membership-prefix cuser) nick))
(finger (concat login (when (or login host) "@") host))
(sbtoken (list finger name info (buffer-name buffer))))
(if (or login host name info) ; we want to be expandable
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 333b762a113..2e078651a52 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -5798,21 +5798,31 @@ NUH, and the current `erc-response' object.")
See also `erc-format-nick-function'."
(when user (erc-server-user-nickname user)))
-(defun erc-get-user-mode-prefix (user)
+(define-obsolete-function-alias 'erc-get-user-mode-prefix
+ #'erc-get-channel-membership-prefix "30.1")
+(defun erc-get-channel-membership-prefix (user)
+ "Return channel membership prefix for USER as a string.
+Ensure returned string has a `help-echo' text property with the
+corresponding verbose membership type, like \"voice\", as its
+value. Expect USER to be an `erc-channel-user' object or a
+string nickname, not necessarily downcased."
(when user
- (cond ((erc-channel-user-owner-p user)
+ (when (stringp user)
+ (setq user (and erc-channel-users (cdr (erc-get-channel-user user)))))
+ (cond ((null user) "")
+ ((erc-channel-user-owner user)
(propertize "~" 'help-echo "owner"))
- ((erc-channel-user-admin-p user)
+ ((erc-channel-user-admin user)
(propertize "&" 'help-echo "admin"))
- ((erc-channel-user-op-p user)
+ ((erc-channel-user-op user)
(propertize "@" 'help-echo "operator"))
- ((erc-channel-user-halfop-p user)
+ ((erc-channel-user-halfop user)
(propertize "%" 'help-echo "half-op"))
- ((erc-channel-user-voice-p user)
+ ((erc-channel-user-voice user)
(propertize "+" 'help-echo "voice"))
(t ""))))
-(defun erc-format-@nick (&optional user _channel-data)
+(defun erc-format-@nick (&optional user channel-data)
"Format the nickname of USER showing if USER has a voice, is an
operator, half-op, admin or owner. Owners have \"~\", admins have
\"&\", operators have \"@\" and users with voice have \"+\" as a
@@ -5821,7 +5831,7 @@ also `erc-format-nick-function'."
(when user
(let ((nick (erc-server-user-nickname user)))
(concat (propertize
- (erc-get-user-mode-prefix nick)
+ (erc-get-channel-membership-prefix channel-data)
'font-lock-face 'erc-nick-prefix-face)
nick))))
@@ -5831,7 +5841,7 @@ also `erc-format-nick-function'."
(let* ((open "<")
(close "> ")
(nick (erc-current-nick))
- (mode (erc-get-user-mode-prefix nick)))
+ (mode (erc-get-channel-membership-prefix nick)))
(concat
(propertize open 'font-lock-face 'erc-default-face)
(propertize mode 'font-lock-face 'erc-my-nick-prefix-face)
@@ -8467,7 +8477,7 @@ Currently only used by the option `erc-prompt-format'.")
(defun erc--format-channel-status-prefix ()
"Return the current channel membership prefix."
(and (erc--target-channel-p erc--target)
- (erc-get-user-mode-prefix (erc-current-nick))))
+ (erc-get-channel-membership-prefix (erc-current-nick))))
(defun erc--format-modes (&optional no-query-p)
"Return a string of channel modes in channels and user modes elsewhere.
- master 0f058244ab7 18/19: Cache shortened channel names in erc-track, (continued)
- master 0f058244ab7 18/19: Cache shortened channel names in erc-track, F. Jason Park, 2023/12/17
- master 49bfea4386f 12/19: Use templates for formatting chat messages in ERC, F. Jason Park, 2023/12/17
- master 1e2b156f040 04/19: Double hyphenate internal ERC 5.6 text props, F. Jason Park, 2023/12/17
- master b5da8ba8070 02/19: Define ERC message-formatting templates with defvar, F. Jason Park, 2023/12/17
- master 69ca2cc1138 05/19: Add utility for iterating over arrays in ERC, F. Jason Park, 2023/12/17
- master 4ee4865ce20 07/19: Add erc-server-396 response handler, F. Jason Park, 2023/12/17
- master 741bce84890 16/19: Forgo excess nick buttonizing on JOINs and QUITs, F. Jason Park, 2023/12/17
- master 7c2e02e6d79 01/19: Remove module from suggested lineup in ERC's manual, F. Jason Park, 2023/12/17
- master 11bae96d23b 08/19: Clarify warning for process-dependent input in ERC, F. Jason Park, 2023/12/17
- master 6e4417eaa7e 14/19: Consolidate status-prefix slots of erc-channel-user, F. Jason Park, 2023/12/17
- master 7db500b50be 09/19: Make erc-get-user-mode-prefix more flexible,
F. Jason Park <=
- master 9d961b31070 13/19: Demote erc-fill-line-spacing to a normal variable, F. Jason Park, 2023/12/17
- master c1befaf0a8b 10/19: Skip erc-ignored-user-p when erc-ignore-list is empty, F. Jason Park, 2023/12/17
- master 236a416be76 11/19: Add erc--spkr text property to chat messages, F. Jason Park, 2023/12/17
- master 951b115c2ac 06/19: Make erc-input's refoldp slot conditionally available, F. Jason Park, 2023/12/17
- master 08ec3e89793 15/19: Rename erc-channel-users to erc-channel-members, F. Jason Park, 2023/12/17
- master 8e06f224a9e 19/19: Add erc-track integration to erc-nicks, F. Jason Park, 2023/12/17
- master 9d889af0d68 17/19: Promote "normal" faces in erc-track, F. Jason Park, 2023/12/17