From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "J.P." Newsgroups: gmane.emacs.bugs Subject: bug#63595: 30.0.50; ERC 5.6: Add buffer-list and nick-list modules Date: Wed, 06 Dec 2023 23:26:07 -0800 Message-ID: <87v89a5v8w.fsf__26017.0096809574$1701934027$gmane$org@neverwas.me> References: <87lehkt97a.fsf@neverwas.me> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31117"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-erc@gnu.org To: 63595@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 07 08:27:00 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rB8mi-0007tz-IL for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 07 Dec 2023 08:27:00 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rB8mc-0001xd-Uy; Thu, 07 Dec 2023 02:26:54 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rB8mZ-0001xE-DQ for bug-gnu-emacs@gnu.org; Thu, 07 Dec 2023 02:26:51 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rB8mY-00020z-Bl for bug-gnu-emacs@gnu.org; Thu, 07 Dec 2023 02:26:51 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rB8mk-0006bt-GN for bug-gnu-emacs@gnu.org; Thu, 07 Dec 2023 02:27:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "J.P." Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Dec 2023 07:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63595 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 63595-submit@debbugs.gnu.org id=B63595.170193399025359 (code B ref 63595); Thu, 07 Dec 2023 07:27:02 +0000 Original-Received: (at 63595) by debbugs.gnu.org; 7 Dec 2023 07:26:30 +0000 Original-Received: from localhost ([127.0.0.1]:40935 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rB8mD-0006ax-NV for submit@debbugs.gnu.org; Thu, 07 Dec 2023 02:26:30 -0500 Original-Received: from mail-108-mta7.mxroute.com ([136.175.108.7]:42909) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rB8mA-0006am-U6 for 63595@debbugs.gnu.org; Thu, 07 Dec 2023 02:26:27 -0500 Original-Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta7.mxroute.com (ZoneMTA) with ESMTPSA id 18c432b773e000190b.001 for <63595@debbugs.gnu.org> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Thu, 07 Dec 2023 07:26:11 +0000 X-Zone-Loop: 65dd285c1b215e15455996d059da4c037764634d5ec2 X-Originating-IP: [136.175.111.2] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=neverwas.me ; s=x; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=06TC4u0+Z9VN1af5fHxEv8fSEwpf87kCI/GfNpwv1zI=; b=G2aAbV8HPqR70bg/WQJbh6RJwT liZKtgn+/8nTfoJfKTpS6+DXnMTJEPvo+ZK8tZb1Om68/ebkADWBo2BqrlmDg/U9qQ6Ozl9fYMHlW 5ZbOqB1rixwCleGwUyV2z8CK/PNyeTZhcygcMgu1Gy1xFVUSrK+j2B9zoASnGC00QYFe248IK5e4U TIYF6iGhzcH3D0+Boo539OOagCuLVWct676csL3cMDIIn2seSNS3UW4uph8x3AlLIfyM3ll9bKB1m wWzKyXf5kSERyj6R5gSabOy30yNAq7BearHOowLBWVA1wR0YoDmdhMNiNZfSQM3FDJ5tP25Ym651z 9ELYFJQQ==; In-Reply-To: <87lehkt97a.fsf@neverwas.me> (J. P.'s message of "Fri, 19 May 2023 12:25:29 -0700") X-Authenticated-Id: masked@neverwas.me X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:275652 Archived-At: --=-=-= Content-Type: text/plain One thing this feature left unaddressed was the inclusion of all available channel-membership prefixes in the "nickbar" (speedbar). Currently, only members with a "+" or "@" have their nicks augmented. Given the recent improvements to channel-mode parsing, it's now easier to offer the full slate of prefixes. See attached. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0009-5.6-Make-erc-get-user-mode-prefix-more-flexible.patch >From 401bc01ace91aac6f3423fc8a04fe7a95b67987c Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Mon, 27 Nov 2023 22:53:00 -0800 Subject: [PATCH 09/11] [5.6] Make erc-get-user-mode-prefix more flexible * 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 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): Use `channel-data' parameter. (erc-format-my-nick, erc--format-channel-status-prefix): Use new name for function `erc-get-user-mode-prefix'. (Bug#63595) --- 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 540d9e98751..4fdfe7a9dcb 100644 --- a/etc/ERC-NEWS +++ b/etc/ERC-NEWS @@ -433,6 +433,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 @@ erc-speedbar-insert-user (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 98621302abd..8e7162fec89 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -5815,21 +5815,31 @@ erc-format-nick 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 @@ -5838,7 +5848,7 @@ erc-format-@nick (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)))) @@ -5848,7 +5858,7 @@ erc-format-my-nick (let* ((open "<") (close "> ") (nick (erc-current-nick)) - (mode (erc-get-user-mode-prefix nick))) + (mode (erc-get-channel-membership-prefix nick))) (erc--ensure-spkr-prop nick) (concat (propertize open 'font-lock-face 'erc-default-face) @@ -8486,7 +8496,7 @@ erc--format-user-modes (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. -- 2.42.0 --=-=-=--