mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-21 06:55:39 +00:00
Use helper to get erc-networks--id symbol as string
* lisp/erc/erc-networks.el (erc-networks--id-string): New function. (erc-networks--construct-target-buffer-name) (erc-networks--ensure-unique-server-buffer-name) (erc-networks--rename-server-buffer): Use it. * lisp/erc/erc-nicks.el (erc-nicks-list-faces): Use it. * lisp/erc/erc-status-sidebar.el (erc-status-sidebar-pad-hierarchy): Use it. * lisp/erc/erc.el (erc-generate-new-buffer-name) (erc-log-irc-protocol) (erc--auth-source-determine-params-defaults) (erc-format-target-and/or-network): Use it. * test/lisp/erc/erc-networks-tests.el (erc-networks--id-string): New test.
This commit is contained in:
parent
d25689d6e2
commit
7fc048ca77
@ -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)))
|
||||
|
@ -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)
|
||||
|
@ -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"))
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)))
|
||||
|
Loading…
Reference in New Issue
Block a user