1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Use erc-display-message instead of erc-make-notice

* lisp/erc/erc-backend.el (erc-server-JOIN): Let `erc-display-message'
handle formatting instead of baking out a string.  The text ultimately
inserted remains unchanged, but forwarding the original `format-spec'
arguments now has the side effect of influencing text properties, which
conveys richer meaning for modules to act upon when doing things like
deciding whether to hide a given message.
* lisp/erc/erc.el (erc-cmd-IGNORE, erc-cmd-UNIGNORE,
erc--unignore-user, erc-cmd-IDLE, erc-cmd-BANLIST, erc-cmd-MASSUNBAN):
Use `erc-display-message' with `notice' for the TYPE parameter instead
of composing `erc-make-notice' and `erc-display-line'.
This commit is contained in:
F. Jason Park 2023-10-04 20:39:03 -07:00
parent 1950ddebac
commit 9c2f99b7d7
2 changed files with 22 additions and 38 deletions

View file

@ -164,7 +164,6 @@
(declare-function erc-is-message-ctcp-p "erc" (message))
(declare-function erc-log-irc-protocol "erc" (string &optional outbound))
(declare-function erc-login "erc" nil)
(declare-function erc-make-notice "erc" (message))
(declare-function erc-network "erc-networks" nil)
(declare-function erc-networks--id-given "erc-networks" (arg &rest args))
(declare-function erc-networks--id-reload "erc-networks" (arg &rest args))
@ -1718,7 +1717,7 @@ add things to `%s' instead."
(if (string-match "^\\(.*\\)\^g.*$" chnl)
(setq chnl (match-string 1 chnl)))
(save-excursion
(let* ((str (cond
(let ((args (cond
;; If I have joined a channel
((erc-current-nick-p nick)
(let ((erc--display-context
@ -1735,18 +1734,15 @@ add things to `%s' instead."
(erc-channel-begin-receiving-names))
(erc-update-mode-line)
(run-hooks 'erc-join-hook)
(erc-make-notice
(erc-format-message 'JOIN-you ?c chnl)))
(list 'JOIN-you ?c chnl))
(t
(setq buffer (erc-get-buffer chnl proc))
(erc-make-notice
(erc-format-message
'JOIN ?n nick ?u login ?h host ?c chnl))))))
(list 'JOIN ?n nick ?u login ?h host ?c chnl)))))
(when buffer (set-buffer buffer))
(erc-update-channel-member chnl nick nick t nil nil nil nil nil host login)
;; on join, we want to stay in the new channel buffer
;;(set-buffer ob)
(erc-display-message parsed nil buffer str))))))
(apply #'erc-display-message parsed 'notice buffer args))))))
(define-erc-response-handler (KICK)
"Handle kick messages received from the server." nil

View file

@ -3609,16 +3609,14 @@ If no USER argument is specified, list the contents of `erc-ignore-list'."
(run-at-time timeout nil
(lambda ()
(erc--unignore-user user buffer))))
(erc-display-line
(erc-make-notice (format "Now ignoring %s" user))
'active)
(erc-display-message nil 'notice 'active
(format "Now ignoring %s" user))
(erc-with-server-buffer (add-to-list 'erc-ignore-list user))))
(if (null (erc-with-server-buffer erc-ignore-list))
(erc-display-line (erc-make-notice "Ignore list is empty") 'active)
(erc-display-line (erc-make-notice "Ignore list:") 'active)
(erc-display-message nil 'notice 'active "Ignore list is empty")
(erc-display-message nil 'notice 'active "Ignore list:")
(mapc (lambda (item)
(erc-display-line (erc-make-notice item)
'active))
(erc-display-message nil 'notice 'active item))
(erc-with-server-buffer erc-ignore-list))))
t)
@ -3632,9 +3630,8 @@ If no USER argument is specified, list the contents of `erc-ignore-list'."
(unless (y-or-n-p (format "Remove this regexp (%s)? "
ignored-nick))
(setq ignored-nick nil))
(erc-display-line
(erc-make-notice (format "%s is not currently ignored!" user))
'active)))
(erc-display-message nil 'notice 'active
(format "%s is not currently ignored!" user))))
(when ignored-nick
(erc--unignore-user user (current-buffer))))
t)
@ -3642,9 +3639,8 @@ If no USER argument is specified, list the contents of `erc-ignore-list'."
(defun erc--unignore-user (user buffer)
(when (buffer-live-p buffer)
(with-current-buffer buffer
(erc-display-line
(erc-make-notice (format "No longer ignoring %s" user))
'active)
(erc-display-message nil 'notice 'active
(format "No longer ignoring %s" user))
(erc-with-server-buffer
(setq erc-ignore-list (delete user erc-ignore-list))))))
@ -4129,12 +4125,10 @@ See `erc-cmd-WHOIS' for more details."
(string-to-number
(cl-third
(erc-response.command-args parsed)))))
(erc-display-line
(erc-make-notice
(erc-display-message nil 'notice origbuf
(format "%s has been idle for %s."
(erc-string-no-properties nick)
(erc-seconds-to-string idleseconds)))
origbuf)
t)))
'erc-server-317-functions)
symlist)
@ -4683,8 +4677,7 @@ The ban list is fetched from the server if necessary."
(cond
((not (erc-channel-p chnl))
(erc-display-line (erc-make-notice "You're not on a channel\n")
'active))
(erc-display-message nil 'notice 'active "You're not on a channel\n"))
((not (get 'erc-channel-banlist 'received-from-server))
(let ((old-367-hook erc-server-367-functions))
@ -4703,9 +4696,8 @@ The ban list is fetched from the server if necessary."
(erc-server-send (format "MODE %s b" chnl)))))
((null erc-channel-banlist)
(erc-display-line (erc-make-notice
(format "No bans for channel: %s\n" chnl))
'active)
(erc-display-message nil 'notice 'active
(format "No bans for channel: %s\n" chnl))
(put 'erc-channel-banlist 'received-from-server nil))
(t
@ -4719,10 +4711,9 @@ The ban list is fetched from the server if necessary."
"%-" (number-to-string (/ erc-fill-column 2)) "s"
"%" (number-to-string (/ erc-fill-column 2)) "s")))
(erc-display-line
(erc-make-notice (format "Ban list for channel: %s\n"
(erc-default-target)))
'active)
(erc-display-message
nil 'notice 'active
(format "Ban list for channel: %s\n" (erc-default-target)))
(erc-display-line separator 'active)
(erc-display-line (format fmt "Ban Mask" "Banned By") 'active)
@ -4739,8 +4730,7 @@ The ban list is fetched from the server if necessary."
'active))
erc-channel-banlist)
(erc-display-line (erc-make-notice "End of Ban list")
'active)
(erc-display-message nil 'notice 'active "End of Ban list")
(put 'erc-channel-banlist 'received-from-server nil)))))
t)
@ -4754,9 +4744,7 @@ Unban all currently banned users in the current channel."
(cond
((not (erc-channel-p chnl))
(erc-display-line
(erc-make-notice "You're not on a channel\n")
'active))
(erc-display-message nil 'notice 'active "You're not on a channel\n"))
((not (get 'erc-channel-banlist 'received-from-server))
(let ((old-367-hook erc-server-367-functions))