aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorF. Jason Park2023-10-04 20:39:03 -0700
committerF. Jason Park2023-10-13 07:47:01 -0700
commit9c2f99b7d7325149c6926fa7ccc4e84fa7a695f6 (patch)
tree1ddbed8ac293f88a5d58c0e9273255e373697a99
parent1950ddebacb73fdc17ebec4da24d74b628c3e0ae (diff)
downloademacs-9c2f99b7d7325149c6926fa7ccc4e84fa7a695f6.tar.gz
emacs-9c2f99b7d7325149c6926fa7ccc4e84fa7a695f6.zip
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'.
-rw-r--r--lisp/erc/erc-backend.el12
-rw-r--r--lisp/erc/erc.el48
2 files changed, 22 insertions, 38 deletions
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 2fb140f57ce..3d34fc97d00 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -164,7 +164,6 @@
164(declare-function erc-is-message-ctcp-p "erc" (message)) 164(declare-function erc-is-message-ctcp-p "erc" (message))
165(declare-function erc-log-irc-protocol "erc" (string &optional outbound)) 165(declare-function erc-log-irc-protocol "erc" (string &optional outbound))
166(declare-function erc-login "erc" nil) 166(declare-function erc-login "erc" nil)
167(declare-function erc-make-notice "erc" (message))
168(declare-function erc-network "erc-networks" nil) 167(declare-function erc-network "erc-networks" nil)
169(declare-function erc-networks--id-given "erc-networks" (arg &rest args)) 168(declare-function erc-networks--id-given "erc-networks" (arg &rest args))
170(declare-function erc-networks--id-reload "erc-networks" (arg &rest args)) 169(declare-function erc-networks--id-reload "erc-networks" (arg &rest args))
@@ -1718,7 +1717,7 @@ add things to `%s' instead."
1718 (if (string-match "^\\(.*\\)\^g.*$" chnl) 1717 (if (string-match "^\\(.*\\)\^g.*$" chnl)
1719 (setq chnl (match-string 1 chnl))) 1718 (setq chnl (match-string 1 chnl)))
1720 (save-excursion 1719 (save-excursion
1721 (let* ((str (cond 1720 (let ((args (cond
1722 ;; If I have joined a channel 1721 ;; If I have joined a channel
1723 ((erc-current-nick-p nick) 1722 ((erc-current-nick-p nick)
1724 (let ((erc--display-context 1723 (let ((erc--display-context
@@ -1735,18 +1734,15 @@ add things to `%s' instead."
1735 (erc-channel-begin-receiving-names)) 1734 (erc-channel-begin-receiving-names))
1736 (erc-update-mode-line) 1735 (erc-update-mode-line)
1737 (run-hooks 'erc-join-hook) 1736 (run-hooks 'erc-join-hook)
1738 (erc-make-notice 1737 (list 'JOIN-you ?c chnl))
1739 (erc-format-message 'JOIN-you ?c chnl)))
1740 (t 1738 (t
1741 (setq buffer (erc-get-buffer chnl proc)) 1739 (setq buffer (erc-get-buffer chnl proc))
1742 (erc-make-notice 1740 (list 'JOIN ?n nick ?u login ?h host ?c chnl)))))
1743 (erc-format-message
1744 'JOIN ?n nick ?u login ?h host ?c chnl))))))
1745 (when buffer (set-buffer buffer)) 1741 (when buffer (set-buffer buffer))
1746 (erc-update-channel-member chnl nick nick t nil nil nil nil nil host login) 1742 (erc-update-channel-member chnl nick nick t nil nil nil nil nil host login)
1747 ;; on join, we want to stay in the new channel buffer 1743 ;; on join, we want to stay in the new channel buffer
1748 ;;(set-buffer ob) 1744 ;;(set-buffer ob)
1749 (erc-display-message parsed nil buffer str)))))) 1745 (apply #'erc-display-message parsed 'notice buffer args))))))
1750 1746
1751(define-erc-response-handler (KICK) 1747(define-erc-response-handler (KICK)
1752 "Handle kick messages received from the server." nil 1748 "Handle kick messages received from the server." nil
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 79b4544a3e4..60cce750355 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -3609,16 +3609,14 @@ If no USER argument is specified, list the contents of `erc-ignore-list'."
3609 (run-at-time timeout nil 3609 (run-at-time timeout nil
3610 (lambda () 3610 (lambda ()
3611 (erc--unignore-user user buffer)))) 3611 (erc--unignore-user user buffer))))
3612 (erc-display-line 3612 (erc-display-message nil 'notice 'active
3613 (erc-make-notice (format "Now ignoring %s" user)) 3613 (format "Now ignoring %s" user))
3614 'active)
3615 (erc-with-server-buffer (add-to-list 'erc-ignore-list user)))) 3614 (erc-with-server-buffer (add-to-list 'erc-ignore-list user))))
3616 (if (null (erc-with-server-buffer erc-ignore-list)) 3615 (if (null (erc-with-server-buffer erc-ignore-list))
3617 (erc-display-line (erc-make-notice "Ignore list is empty") 'active) 3616 (erc-display-message nil 'notice 'active "Ignore list is empty")
3618 (erc-display-line (erc-make-notice "Ignore list:") 'active) 3617 (erc-display-message nil 'notice 'active "Ignore list:")
3619 (mapc (lambda (item) 3618 (mapc (lambda (item)
3620 (erc-display-line (erc-make-notice item) 3619 (erc-display-message nil 'notice 'active item))
3621 'active))
3622 (erc-with-server-buffer erc-ignore-list)))) 3620 (erc-with-server-buffer erc-ignore-list))))
3623 t) 3621 t)
3624 3622
@@ -3632,9 +3630,8 @@ If no USER argument is specified, list the contents of `erc-ignore-list'."
3632 (unless (y-or-n-p (format "Remove this regexp (%s)? " 3630 (unless (y-or-n-p (format "Remove this regexp (%s)? "
3633 ignored-nick)) 3631 ignored-nick))
3634 (setq ignored-nick nil)) 3632 (setq ignored-nick nil))
3635 (erc-display-line 3633 (erc-display-message nil 'notice 'active
3636 (erc-make-notice (format "%s is not currently ignored!" user)) 3634 (format "%s is not currently ignored!" user))))
3637 'active)))
3638 (when ignored-nick 3635 (when ignored-nick
3639 (erc--unignore-user user (current-buffer)))) 3636 (erc--unignore-user user (current-buffer))))
3640 t) 3637 t)
@@ -3642,9 +3639,8 @@ If no USER argument is specified, list the contents of `erc-ignore-list'."
3642(defun erc--unignore-user (user buffer) 3639(defun erc--unignore-user (user buffer)
3643 (when (buffer-live-p buffer) 3640 (when (buffer-live-p buffer)
3644 (with-current-buffer buffer 3641 (with-current-buffer buffer
3645 (erc-display-line 3642 (erc-display-message nil 'notice 'active
3646 (erc-make-notice (format "No longer ignoring %s" user)) 3643 (format "No longer ignoring %s" user))
3647 'active)
3648 (erc-with-server-buffer 3644 (erc-with-server-buffer
3649 (setq erc-ignore-list (delete user erc-ignore-list)))))) 3645 (setq erc-ignore-list (delete user erc-ignore-list))))))
3650 3646
@@ -4129,12 +4125,10 @@ See `erc-cmd-WHOIS' for more details."
4129 (string-to-number 4125 (string-to-number
4130 (cl-third 4126 (cl-third
4131 (erc-response.command-args parsed))))) 4127 (erc-response.command-args parsed)))))
4132 (erc-display-line 4128 (erc-display-message nil 'notice origbuf
4133 (erc-make-notice
4134 (format "%s has been idle for %s." 4129 (format "%s has been idle for %s."
4135 (erc-string-no-properties nick) 4130 (erc-string-no-properties nick)
4136 (erc-seconds-to-string idleseconds))) 4131 (erc-seconds-to-string idleseconds)))
4137 origbuf)
4138 t))) 4132 t)))
4139 'erc-server-317-functions) 4133 'erc-server-317-functions)
4140 symlist) 4134 symlist)
@@ -4683,8 +4677,7 @@ The ban list is fetched from the server if necessary."
4683 4677
4684 (cond 4678 (cond
4685 ((not (erc-channel-p chnl)) 4679 ((not (erc-channel-p chnl))
4686 (erc-display-line (erc-make-notice "You're not on a channel\n") 4680 (erc-display-message nil 'notice 'active "You're not on a channel\n"))
4687 'active))
4688 4681
4689 ((not (get 'erc-channel-banlist 'received-from-server)) 4682 ((not (get 'erc-channel-banlist 'received-from-server))
4690 (let ((old-367-hook erc-server-367-functions)) 4683 (let ((old-367-hook erc-server-367-functions))
@@ -4703,9 +4696,8 @@ The ban list is fetched from the server if necessary."
4703 (erc-server-send (format "MODE %s b" chnl))))) 4696 (erc-server-send (format "MODE %s b" chnl)))))
4704 4697
4705 ((null erc-channel-banlist) 4698 ((null erc-channel-banlist)
4706 (erc-display-line (erc-make-notice 4699 (erc-display-message nil 'notice 'active
4707 (format "No bans for channel: %s\n" chnl)) 4700 (format "No bans for channel: %s\n" chnl))
4708 'active)
4709 (put 'erc-channel-banlist 'received-from-server nil)) 4701 (put 'erc-channel-banlist 'received-from-server nil))
4710 4702
4711 (t 4703 (t
@@ -4719,10 +4711,9 @@ The ban list is fetched from the server if necessary."
4719 "%-" (number-to-string (/ erc-fill-column 2)) "s" 4711 "%-" (number-to-string (/ erc-fill-column 2)) "s"
4720 "%" (number-to-string (/ erc-fill-column 2)) "s"))) 4712 "%" (number-to-string (/ erc-fill-column 2)) "s")))
4721 4713
4722 (erc-display-line 4714 (erc-display-message
4723 (erc-make-notice (format "Ban list for channel: %s\n" 4715 nil 'notice 'active
4724 (erc-default-target))) 4716 (format "Ban list for channel: %s\n" (erc-default-target)))
4725 'active)
4726 4717
4727 (erc-display-line separator 'active) 4718 (erc-display-line separator 'active)
4728 (erc-display-line (format fmt "Ban Mask" "Banned By") 'active) 4719 (erc-display-line (format fmt "Ban Mask" "Banned By") 'active)
@@ -4739,8 +4730,7 @@ The ban list is fetched from the server if necessary."
4739 'active)) 4730 'active))
4740 erc-channel-banlist) 4731 erc-channel-banlist)
4741 4732
4742 (erc-display-line (erc-make-notice "End of Ban list") 4733 (erc-display-message nil 'notice 'active "End of Ban list")
4743 'active)
4744 (put 'erc-channel-banlist 'received-from-server nil))))) 4734 (put 'erc-channel-banlist 'received-from-server nil)))))
4745 t) 4735 t)
4746 4736
@@ -4754,9 +4744,7 @@ Unban all currently banned users in the current channel."
4754 (cond 4744 (cond
4755 4745
4756 ((not (erc-channel-p chnl)) 4746 ((not (erc-channel-p chnl))
4757 (erc-display-line 4747 (erc-display-message nil 'notice 'active "You're not on a channel\n"))
4758 (erc-make-notice "You're not on a channel\n")
4759 'active))
4760 4748
4761 ((not (get 'erc-channel-banlist 'received-from-server)) 4749 ((not (get 'erc-channel-banlist 'received-from-server))
4762 (let ((old-367-hook erc-server-367-functions)) 4750 (let ((old-367-hook erc-server-367-functions))