aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorF. Jason Park2023-10-15 13:20:07 -0700
committerF. Jason Park2023-10-20 15:24:06 -0700
commitf109396fe362d3bc556efe2a7315169c74724d63 (patch)
tree6ee93a4db6f7d0491456209925ee0f23aa6c77af
parent8cf66ab1e5ff253d72368901490f073634e1ae4b (diff)
downloademacs-f109396fe362d3bc556efe2a7315169c74724d63.tar.gz
emacs-f109396fe362d3bc556efe2a7315169c74724d63.zip
Prefer erc-target to erc-default-target
* etc/ERC-NEWS: Mention `erc-target' and new `erc-server-buffer-p' alias. * lisp/erc/erc-backend.el (erc-process-sentinel): Set `joined-p' slot of `erc--target-channel' object to nil when applicable. (erc-server-JOIN): Mark `erc--target-channel' object as being joined. * lisp/erc/erc-common.el (erc--target-channel): Add `joined-p' slot. Use hyphenated name so accessor function's name ends in "joined-p" rather than "joinedp". Note that this will always be nil when disconnected. (erc--target): Relocate here from erc.el. (erc-target): New public API function to return the current buffer's target as a string, even in channels that have been unjoined. * lisp/erc/erc-networks.el (erc--default-target): Remove forward declaration. (erc-networks--id-reload): Use `erc-target' instead of `erc--default-target' as predicate for visiting target buffers. * lisp/erc/erc.el (erc-remove-channel-users): Set channel "joinedness" to nil in `erc--target-channel' object, when applicable. (erc--target): Move to erc-common. (erc--default-target): Remove, replaced by new function `erc-target'. (erc-query-buffer-p): Use `erc-target'. (erc-after-connect): Revise doc string. (erc-connection-established): Revise doc string and move `erc-unhide-query-prompt' business before hook. (erc--current-buffer-joined-p): Remove comment and use new `joined-p' slot of `erc--target-channel' for determining "joinedness" of channel. (erc-kill-buffer-function): Use `erc--target-channel-p' for detecting whether the buffer is a channel buffer. * test/lisp/erc/erc-networks-tests.el (erc-networks--shrink-ids-and-buffer-names--hook-collapse-target): Remove comment. * test/lisp/erc/erc-scenarios-base-reuse-buffers.el (erc-scenarios-common--base-reuse-buffers-channel-buffers): Clarify assertion. * test/lisp/erc/erc-tests.el (erc-with-all-buffers-of-server): Replace `erc-default-recipients' with `erc--target'. (erc--target-from-string): Update expected shape of `erc--target-channel' struct with new `joined-p' slot. (erc-message): Set `erc--target' in buffer "#chan". (Bug#66578)
-rw-r--r--etc/ERC-NEWS18
-rw-r--r--lisp/erc/erc-backend.el5
-rw-r--r--lisp/erc/erc-common.el22
-rw-r--r--lisp/erc/erc-networks.el12
-rw-r--r--lisp/erc/erc.el65
-rw-r--r--test/lisp/erc/erc-networks-tests.el5
-rw-r--r--test/lisp/erc/erc-scenarios-base-reuse-buffers.el2
-rw-r--r--test/lisp/erc/erc-tests.el19
8 files changed, 72 insertions, 76 deletions
diff --git a/etc/ERC-NEWS b/etc/ERC-NEWS
index e47c42a51a6..41ab9cc4c5e 100644
--- a/etc/ERC-NEWS
+++ b/etc/ERC-NEWS
@@ -425,6 +425,24 @@ use of 'insert-before-markers' instead of 'insert'. As always, users
425feeling unduly inconvenienced by these changes are encouraged to voice 425feeling unduly inconvenienced by these changes are encouraged to voice
426their concerns on the bug list. 426their concerns on the bug list.
427 427
428*** Introducing new ways to detect ERC buffer types.
429The old standby 'erc-default-target' has served ERC well for over two
430decades. But a lesser known gotcha affecting its use has always
431haunted an unlucky few, that is, the function has always returned
432non-nil in "unjoined" channel buffers (those that the client has
433parted with or been kicked from). While perhaps not itself a major
434footgun, recessive pitfalls rooted in this subtlety continue to affect
435dependent functions, like 'erc-get-buffer'.
436
437To discourage misuse of 'erc-default-target', ERC 5.6 offers an
438alternative in the function 'erc-target', which is identical to the
439former except for its disregard for "joinedness." As a related bonus,
440the dependent function 'erc-server-buffer-p' is being rebranded as
441'erc-server-or-unjoined-channel-buffer-p'. Unfortunately, this
442release lacks a similar solution for detecting "joinedness" directly,
443but users can turn to 'xor'-ing 'erc-default-target' and 'erc-target'
444as a makeshift kludge.
445
428*** Miscellaneous changes 446*** Miscellaneous changes
429Two helper macros from GNU ELPA's Compat library are now available to 447Two helper macros from GNU ELPA's Compat library are now available to
430third-party modules as 'erc-compat-call' and 'erc-compat-function'. 448third-party modules as 'erc-compat-call' and 'erc-compat-function'.
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index d3094b0b955..4b5edaa77d2 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -1103,7 +1103,7 @@ Change value of property `erc-prompt' from t to `hidden'."
1103 (erc--register-connection) 1103 (erc--register-connection)
1104 ;; assume event is 'failed 1104 ;; assume event is 'failed
1105 (erc-with-all-buffers-of-server cproc nil 1105 (erc-with-all-buffers-of-server cproc nil
1106 (setq erc-server-connected nil)) 1106 (setq erc-server-connected nil))
1107 (when erc-server-ping-handler 1107 (when erc-server-ping-handler
1108 (progn (cancel-timer erc-server-ping-handler) 1108 (progn (cancel-timer erc-server-ping-handler)
1109 (setq erc-server-ping-handler nil))) 1109 (setq erc-server-ping-handler nil)))
@@ -1111,6 +1111,8 @@ Change value of property `erc-prompt' from t to `hidden'."
1111 (erc-current-nick) (system-name) "") 1111 (erc-current-nick) (system-name) "")
1112 (dolist (buf (erc-buffer-filter (lambda () (boundp 'erc-channel-users)) cproc)) 1112 (dolist (buf (erc-buffer-filter (lambda () (boundp 'erc-channel-users)) cproc))
1113 (with-current-buffer buf 1113 (with-current-buffer buf
1114 (when (erc--target-channel-p erc--target)
1115 (setf (erc--target-channel-joined-p erc--target) nil))
1114 (setq erc-channel-users (make-hash-table :test 'equal)))) 1116 (setq erc-channel-users (make-hash-table :test 'equal))))
1115 ;; Hide the prompt 1117 ;; Hide the prompt
1116 (erc--hide-prompt cproc) 1118 (erc--hide-prompt cproc)
@@ -1731,6 +1733,7 @@ add things to `%s' instead."
1731 (with-suppressed-warnings 1733 (with-suppressed-warnings
1732 ((obsolete erc-add-default-channel)) 1734 ((obsolete erc-add-default-channel))
1733 (erc-add-default-channel chnl)) 1735 (erc-add-default-channel chnl))
1736 (setf (erc--target-channel-joined-p erc--target) t)
1734 (erc-server-send (format "MODE %s" chnl))) 1737 (erc-server-send (format "MODE %s" chnl)))
1735 (erc-with-buffer (chnl proc) 1738 (erc-with-buffer (chnl proc)
1736 (erc-channel-begin-receiving-names)) 1739 (erc-channel-begin-receiving-names))
diff --git a/lisp/erc/erc-common.el b/lisp/erc/erc-common.el
index 8d896e663b5..930e8032f6d 100644
--- a/lisp/erc/erc-common.el
+++ b/lisp/erc/erc-common.el
@@ -81,16 +81,13 @@
81 (string "" :type string :documentation "Received name of target.") 81 (string "" :type string :documentation "Received name of target.")
82 (symbol nil :type symbol :documentation "Case-mapped name as symbol.")) 82 (symbol nil :type symbol :documentation "Case-mapped name as symbol."))
83 83
84;; At some point, it may make sense to add a query type with an 84;; At some point, it may make sense to add a separate query type,
85;; account field, which may help support reassociation across 85;; possibly with an account field to help reassociation across
86;; reconnects and nick changes (likely requires v3 extensions). 86;; reconnects and nick changes.
87;; 87
88;; These channel variants should probably take on a `joined' field to 88(cl-defstruct (erc--target-channel (:include erc--target))
89;; track "joinedness", which `erc-server-JOIN', `erc-server-PART', 89 (joined-p nil :type boolean :documentation "Whether channel is joined."))
90;; etc. should toggle. Functions like `erc--current-buffer-joined-p'
91;; may find it useful.
92 90
93(cl-defstruct (erc--target-channel (:include erc--target)))
94(cl-defstruct (erc--target-channel-local (:include erc--target-channel))) 91(cl-defstruct (erc--target-channel-local (:include erc--target-channel)))
95 92
96;; Beginning in 5.5/29.1, the `tags' field may take on one of two 93;; Beginning in 5.5/29.1, the `tags' field may take on one of two
@@ -427,6 +424,13 @@ nil."
427 ,@forms)) 424 ,@forms))
428 ,process))) 425 ,process)))
429 426
427(defvar-local erc--target nil
428 "A permanent `erc--target' struct instance in channel and query buffers.")
429
430(define-inline erc-target ()
431 "Return target of current buffer, if any, as a string."
432 (inline-quote (and erc--target (erc--target-string erc--target))))
433
430(defun erc-log-aux (string) 434(defun erc-log-aux (string)
431 "Do the debug logging of STRING." 435 "Do the debug logging of STRING."
432 (let ((cb (current-buffer)) 436 (let ((cb (current-buffer))
diff --git a/lisp/erc/erc-networks.el b/lisp/erc/erc-networks.el
index d73d715db2c..dd047243a3c 100644
--- a/lisp/erc/erc-networks.el
+++ b/lisp/erc/erc-networks.el
@@ -53,7 +53,6 @@
53(defvar erc-server-process) 53(defvar erc-server-process)
54(defvar erc-session-server) 54(defvar erc-session-server)
55 55
56(declare-function erc--default-target "erc" nil)
57(declare-function erc--get-isupport-entry "erc-backend" (key &optional single)) 56(declare-function erc--get-isupport-entry "erc-backend" (key &optional single))
58(declare-function erc-buffer-filter "erc" (predicate &optional proc)) 57(declare-function erc-buffer-filter "erc" (predicate &optional proc))
59(declare-function erc-current-nick "erc" nil) 58(declare-function erc-current-nick "erc" nil)
@@ -991,12 +990,11 @@ object."
991 (erc-networks--id-qualifying-len nid)) 990 (erc-networks--id-qualifying-len nid))
992 (erc-networks--rename-server-buffer (or proc erc-server-process) parsed) 991 (erc-networks--rename-server-buffer (or proc erc-server-process) parsed)
993 (erc-networks--shrink-ids-and-buffer-names-any) 992 (erc-networks--shrink-ids-and-buffer-names-any)
994 (erc-with-all-buffers-of-server 993 (erc-with-all-buffers-of-server erc-server-process #'erc-target
995 erc-server-process #'erc--default-target 994 (when-let
996 (when-let* ((new-name (erc-networks--reconcile-buffer-names erc--target 995 ((new-name (erc-networks--reconcile-buffer-names erc--target nid))
997 nid)) 996 ((not (equal (buffer-name) new-name))))
998 ((not (equal (buffer-name) new-name)))) 997 (rename-buffer new-name 'unique))))
999 (rename-buffer new-name 'unique))))
1000 998
1001(cl-defgeneric erc-networks--id-ensure-comparable (self other) 999(cl-defgeneric erc-networks--id-ensure-comparable (self other)
1002 "Take measures to ensure two net identities are in comparable states.") 1000 "Take measures to ensure two net identities are in comparable states.")
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 877478690af..7d75ec49ccd 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -534,6 +534,8 @@ See also: `erc-remove-server-user' and
534 534
535Removes all users in the current channel. This is called by 535Removes all users in the current channel. This is called by
536`erc-server-PART' and `erc-server-QUIT'." 536`erc-server-PART' and `erc-server-QUIT'."
537 (when (erc--target-channel-p erc--target)
538 (setf (erc--target-channel-joined-p erc--target) nil))
537 (when (and erc-server-connected 539 (when (and erc-server-connected
538 (erc-server-process-alive) 540 (erc-server-process-alive)
539 (hash-table-p erc-channel-users)) 541 (hash-table-p erc-channel-users))
@@ -1391,16 +1393,6 @@ buffer during local-module setup and `erc-mode-hook' activation.")
1391 #'make-erc--target) 1393 #'make-erc--target)
1392 :string string :symbol (intern (erc-downcase string)))) 1394 :string string :symbol (intern (erc-downcase string))))
1393 1395
1394(defvar-local erc--target nil
1395 "Info about a buffer's target, if any.")
1396
1397;; Temporary internal getter to ease transition to `erc--target'
1398;; everywhere. Will be replaced by updated `erc-default-target'.
1399(defun erc--default-target ()
1400 "Return target string or nil."
1401 (when erc--target
1402 (erc--target-string erc--target)))
1403
1404(defun erc-once-with-server-event (event f) 1396(defun erc-once-with-server-event (event f)
1405 "Run function F the next time EVENT occurs in the `current-buffer'. 1397 "Run function F the next time EVENT occurs in the `current-buffer'.
1406 1398
@@ -1504,7 +1496,7 @@ If BUFFER is nil, the current buffer is used."
1504 "Return non-nil if BUFFER is an ERC query buffer. 1496 "Return non-nil if BUFFER is an ERC query buffer.
1505If BUFFER is nil, the current buffer is used." 1497If BUFFER is nil, the current buffer is used."
1506 (with-current-buffer (or buffer (current-buffer)) 1498 (with-current-buffer (or buffer (current-buffer))
1507 (let ((target (erc-default-target))) 1499 (let ((target (erc-target)))
1508 (and (eq major-mode 'erc-mode) 1500 (and (eq major-mode 'erc-mode)
1509 target 1501 target
1510 (not (memq (aref target 0) '(?# ?& ?+ ?!))))))) 1502 (not (memq (aref target 0) '(?# ?& ?+ ?!)))))))
@@ -2492,10 +2484,13 @@ in here get called with three parameters, SERVER, PORT and NICK."
2492 :type '(repeat function)) 2484 :type '(repeat function))
2493 2485
2494(defcustom erc-after-connect nil 2486(defcustom erc-after-connect nil
2495 "Functions called after connecting to a server. 2487 "Abnormal hook run upon establishing a logical IRC connection.
2496This functions in this variable gets executed when an end of MOTD 2488Runs on MOTD's end when `erc-server-connected' becomes non-nil.
2497has been received. All functions in here get called with the 2489ERC calls members with `erc-server-announced-name', falling back
2498parameters SERVER and NICK." 2490to the 376/422 message's \"sender\", as well as the current nick,
2491as given by the 376/422 message's \"target\" parameter, which is
2492typically the same as that reported by `erc-current-nick'."
2493 :package-version '(ERC . "5.6") ; FIXME sync on release
2499 :group 'erc-hooks 2494 :group 'erc-hooks
2500 :type '(repeat function)) 2495 :type '(repeat function))
2501 2496
@@ -5749,9 +5744,7 @@ See also: `erc-echo-notice-in-user-buffers',
5749 (erc-load-script f))))) 5744 (erc-load-script f)))))
5750 5745
5751(defun erc-connection-established (proc parsed) 5746(defun erc-connection-established (proc parsed)
5752 "Run just after connection. 5747 "Set user mode and run `erc-after-connect' hook in server buffer."
5753
5754Set user modes and run `erc-after-connect' hook."
5755 (with-current-buffer (process-buffer proc) 5748 (with-current-buffer (process-buffer proc)
5756 (unless erc-server-connected ; only once per session 5749 (unless erc-server-connected ; only once per session
5757 (let ((server (or erc-server-announced-name 5750 (let ((server (or erc-server-announced-name
@@ -5770,14 +5763,11 @@ Set user modes and run `erc-after-connect' hook."
5770 (erc-update-mode-line) 5763 (erc-update-mode-line)
5771 (erc-set-initial-user-mode nick buffer) 5764 (erc-set-initial-user-mode nick buffer)
5772 (erc-server-setup-periodical-ping buffer) 5765 (erc-server-setup-periodical-ping buffer)
5773 (run-hook-with-args 'erc-after-connect server nick)))) 5766 (when erc-unhide-query-prompt
5774 5767 (erc-with-all-buffers-of-server erc-server-process nil
5775 (when erc-unhide-query-prompt 5768 (when (and erc--target (not (erc--target-channel-p erc--target)))
5776 (erc-with-all-buffers-of-server proc 5769 (erc--unhide-prompt))))
5777 nil ; FIXME use `erc--target' after bug#48598 5770 (run-hook-with-args 'erc-after-connect server nick)))))
5778 (when (and (erc-default-target)
5779 (not (erc-channel-p (car erc-default-recipients))))
5780 (erc--unhide-prompt)))))
5781 5771
5782(defun erc-set-initial-user-mode (nick buffer) 5772(defun erc-set-initial-user-mode (nick buffer)
5783 "If `erc-user-mode' is non-nil for NICK, set the user modes. 5773 "If `erc-user-mode' is non-nil for NICK, set the user modes.
@@ -7065,25 +7055,11 @@ See also `erc-downcase'."
7065;; default target handling 7055;; default target handling
7066 7056
7067(defun erc--current-buffer-joined-p () 7057(defun erc--current-buffer-joined-p ()
7068 "Return whether the current target buffer is joined." 7058 "Return non-nil if the current buffer is a channel and is joined."
7069 ;; This may be a reliable means of detecting subscription status,
7070 ;; but it's also roundabout and awkward. Perhaps it's worth
7071 ;; discussing adding a joined slot to `erc--target' for this.
7072 (cl-assert erc--target) 7059 (cl-assert erc--target)
7073 (and (erc--target-channel-p erc--target) 7060 (and (erc--target-channel-p erc--target)
7074 (erc-get-channel-user (erc-current-nick)) t)) 7061 (erc--target-channel-joined-p erc--target)
7075 7062 t))
7076;; While `erc-default-target' happens to return nil in channel buffers
7077;; you've parted or from which you've been kicked, using it to detect
7078;; whether a channel is currently joined may become unreliable in the
7079;; future. For now, third-party code can use
7080;;
7081;; (erc-get-channel-user (erc-current-nick))
7082;;
7083;; A predicate may be provided eventually. For retrieving a target's
7084;; name regardless of subscription or connection status, new library
7085;; code should use `erc--default-target'. Third-party code should
7086;; continue to use `erc-default-target'.
7087 7063
7088(defun erc-default-target () 7064(defun erc-default-target ()
7089 "Return the current channel or query target, if any. 7065 "Return the current channel or query target, if any.
@@ -8315,6 +8291,7 @@ See also `kill-buffer'."
8315 :group 'erc-hooks 8291 :group 'erc-hooks
8316 :type 'hook) 8292 :type 'hook)
8317 8293
8294;; FIXME alias and deprecate current *-function suffixed name.
8318(defun erc-kill-buffer-function () 8295(defun erc-kill-buffer-function ()
8319 "Function to call when an ERC buffer is killed. 8296 "Function to call when an ERC buffer is killed.
8320This function should be on `kill-buffer-hook'. 8297This function should be on `kill-buffer-hook'.
@@ -8328,7 +8305,7 @@ or `erc-kill-buffer-hook' if any other buffer."
8328 (cond 8305 (cond
8329 ((eq (erc-server-buffer) (current-buffer)) 8306 ((eq (erc-server-buffer) (current-buffer))
8330 (run-hooks 'erc-kill-server-hook)) 8307 (run-hooks 'erc-kill-server-hook))
8331 ((erc-channel-p (or (erc-default-target) (buffer-name))) 8308 ((erc--target-channel-p erc--target)
8332 (run-hooks 'erc-kill-channel-hook)) 8309 (run-hooks 'erc-kill-channel-hook))
8333 (t 8310 (t
8334 (run-hooks 'erc-kill-buffer-hook))))) 8311 (run-hooks 'erc-kill-buffer-hook)))))
diff --git a/test/lisp/erc/erc-networks-tests.el b/test/lisp/erc/erc-networks-tests.el
index 45ef0d10a6e..d0f1dddf6b3 100644
--- a/test/lisp/erc/erc-networks-tests.el
+++ b/test/lisp/erc/erc-networks-tests.el
@@ -623,11 +623,6 @@
623 :symbol 'foonet/dummy 623 :symbol 'foonet/dummy
624 :parts [foonet "dummy"] 624 :parts [foonet "dummy"]
625 :len 2) 625 :len 2)
626 ;; `erc-kill-buffer-function' uses legacy target detection
627 ;; but falls back on buffer name, so no need for:
628 ;;
629 ;; erc-default-recipients '("#a")
630 ;;
631 erc--target (erc--target-from-string "#a") 626 erc--target (erc--target-from-string "#a")
632 erc-server-process (with-temp-buffer 627 erc-server-process (with-temp-buffer
633 (erc-networks-tests--create-dead-proc))) 628 (erc-networks-tests--create-dead-proc)))
diff --git a/test/lisp/erc/erc-scenarios-base-reuse-buffers.el b/test/lisp/erc/erc-scenarios-base-reuse-buffers.el
index 71027a0c138..af483bb1a52 100644
--- a/test/lisp/erc/erc-scenarios-base-reuse-buffers.el
+++ b/test/lisp/erc/erc-scenarios-base-reuse-buffers.el
@@ -124,6 +124,7 @@ Adapted from scenario clash-of-chans/uniquify described in Bug#48598:
124 (erc-d-t-search-for 1 "shake my sword") 124 (erc-d-t-search-for 1 "shake my sword")
125 (erc-cmd-PART "#chan") 125 (erc-cmd-PART "#chan")
126 (funcall expect 3 "You have left channel #chan") 126 (funcall expect 3 "You have left channel #chan")
127 (should-not (erc-get-channel-user (erc-current-nick)))
127 (erc-cmd-JOIN "#chan"))) 128 (erc-cmd-JOIN "#chan")))
128 129
129 (ert-info ("Part #chan@barnet") 130 (ert-info ("Part #chan@barnet")
@@ -139,6 +140,7 @@ Adapted from scenario clash-of-chans/uniquify described in Bug#48598:
139 (get-buffer "#chan/127.0.0.1<3>")) 140 (get-buffer "#chan/127.0.0.1<3>"))
140 141
141 (ert-info ("Activity continues in new, <n>-suffixed #chan@foonet buffer") 142 (ert-info ("Activity continues in new, <n>-suffixed #chan@foonet buffer")
143 ;; The first /JOIN did not cause the same buffer to be reused.
142 (with-current-buffer "#chan/127.0.0.1" 144 (with-current-buffer "#chan/127.0.0.1"
143 (should-not (erc-get-channel-user (erc-current-nick)))) 145 (should-not (erc-get-channel-user (erc-current-nick))))
144 (with-current-buffer "#chan/127.0.0.1<3>" 146 (with-current-buffer "#chan/127.0.0.1<3>"
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index 02dfc55b6d5..4d2f880b46f 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -69,26 +69,25 @@
69 (with-current-buffer (get-buffer-create "#foo") 69 (with-current-buffer (get-buffer-create "#foo")
70 (erc-mode) 70 (erc-mode)
71 (setq erc-server-process proc-exnet) 71 (setq erc-server-process proc-exnet)
72 (setq erc-default-recipients '("#foo"))) 72 (setq erc--target (erc--target-from-string "#foo")))
73 73
74 (with-current-buffer (get-buffer-create "#spam") 74 (with-current-buffer (get-buffer-create "#spam")
75 (erc-mode) 75 (erc-mode)
76 (setq erc-server-process proc-onet) 76 (setq erc-server-process proc-onet)
77 (setq erc-default-recipients '("#spam"))) 77 (setq erc--target (erc--target-from-string "#spam")))
78 78
79 (with-current-buffer (get-buffer-create "#bar") 79 (with-current-buffer (get-buffer-create "#bar")
80 (erc-mode) 80 (erc-mode)
81 (setq erc-server-process proc-onet) 81 (setq erc-server-process proc-onet)
82 (setq erc-default-recipients '("#bar"))) 82 (setq erc--target (erc--target-from-string "#bar")))
83 83
84 (with-current-buffer (get-buffer-create "#baz") 84 (with-current-buffer (get-buffer-create "#baz")
85 (erc-mode) 85 (erc-mode)
86 (setq erc-server-process proc-exnet) 86 (setq erc-server-process proc-exnet)
87 (setq erc-default-recipients '("#baz"))) 87 (setq erc--target (erc--target-from-string "#baz")))
88 88
89 (should (eq (get-buffer-process "ExampleNet") proc-exnet)) 89 (should (eq (get-buffer-process "ExampleNet") proc-exnet))
90 (erc-with-all-buffers-of-server (get-buffer-process "ExampleNet") 90 (erc-with-all-buffers-of-server (get-buffer-process "ExampleNet") nil
91 nil
92 (kill-buffer)) 91 (kill-buffer))
93 92
94 (should-not (get-buffer "ExampleNet")) 93 (should-not (get-buffer "ExampleNet"))
@@ -102,8 +101,7 @@
102 (calls 0) 101 (calls 0)
103 (get-test (lambda () (cl-incf calls) test))) 102 (get-test (lambda () (cl-incf calls) test)))
104 103
105 (erc-with-all-buffers-of-server proc-onet 104 (erc-with-all-buffers-of-server proc-onet (funcall get-test)
106 (funcall get-test)
107 (kill-buffer)) 105 (kill-buffer))
108 106
109 (should (= calls 1))) 107 (should (= calls 1)))
@@ -812,7 +810,7 @@
812 810
813(ert-deftest erc--target-from-string () 811(ert-deftest erc--target-from-string ()
814 (should (equal (erc--target-from-string "#chan") 812 (should (equal (erc--target-from-string "#chan")
815 #s(erc--target-channel "#chan" \#chan))) 813 #s(erc--target-channel "#chan" \#chan nil)))
816 814
817 (should (equal (erc--target-from-string "Bob") 815 (should (equal (erc--target-from-string "Bob")
818 #s(erc--target "Bob" bob))) 816 #s(erc--target "Bob" bob)))
@@ -820,7 +818,7 @@
820 (let ((erc--isupport-params (make-hash-table))) 818 (let ((erc--isupport-params (make-hash-table)))
821 (puthash 'CHANTYPES '("&#") erc--isupport-params) 819 (puthash 'CHANTYPES '("&#") erc--isupport-params)
822 (should (equal (erc--target-from-string "&Bitlbee") 820 (should (equal (erc--target-from-string "&Bitlbee")
823 #s(erc--target-channel-local "&Bitlbee" &bitlbee))))) 821 #s(erc--target-channel-local "&Bitlbee" &bitlbee nil)))))
824 822
825(ert-deftest erc--modify-local-map () 823(ert-deftest erc--modify-local-map ()
826 (when (and (bound-and-true-p erc-irccontrols-mode) 824 (when (and (bound-and-true-p erc-irccontrols-mode)
@@ -1846,6 +1844,7 @@
1846 (erc-mode) 1844 (erc-mode)
1847 (setq erc-server-process (buffer-local-value 'erc-server-process 1845 (setq erc-server-process (buffer-local-value 'erc-server-process
1848 (get-buffer "ExampleNet")) 1846 (get-buffer "ExampleNet"))
1847 erc--target (erc--target-from-string "#chan")
1849 erc-default-recipients '("#chan") 1848 erc-default-recipients '("#chan")
1850 erc-channel-users (make-hash-table :test 'equal) 1849 erc-channel-users (make-hash-table :test 'equal)
1851 erc-network 'ExampleNet) 1850 erc-network 'ExampleNet)