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 the various CTCP reply handlers. (Bug#67677)
This commit is contained in:
parent
717f917d1d
commit
23d692ed01
2 changed files with 32 additions and 31 deletions
|
@ -1996,8 +1996,8 @@ like `erc-insert-modify-hook'.")
|
|||
(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 @@ like `erc-insert-modify-hook'.")
|
|||
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
|
||||
|
|
|
@ -6528,8 +6528,14 @@ See also `erc-display-message'."
|
|||
(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)
|
||||
|
|
Loading…
Add table
Reference in a new issue