diff --git a/lisp/erc/erc-networks.el b/lisp/erc/erc-networks.el index 75de68a284c..d1e4a0238a1 100644 --- a/lisp/erc/erc-networks.el +++ b/lisp/erc/erc-networks.el @@ -831,6 +831,10 @@ respectively. The separator is given by `erc-networks--id-sep'." (len 0 :type integer :documentation "Length of active `parts' interval.")) +(define-inline erc-networks--id-string (id) + "Return the symbol for `erc-networks--id' ID as a string." + (inline-quote (symbol-name (erc-networks--id-symbol ,id)))) + ;; For now, please use this instead of `erc-networks--id-fixed-p'. (cl-defgeneric erc-networks--id-given (net-id) "Return the preassigned identifier for a network context, if any. @@ -1159,10 +1163,10 @@ TARGET to be an `erc--target' object." ((not (with-suppressed-warnings ((obsolete erc-reuse-buffers)) erc-reuse-buffers)) (cadr (split-string - (symbol-name (erc-networks--id-symbol erc-networks--id)) + (erc-networks--id-string erc-networks--id) "/"))) ((erc--target-channel-local-p target) erc-server-announced-name) - (t (symbol-name (erc-networks--id-symbol erc-networks--id)))))) + (t (erc-networks--id-string erc-networks--id))))) (defun erc-networks--ensure-unique-target-buffer-name () (when-let* ((new-name (erc-networks--construct-target-buffer-name @@ -1171,8 +1175,7 @@ TARGET to be an `erc--target' object." (rename-buffer new-name 'unique))) (defun erc-networks--ensure-unique-server-buffer-name () - (when-let* ((new-name (symbol-name (erc-networks--id-symbol - erc-networks--id))) + (when-let* ((new-name (erc-networks--id-string erc-networks--id)) ((not (equal (buffer-name) new-name)))) (rename-buffer new-name 'unique))) @@ -1489,7 +1492,7 @@ to be a false alarm. If `erc-reuse-buffers' is nil, let ;; buffer may have been deleted. (erc-networks--reclaim-orphaned-target-buffers new-proc erc-networks--id erc-server-announced-name) - (let* ((name (symbol-name (erc-networks--id-symbol erc-networks--id))) + (let* ((name (erc-networks--id-string erc-networks--id)) ;; When this ends up being the current buffer, either we have ;; a "given" ID or the buffer was reused on reconnecting. (existing (get-buffer name))) diff --git a/lisp/erc/erc-nicks.el b/lisp/erc/erc-nicks.el index e2cbe613d99..6d4f8c596fc 100644 --- a/lisp/erc/erc-nicks.el +++ b/lisp/erc/erc-nicks.el @@ -659,7 +659,7 @@ Abandon search after examining LIMIT faces." (progn (delete-region (pos-bol) (1+ (pos-eol))) (forward-line -1)) (when-let* ((nid (get face 'erc-nicks--netid)) - (net (symbol-name (erc-networks--id-symbol nid)))) + (net (erc-networks--id-string nid))) (goto-char (button-end (point))) (skip-syntax-forward "-") (put-text-property (point) (1+ (point)) 'rear-nonsticky nil) diff --git a/lisp/erc/erc-status-sidebar.el b/lisp/erc/erc-status-sidebar.el index bf049242443..bb11ade221d 100644 --- a/lisp/erc/erc-status-sidebar.el +++ b/lisp/erc/erc-status-sidebar.el @@ -390,8 +390,8 @@ focused window." (next (cadr (member buffer buflist))) ((buffer-live-p next)) (proc (buffer-local-value 'erc-server-process next)) - (id (process-get proc 'erc-networks--id))) - (symbol-name (erc-networks--id-symbol id))) + (id (process-get proc 'erc-networks--id)) + ((erc-networks--id-string id)))) "???") "\n")) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 18cc4071b48..7028d0a68cc 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -2060,8 +2060,7 @@ same manner." (if (and (with-suppressed-warnings ((obsolete erc-reuse-buffers)) erc-reuse-buffers) id) - (let ((string (symbol-name (erc-networks--id-symbol - (erc-networks--id-create id))))) + (let ((string (erc-networks--id-string (erc-networks--id-create id)))) (when-let* ((buf (get-buffer string)) ((erc-server-process-alive buf))) (user-error "Session with ID %S already exists" string)) @@ -3063,9 +3062,8 @@ such inconsistent labeling may pose a problem until the MOTD is received. Setting a fixed `erc-networks--id' can serve as a workaround." (when erc-debug-irc-protocol - (let ((esid (if-let* ((erc-networks--id) - (esid (erc-networks--id-symbol erc-networks--id))) - (symbol-name esid) + (let ((esid (if erc-networks--id + (erc-networks--id-string erc-networks--id) (or erc-server-announced-name (format "%s:%s" erc-session-server erc-session-port)))) (ts (when erc-debug-irc-protocol-time-format @@ -4669,9 +4667,8 @@ node `(erc) auth-source'." function)) (defun erc--auth-source-determine-params-defaults () - (let* ((net (and-let* ((erc-networks--id) - (esid (erc-networks--id-symbol erc-networks--id)) - ((symbol-name esid))))) + (let* ((net (and erc-networks--id + (erc-networks--id-string erc-networks--id))) (localp (and erc--target (erc--target-channel-local-p erc--target))) (hosts (if localp (list erc-server-announced-name erc-session-server net) @@ -9188,9 +9185,8 @@ This should be a string with substitution variables recognized by If the name of the network is not available, then use the shortened server name instead." (if-let* ((erc--target) - (name (if-let* ((erc-networks--id) - (esid (erc-networks--id-symbol erc-networks--id))) - (symbol-name esid) + (name (if erc-networks--id + (erc-networks--id-string erc-networks--id) (erc-shorten-server-name (or erc-server-announced-name erc-session-server))))) (concat (erc--target-string erc--target) "@" name) diff --git a/test/lisp/erc/erc-networks-tests.el b/test/lisp/erc/erc-networks-tests.el index e84cca68cdd..02c90f28c6c 100644 --- a/test/lisp/erc/erc-networks-tests.el +++ b/test/lisp/erc/erc-networks-tests.el @@ -76,6 +76,14 @@ :symbol 'fake.chat))))) (kill-buffer)))) +(ert-deftest erc-networks--id-string () + (should (equal (erc-networks--id-string (erc-networks--id-fixed-create 'foo)) + "foo")) + (should (equal (let* ((erc-network 'FooNet) + (erc-server-current-nick "Joe")) ; needs letstar + (erc-networks--id-string (erc-networks--id-create nil))) + "FooNet"))) + (ert-deftest erc-networks--id-create () (cl-letf (((symbol-function 'float-time) (lambda (&optional _) 0.0)))