From: "J.P." <jp@neverwas.me>
To: 67677@debbugs.gnu.org
Cc: emacs-erc@gnu.org
Subject: bug#67677: 30.0.50; ERC 5.6: Use templates for formatting chat messages
Date: Mon, 18 Dec 2023 06:50:25 -0800 [thread overview]
Message-ID: <87v88vftu6.fsf__41785.2453467035$1702911079$gmane$org@neverwas.me> (raw)
In-Reply-To: <87jzpq7apw.fsf@neverwas.me> (J. P.'s message of "Wed, 06 Dec 2023 23:06:35 -0800")
[-- Attachment #1: Type: text/plain, Size: 248 bytes --]
A version of these changes has been installed as
49bfea4386f * Use templates for formatting chat messages in ERC
Unfortunately, they included a somewhat glaring omission involving CTCP
replies that's hopefully addressed by the attached patch.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-5.6-Populate-erc-msg-prop-overrides-for-CTCP-replies.patch --]
[-- Type: text/x-patch, Size: 6037 bytes --]
From ad93b795ae3ed3f0b91acdf5806703e32b3ef074 Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <jp@neverwas.me>
Date: Sun, 17 Dec 2023 21:49:13 -0800
Subject: [PATCH] [5.6] Populate erc--msg-prop-overrides for CTCP replies
* lisp/erc/erc-backend.el (erc-server-PRIVMSG): Don't set string
intended for insertion to the undefined return value of
`erc-process-ctcp-reply' and `erc-process-ctcp-query'. Rework control
flow slightly for clarity.
* lisp/erc/erc.el (erc-process-ctcp-reply): Bind
`erc--msg-prop-overrides' and populate with `erc--ctcp' and `erc--cmd'
"msg props" for the benefit of `erc-display-message' calls made by
CTCP reply handlers. (Bug#67677)
---
lisp/erc/erc-backend.el | 53 +++++++++++++++++++----------------------
lisp/erc/erc.el | 10 ++++++--
2 files changed, 32 insertions(+), 31 deletions(-)
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 0c336540483..6d30409e156 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -1996,8 +1996,8 @@ erc--speaker-status-prefix-wanted-p
(erc--msg-prop-overrides `((erc--tmp) ,@erc--msg-prop-overrides))
(erc--speaker-status-prefix-wanted-p nil)
(erc-current-message-catalog erc--message-speaker-catalog)
- s buffer statusmsg cmem-prefix
- fnick)
+ ;;
+ buffer statusmsg cmem-prefix fnick)
(setq buffer (erc-get-buffer (if privp nick tgt) proc))
;; Even worth checking for empty target here? (invalid anyway)
(unless (or buffer noticep (string-empty-p tgt) (eq ?$ (aref tgt 0))
@@ -2042,36 +2042,31 @@ erc--speaker-status-prefix-wanted-p
erc-show-speaker-membership-status
inputp)
(cdr cdata))))))
- (cond
- ((erc-is-message-ctcp-p msg)
- ;; FIXME explain undefined return values being assigned to `s'.
- (setq s (if-let ((parsed
- (erc--ctcp-response-from-parsed
- :parsed parsed :buffer buffer :statusmsg statusmsg
- :prefix cmem-prefix :dispname fnick))
- (msgp))
- (erc-process-ctcp-query proc parsed nick login host)
- (erc-process-ctcp-reply proc parsed nick login host
- (match-string 1 msg)))))
- (t
+ (if (erc-is-message-ctcp-p msg)
+ (if noticep
+ (erc-process-ctcp-reply proc parsed nick login host
+ (match-string 1 msg))
+ (setq parsed (erc--ctcp-response-from-parsed
+ :parsed parsed :buffer buffer :statusmsg statusmsg
+ :prefix cmem-prefix :dispname fnick))
+ (erc-process-ctcp-query proc parsed nick login host))
(setq erc-server-last-peers (cons nick (cdr erc-server-last-peers)))
(with-current-buffer (or buffer (current-buffer))
;; Re-bind in case either buffer has a local value.
- (let ((erc-current-message-catalog erc--message-speaker-catalog))
- (setq s (erc--determine-speaker-message-format-args
- nick msg privp msgp inputp statusmsg
- cmem-prefix fnick))))))
- (when s
- (if (and noticep privp)
- (progn
- (push (cons 'erc--msg (car s)) erc--msg-prop-overrides)
- (setq s (apply #'erc-format-message s))
- (run-hook-with-args 'erc-echo-notice-always-hook
- s parsed buffer nick)
- (run-hook-with-args-until-success
- 'erc-echo-notice-hook s parsed buffer nick))
- (apply #'erc-display-message parsed nil buffer
- (ensure-list s))))))))
+ (let ((erc-current-message-catalog erc--message-speaker-catalog)
+ (msg-args (erc--determine-speaker-message-format-args
+ nick msg privp msgp inputp statusmsg
+ cmem-prefix fnick)))
+ (if (or msgp (not privp))
+ ;; This is a PRIVMSG or a NOTICE to a channel.
+ (apply #'erc-display-message parsed nil buffer msg-args)
+ ;; This is a NOTICE directed at the client's current nick.
+ (push (cons 'erc--msg (car msg-args)) erc--msg-prop-overrides)
+ (let ((fmtmsg (apply #'erc-format-message msg-args)))
+ (run-hook-with-args 'erc-echo-notice-always-hook
+ fmtmsg parsed buffer nick)
+ (run-hook-with-args-until-success
+ 'erc-echo-notice-hook fmtmsg parsed buffer nick))))))))))
(define-erc-response-handler (QUIT)
"Another user has quit IRC." nil
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index faa2cbefd1b..37e47591d73 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -6525,8 +6525,14 @@ erc-ctcp-query-VERSION
(defun erc-process-ctcp-reply (proc parsed nick login host msg)
"Process MSG as a CTCP reply."
(let* ((type (car (split-string msg)))
- (hook (intern (concat "erc-ctcp-reply-" type "-hook"))))
- (if (boundp hook)
+ (hook (intern-soft (concat "erc-ctcp-reply-" type "-hook")))
+ ;; Help `erc-display-message' by ensuring subsequent
+ ;; insertions retain the necessary props.
+ (cmd (erc--get-eq-comparable-cmd (erc-response.command parsed)))
+ (erc--msg-prop-overrides `((erc--ctcp . ,(and hook (intern type)))
+ (erc--cmd . ,cmd)
+ ,@erc--msg-prop-overrides)))
+ (if (and hook (boundp hook))
(run-hook-with-args-until-success
hook proc nick login host
(car (erc-response.command-args parsed)) msg)
--
2.42.0
next parent reply other threads:[~2023-12-18 14:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87jzpq7apw.fsf@neverwas.me>
2023-12-18 14:50 ` J.P. [this message]
[not found] ` <87v88vftu6.fsf@neverwas.me>
2024-01-08 5:46 ` bug#67677: 30.0.50; ERC 5.6: Use templates for formatting chat messages J.P.
2024-01-12 16:19 ` J.P.
[not found] ` <87a5paa5j0.fsf@neverwas.me>
2024-01-19 2:16 ` J.P.
[not found] ` <87fryurrst.fsf@neverwas.me>
2024-02-01 3:14 ` J.P.
2023-12-07 7:06 J.P.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='87v88vftu6.fsf__41785.2453467035$1702911079$gmane$org@neverwas.me' \
--to=jp@neverwas.me \
--cc=67677@debbugs.gnu.org \
--cc=emacs-erc@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).