diff options
| author | F. Jason Park | 2021-05-03 05:54:56 -0700 |
|---|---|---|
| committer | F. Jason Park | 2022-06-30 15:03:26 -0700 |
| commit | 752e860db4800a26599c4cd6ca2c39ab1909b425 (patch) | |
| tree | 8a2dfd5e98c8bfdda3375e5fe9145a4f7eaa8ee1 /lisp/erc/erc.el | |
| parent | 9be08ceb314888c7f86bddbec6490e7ead718a88 (diff) | |
| download | emacs-752e860db4800a26599c4cd6ca2c39ab1909b425.tar.gz emacs-752e860db4800a26599c4cd6ca2c39ab1909b425.zip | |
Address long-standing ERC buffer-naming issues
* lisp/erc/erc-backend.el (erc-server-connected): Revise doc string.
(erc-server-reconnect, erc-server-JOIN): Reuse original ID param from
the first connection when calling `erc-open'.
(erc-server-NICK): Apply same name generation process used by
`erc-open'; except here, do so for the purpose of "re-nicking".
Update network identifier and maybe buffer names after a user's own
nick changes.
* lisp/erc/erc-networks.el (erc-networks--id, erc-networks--id-fixed,
erc-networks--id-qualifying): Define new set of structs to contain all
info relevant to specifying a unique identifier for a network context.
Add a new variable `erc-networks--id' to store a local reference to a
`erc-networks--id' object, shared among all buffers in a logical
session.
(erc-networks--id-given, erc-networks--id-create,
erc-networks--id-on-connect, erc-networks--id--equal-p,
erc-networks--id-qualifying-init-parts,
erc-networks--id-qualifying-init-symbol,
erc-networks--id-qualifying-grow-id,
erc-networks--id-qualifying-reset-id,
erc-networks--id-qualifying-prefix-length,
erc-networks--id-qualifying-update, erc-networks--id-reload,
erc-networks--id-ensure-comparable, erc-networks--id-sort-buffers):
Add new functions to support management of `erc-networks--id' struct
instances.
(erc-networks--id-sep): New variable for to help when formatting
buffer names.
(erc-obsolete-var): Define new generic context rewriter.
(erc-networks-shrink-ids-and-buffer-names,
erc-networks--refresh-buffer-names,
erc-networks--shrink-ids-and-buffer-names-any): Add functions to
reassess all network IDs and shrink them if necessary along with
affected buffer names. Also add function to rename buffers so that
their names are unique. Register these on all three of ERC's
kill-buffer hooks because an orphaned target buffer is enough to keep
its session alive.
(erc-networks-rename-surviving-target-buffer): Add new function that
renames a target buffer when it becomes the sole bearer of a name
based on a target that has become unique across all sessions and, in
most cases, all networks. IOW, remove the @NETWORK-ID suffix from the
last remaining channel or query buffer after its namesakes have all
been killed off. Register this function with ERC's target-related
kill-buffer hooks.
(erc-networks--examine-targets): Add new utility function that visits
all ERC buffers and runs callbacks when a buffer-name collision is
encountered.
(erc-networks--qualified-sep): Add constant to hold separator between
target and suffix.
(erc-networks--construct-target-buffer-name,
erc-networks--ensure-unique-target-buffer-name,
erc-networks--ensure-unique-server-buffer-name,
erc-networks--maybe-update-buffer-name): Add helpers to support
`erc-networks--reconcile-buffer-names' and friends.
(erc-networks--reconcile-buffer-names): Add new buffer-naming strategy
function and helper for `erc-generate-new-buffer-name' that only run
in target buffers.
(erc-determine-network, erc-networks--determine): Deprecate former and
partially replace with latter, which demotes RPL_ISUPPORT-derived
NETWORK name to fallback in favor of known `erc-networks-alist'
members as part of shift to network-based connection-identity policy.
Return sentinel on failure. Expect `erc-server-announced-name' to be
set, and signal when it's not.
(erc-networks--name-missing-sentinel): Value returned when new
function `erc-networks--determine' fails to find network name. The
rationale for not making this customizable is that the value signifies
the pathological case where a user of an uncommon IRC setup has not
yet set a mapping from announced- to network name. And the chances of
there being multiple unknown networks is low.
(erc-set-network-name, erc-networks--set-name): Deprecate former and
partially replace with latter. Ding with helpful message, and don't
set `erc-network' when network name is not found.
(erc-networks--ensure-announced): Add new fallback function to ensure
`erc-server-announced-name' is set. Register with post-MOTD hooks.
(erc-unset-network-name): Deprecate function unused internally.
(erc-networks--insert-transplanted-content,
erc-networks--reclaim-orphaned-target-buffers,
erc-networks--copy-over-server-buffer-contents,
erc--update-server-identity): Add helpers for
`erc-networks--rename-server-buffer'. The first re-associates all
existing target buffers that ought to be owned by the new server
process. The second grabs buffer text from an old, dead server buffer
before killing it. It then inserts that text above everything in the
current, replacement server buffer. The other two massage the IDs of
related sessions, possibly renaming them as well. They may also
uniquify the current session's network ID.
(erc-networks--init-identity): Add new function to perform one-time
session-related setup. This could be combined with
`erc-set-network-name'.
(erc-networks--rename-server-buffer): Add new function to replace
`erc-unset-network-name' as default `erc-disconnected-hook' member;
renames server buffers once network is discovered; added to/removed
from `erc-after-connect' hook on `erc-networks' minor mode.
(erc-networks--bouncer-targets): Add constant to hold target symbols
of well known bouncer-configuration bots.
(erc-networks-on-MOTD-end): Add primary network-context handler to run
on 376/422 functions, just before logical connection is officially
established.
(erc-networks-enable, erc-networks-mode): Register main network-setup
handler with 376/422 hooks.
* lisp/erc/erc.el (erc-rename-buffers): Change this option's default
to t, remove the only instance where it's actually used, and make it
an obsolete variable.
(erc-reuse-buffers): Make this an obsolete variable, but take pains to
ensure its pre-28.1 behavior is preserved. That is, undo the
regression involving unwanted automatic reassociation of channel
buffers during joins, which arrived in ERC 5.4 and effectively
inverted the meaning of this variable, when nil, for channel buffers,
all without accompanying documentation or announcement.
(erc-generate-new-buffer-name): Replace current policy of appending a
slash and the invocation host name. Favor instead temporary names for
server buffers and network-based uniquifying suffixes for channels and
query buffers. Fall back to the TCP host:port<n> convention when
necessary. Accept additional optional params after the others.
(erc-get-buffer-create): Don't generate a new name when reconnecting,
just return the same buffer. `erc-open' starts from a clean slate
anyway, so this just keeps things simple. Also add optional params.
(erc-open): Add new ID param to for a network identifier explicitly
passed to an entry-point command. This is stored in the `given' slot
of the `erc-network--id' object. Also initialize the latter in new
connections and otherwise copy it over. As part of the push to recast
erc-networks.el as an essential library, set `erc-network' explicitly,
when known, rather than via hooks.
(erc, erc-tls): Add new ID keyword parameter and pass it to
`erc-open'.
(erc-log-irc-protocol): Use `erc--network-id' instead of the function
`erc-network' to determine preferred peer name.
(erc-format-target-and/or-network): This is called frequently from
mode-line updates, so renaming buffers here is not ideal. Instead, do
so in `erc-networks--rename-server-buffer'.
(erc-kill-server-hook): Add `erc-networks-shrink-ids-and-buffer-names'
as default member.
(erc-kill-channel-hook, erc-kill-buffer-hook): Add
`erc-networks-shrink-ids-and-buffer-names' and
`erc-networks-rename-surviving-target-buffer' as default member.
* test/lisp/erc/erc-tests.el (erc-log-irc-protocol): Use network-ID
focused internal API.
* test/lisp/erc/erc-networks-tests.el: Add new file that includes
tests for the above network-ID focused functions.
See bug#48598 for background on all of the above.
Diffstat (limited to 'lisp/erc/erc.el')
| -rw-r--r-- | lisp/erc/erc.el | 239 |
1 files changed, 151 insertions, 88 deletions
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 9f17816b8d4..18a353ae494 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el | |||
| @@ -134,6 +134,8 @@ | |||
| 134 | (defvar erc--server-last-reconnect-count) | 134 | (defvar erc--server-last-reconnect-count) |
| 135 | (defvar erc--server-reconnecting) | 135 | (defvar erc--server-reconnecting) |
| 136 | (defvar erc-channel-members-changed-hook) | 136 | (defvar erc-channel-members-changed-hook) |
| 137 | (defvar erc-network) | ||
| 138 | (defvar erc-networks--id) | ||
| 137 | (defvar erc-server-367-functions) | 139 | (defvar erc-server-367-functions) |
| 138 | (defvar erc-server-announced-name) | 140 | (defvar erc-server-announced-name) |
| 139 | (defvar erc-server-connect-function) | 141 | (defvar erc-server-connect-function) |
| @@ -210,12 +212,21 @@ parameters and authentication." | |||
| 210 | :set (lambda (sym val) | 212 | :set (lambda (sym val) |
| 211 | (set sym (if (functionp val) (funcall val) val)))) | 213 | (set sym (if (functionp val) (funcall val) val)))) |
| 212 | 214 | ||
| 213 | (defcustom erc-rename-buffers nil | 215 | (defcustom erc-rename-buffers t |
| 214 | "Non-nil means rename buffers with network name, if available." | 216 | "Non-nil means rename buffers with network name, if available." |
| 215 | :version "24.5" | 217 | :version "24.5" |
| 216 | :group 'erc | 218 | :group 'erc |
| 217 | :type 'boolean) | 219 | :type 'boolean) |
| 218 | 220 | ||
| 221 | ;; For the sake of compatibility, an ID will be created on the user's | ||
| 222 | ;; behalf when `erc-rename-buffers' is nil and one wasn't provided. | ||
| 223 | ;; The name will simply be that of the buffer, usually SERVER:PORT. | ||
| 224 | ;; This violates the policy of treating provided IDs as gospel, but | ||
| 225 | ;; it'll have to do for now. | ||
| 226 | |||
| 227 | (make-obsolete-variable 'erc-rename-buffers | ||
| 228 | "old behavior when t now permanent" "29.1") | ||
| 229 | |||
| 219 | (defvar erc-password nil | 230 | (defvar erc-password nil |
| 220 | "Password to use when authenticating to an IRC server. | 231 | "Password to use when authenticating to an IRC server. |
| 221 | It is not strictly necessary to provide this, since ERC will | 232 | It is not strictly necessary to provide this, since ERC will |
| @@ -1660,6 +1671,14 @@ effect when `erc-join-buffer' is set to `frame'." | |||
| 1660 | (erc-channel-p (erc-default-target)))) | 1671 | (erc-channel-p (erc-default-target)))) |
| 1661 | (t nil))) | 1672 | (t nil))) |
| 1662 | 1673 | ||
| 1674 | ;; For the sake of compatibility, a historical quirk concerning this | ||
| 1675 | ;; option, when nil, has been preserved: all buffers are suffixed with | ||
| 1676 | ;; the original dialed host name, which is usually something like | ||
| 1677 | ;; irc.libera.chat. Collisions are handled by adding a uniquifying | ||
| 1678 | ;; numeric suffix of the form <N>. Note that channel reassociation | ||
| 1679 | ;; behavior involving this option (when nil) was inverted in 28.1 (ERC | ||
| 1680 | ;; 5.4 and 5.4.1). This was regrettable and has since been undone. | ||
| 1681 | |||
| 1663 | (defcustom erc-reuse-buffers t | 1682 | (defcustom erc-reuse-buffers t |
| 1664 | "If nil, create new buffers on joining a channel/query. | 1683 | "If nil, create new buffers on joining a channel/query. |
| 1665 | If non-nil, a new buffer will only be created when you join | 1684 | If non-nil, a new buffer will only be created when you join |
| @@ -1669,6 +1688,9 @@ the existing buffers will be reused." | |||
| 1669 | :group 'erc-buffers | 1688 | :group 'erc-buffers |
| 1670 | :type 'boolean) | 1689 | :type 'boolean) |
| 1671 | 1690 | ||
| 1691 | (make-obsolete-variable 'erc-reuse-buffers | ||
| 1692 | "old behavior when t now permanent" "29.1") | ||
| 1693 | |||
| 1672 | (defun erc-normalize-port (port) | 1694 | (defun erc-normalize-port (port) |
| 1673 | "Normalize the port specification PORT to integer form. | 1695 | "Normalize the port specification PORT to integer form. |
| 1674 | PORT may be an integer, a string or a symbol. If it is a string or a | 1696 | PORT may be an integer, a string or a symbol. If it is a string or a |
| @@ -1704,55 +1726,61 @@ symbol, it may have these values: | |||
| 1704 | "Check whether ports A and B are equal." | 1726 | "Check whether ports A and B are equal." |
| 1705 | (= (erc-normalize-port a) (erc-normalize-port b))) | 1727 | (= (erc-normalize-port a) (erc-normalize-port b))) |
| 1706 | 1728 | ||
| 1707 | (defun erc-generate-new-buffer-name (server port target) | 1729 | (defun erc-generate-new-buffer-name (server port target &optional tgt-info id) |
| 1708 | "Create a new buffer name based on the arguments." | 1730 | "Determine the name of an ERC buffer. |
| 1709 | (when (numberp port) (setq port (number-to-string port))) | 1731 | When TGT-INFO is nil, assume this is a server buffer. If ID is non-nil, |
| 1710 | (let* ((buf-name (or target | 1732 | return ID as a string unless a buffer already exists with a live server |
| 1711 | (let ((name (concat server ":" port))) | 1733 | process, in which case signal an error. When ID is nil, return a |
| 1712 | (when (> (length name) 1) | 1734 | temporary name based on SERVER and PORT to be replaced with the network |
| 1713 | name)) | 1735 | name when discovered (see `erc-networks--rename-server-buffer'). Allow |
| 1714 | ;; This fallback should in fact never happen. | 1736 | either SERVER or PORT (but not both) to be nil to accommodate oddball |
| 1715 | "*erc-server-buffer*")) | 1737 | `erc-server-connect-function's. |
| 1716 | (full-buf-name (concat buf-name "/" server)) | 1738 | |
| 1717 | (dup-buf-name (buffer-name (car (erc-channel-list nil)))) | 1739 | When TGT-INFO is non-nil, expect its string field to match the redundant |
| 1718 | buffer-name) | 1740 | param TARGET (retained for compatibility). Whenever possibly, prefer |
| 1719 | ;; Reuse existing buffers, but not if the buffer is a connected server | 1741 | returning TGT-INFO's string unmodified. But when a case-insensitive |
| 1720 | ;; buffer and not if its associated with a different server than the | 1742 | collision prevents that, return target@ID when ID is non-nil or |
| 1721 | ;; current ERC buffer. | 1743 | target@network otherwise after renaming the conflicting buffer in the |
| 1722 | ;; If buf-name is taken by a different connection (or by something !erc) | 1744 | same manner." |
| 1723 | ;; then see if "buf-name/server" meets the same criteria. | 1745 | (when target ; compat |
| 1724 | (if (and dup-buf-name (string-match-p (concat buf-name "/") dup-buf-name)) | 1746 | (setq tgt-info (erc--target-from-string target))) |
| 1725 | (setq buffer-name full-buf-name) ; ERC buffer with full name already exists. | 1747 | (if tgt-info |
| 1726 | (dolist (candidate (list buf-name full-buf-name)) | 1748 | (let* ((esid (erc-networks--id-symbol erc-networks--id)) |
| 1727 | (if (and (not buffer-name) | 1749 | (name (if esid |
| 1728 | erc-reuse-buffers | 1750 | (erc-networks--reconcile-buffer-names tgt-info |
| 1729 | (or (not (get-buffer candidate)) | 1751 | erc-networks--id) |
| 1730 | ;; Looking for a server buffer, so there's no target. | 1752 | (erc--target-string tgt-info)))) |
| 1731 | (and (not target) | 1753 | (if (and esid (with-suppressed-warnings ((obsolete erc-reuse-buffers)) |
| 1732 | (with-current-buffer (get-buffer candidate) | 1754 | erc-reuse-buffers)) |
| 1733 | (and (erc-server-buffer-p) | 1755 | name |
| 1734 | (not (erc-server-process-alive))))) | 1756 | (generate-new-buffer-name name))) |
| 1735 | ;; Channel buffer; check that it's from the right server. | 1757 | (if (and (with-suppressed-warnings ((obsolete erc-reuse-buffers)) |
| 1736 | (and target | 1758 | erc-reuse-buffers) |
| 1737 | (with-current-buffer (get-buffer candidate) | 1759 | id) |
| 1738 | (and (string= erc-session-server server) | 1760 | (progn |
| 1739 | (erc-port-equal erc-session-port port)))))) | 1761 | (when-let* ((buf (get-buffer (symbol-name id))) |
| 1740 | (setq buffer-name candidate) | 1762 | ((erc-server-process-alive buf))) |
| 1741 | (when (and (not buffer-name) (get-buffer buf-name) erc-reuse-buffers) | 1763 | (user-error "Session with ID %S already exists" id)) |
| 1742 | ;; A new buffer will be created with the name buf-name/server, rename | 1764 | (symbol-name id)) |
| 1743 | ;; the existing name-duplicated buffer with the same format as well. | 1765 | (generate-new-buffer-name (if (and server port) |
| 1744 | (with-current-buffer (get-buffer buf-name) | 1766 | (if (with-suppressed-warnings |
| 1745 | (when (derived-mode-p 'erc-mode) ; ensure it's an erc buffer | 1767 | ((obsolete erc-reuse-buffers)) |
| 1746 | (rename-buffer | 1768 | erc-reuse-buffers) |
| 1747 | (concat buf-name "/" (or erc-session-server erc-server-announced-name))))))))) | 1769 | (format "%s:%s" server port) |
| 1748 | ;; If buffer-name is unset, neither candidate worked out for us, | 1770 | (format "%s:%s/%s" server port server)) |
| 1749 | ;; fallback to the old <N> uniquification method: | 1771 | (or server port)))))) |
| 1750 | (or buffer-name (generate-new-buffer-name full-buf-name)))) | 1772 | |
| 1751 | 1773 | (defun erc-get-buffer-create (server port target &optional tgt-info id) | |
| 1752 | (defun erc-get-buffer-create (server port target) | ||
| 1753 | "Create a new buffer based on the arguments." | 1774 | "Create a new buffer based on the arguments." |
| 1754 | (get-buffer-create (erc-generate-new-buffer-name server port target))) | 1775 | (when target ; compat |
| 1755 | 1776 | (setq tgt-info (erc--target-from-string target))) | |
| 1777 | (if (and erc--server-reconnecting | ||
| 1778 | (not tgt-info) | ||
| 1779 | (with-suppressed-warnings ((obsolete erc-reuse-buffers)) | ||
| 1780 | erc-reuse-buffers)) | ||
| 1781 | (current-buffer) | ||
| 1782 | (get-buffer-create | ||
| 1783 | (erc-generate-new-buffer-name server port nil tgt-info id)))) | ||
| 1756 | 1784 | ||
| 1757 | (defun erc-member-ignore-case (string list) | 1785 | (defun erc-member-ignore-case (string list) |
| 1758 | "Return non-nil if STRING is a member of LIST. | 1786 | "Return non-nil if STRING is a member of LIST. |
| @@ -2094,7 +2122,7 @@ removed from the list will be disabled." | |||
| 2094 | 2122 | ||
| 2095 | (defun erc-open (&optional server port nick full-name | 2123 | (defun erc-open (&optional server port nick full-name |
| 2096 | connect passwd tgt-list channel process | 2124 | connect passwd tgt-list channel process |
| 2097 | client-certificate user) | 2125 | client-certificate user id) |
| 2098 | "Connect to SERVER on PORT as NICK with USER and FULL-NAME. | 2126 | "Connect to SERVER on PORT as NICK with USER and FULL-NAME. |
| 2099 | 2127 | ||
| 2100 | If CONNECT is non-nil, connect to the server. Otherwise assume | 2128 | If CONNECT is non-nil, connect to the server. Otherwise assume |
| @@ -2111,11 +2139,17 @@ of the client certificate itself to use when connecting over TLS, | |||
| 2111 | or t, which means that `auth-source' will be queried for the | 2139 | or t, which means that `auth-source' will be queried for the |
| 2112 | private key and the certificate. | 2140 | private key and the certificate. |
| 2113 | 2141 | ||
| 2142 | When non-nil, ID should be a symbol for identifying the connection. | ||
| 2143 | |||
| 2114 | Returns the buffer for the given server or channel." | 2144 | Returns the buffer for the given server or channel." |
| 2115 | (let ((buffer (erc-get-buffer-create server port channel)) | 2145 | (let* ((target (and channel (erc--target-from-string channel))) |
| 2116 | (old-buffer (current-buffer)) | 2146 | (buffer (erc-get-buffer-create server port nil target id)) |
| 2117 | old-point | 2147 | (old-buffer (current-buffer)) |
| 2118 | (continued-session (and erc-reuse-buffers erc--server-reconnecting))) | 2148 | old-point |
| 2149 | (continued-session (and erc--server-reconnecting | ||
| 2150 | (with-suppressed-warnings | ||
| 2151 | ((obsolete erc-reuse-buffers)) | ||
| 2152 | erc-reuse-buffers)))) | ||
| 2119 | (when connect (run-hook-with-args 'erc-before-connect server port nick)) | 2153 | (when connect (run-hook-with-args 'erc-before-connect server port nick)) |
| 2120 | (erc-update-modules) | 2154 | (erc-update-modules) |
| 2121 | (set-buffer buffer) | 2155 | (set-buffer buffer) |
| @@ -2145,7 +2179,9 @@ Returns the buffer for the given server or channel." | |||
| 2145 | (set-marker erc-insert-marker (point)) | 2179 | (set-marker erc-insert-marker (point)) |
| 2146 | ;; stack of default recipients | 2180 | ;; stack of default recipients |
| 2147 | (setq erc-default-recipients tgt-list) | 2181 | (setq erc-default-recipients tgt-list) |
| 2148 | (setq erc--target (and channel (erc--target-from-string channel))) | 2182 | (when target |
| 2183 | (setq erc--target target | ||
| 2184 | erc-network (erc-network))) | ||
| 2149 | (setq erc-server-current-nick nil) | 2185 | (setq erc-server-current-nick nil) |
| 2150 | ;; Initialize erc-server-users and erc-channel-users | 2186 | ;; Initialize erc-server-users and erc-channel-users |
| 2151 | (if connect | 2187 | (if connect |
| @@ -2184,6 +2220,10 @@ Returns the buffer for the given server or channel." | |||
| 2184 | :require '(:secret)))) | 2220 | :require '(:secret)))) |
| 2185 | ;; client certificate (only useful if connecting over TLS) | 2221 | ;; client certificate (only useful if connecting over TLS) |
| 2186 | (setq erc-session-client-certificate client-certificate) | 2222 | (setq erc-session-client-certificate client-certificate) |
| 2223 | (setq erc-networks--id (if connect | ||
| 2224 | (erc-networks--id-create id) | ||
| 2225 | (buffer-local-value 'erc-networks--id | ||
| 2226 | old-buffer))) | ||
| 2187 | ;; debug output buffer | 2227 | ;; debug output buffer |
| 2188 | (setq erc-dbuf | 2228 | (setq erc-dbuf |
| 2189 | (when erc-log-p | 2229 | (when erc-log-p |
| @@ -2322,7 +2362,8 @@ parameters SERVER and NICK." | |||
| 2322 | (nick (erc-compute-nick)) | 2362 | (nick (erc-compute-nick)) |
| 2323 | (user (erc-compute-user)) | 2363 | (user (erc-compute-user)) |
| 2324 | password | 2364 | password |
| 2325 | (full-name (erc-compute-full-name))) | 2365 | (full-name (erc-compute-full-name)) |
| 2366 | id) | ||
| 2326 | "ERC is a powerful, modular, and extensible IRC client. | 2367 | "ERC is a powerful, modular, and extensible IRC client. |
| 2327 | This function is the main entry point for ERC. | 2368 | This function is the main entry point for ERC. |
| 2328 | 2369 | ||
| @@ -2335,6 +2376,7 @@ Non-interactively, it takes the keyword arguments | |||
| 2335 | (user (erc-compute-user)) | 2376 | (user (erc-compute-user)) |
| 2336 | password | 2377 | password |
| 2337 | (full-name (erc-compute-full-name)) | 2378 | (full-name (erc-compute-full-name)) |
| 2379 | id | ||
| 2338 | 2380 | ||
| 2339 | That is, if called with | 2381 | That is, if called with |
| 2340 | 2382 | ||
| @@ -2342,9 +2384,13 @@ That is, if called with | |||
| 2342 | 2384 | ||
| 2343 | then the server and full-name will be set to those values, | 2385 | then the server and full-name will be set to those values, |
| 2344 | whereas `erc-compute-port' and `erc-compute-nick' will be invoked | 2386 | whereas `erc-compute-port' and `erc-compute-nick' will be invoked |
| 2345 | for the values of the other parameters." | 2387 | for the values of the other parameters. |
| 2388 | |||
| 2389 | When present, ID should be an opaque object used to identify the | ||
| 2390 | connection unequivocally. This is rarely needed and not available | ||
| 2391 | interactively." | ||
| 2346 | (interactive (erc-select-read-args)) | 2392 | (interactive (erc-select-read-args)) |
| 2347 | (erc-open server port nick full-name t password nil nil nil nil user)) | 2393 | (erc-open server port nick full-name t password nil nil nil nil user id)) |
| 2348 | 2394 | ||
| 2349 | ;;;###autoload | 2395 | ;;;###autoload |
| 2350 | (defalias 'erc-select #'erc) | 2396 | (defalias 'erc-select #'erc) |
| @@ -2357,7 +2403,8 @@ for the values of the other parameters." | |||
| 2357 | (user (erc-compute-user)) | 2403 | (user (erc-compute-user)) |
| 2358 | password | 2404 | password |
| 2359 | (full-name (erc-compute-full-name)) | 2405 | (full-name (erc-compute-full-name)) |
| 2360 | client-certificate) | 2406 | client-certificate |
| 2407 | id) | ||
| 2361 | "ERC is a powerful, modular, and extensible IRC client. | 2408 | "ERC is a powerful, modular, and extensible IRC client. |
| 2362 | This function is the main entry point for ERC over TLS. | 2409 | This function is the main entry point for ERC over TLS. |
| 2363 | 2410 | ||
| @@ -2371,6 +2418,7 @@ Non-interactively, it takes the keyword arguments | |||
| 2371 | password | 2418 | password |
| 2372 | (full-name (erc-compute-full-name)) | 2419 | (full-name (erc-compute-full-name)) |
| 2373 | client-certificate | 2420 | client-certificate |
| 2421 | id | ||
| 2374 | 2422 | ||
| 2375 | That is, if called with | 2423 | That is, if called with |
| 2376 | 2424 | ||
| @@ -2393,12 +2441,18 @@ Example usage: | |||
| 2393 | (erc-tls :server \"irc.libera.chat\" :port 6697 | 2441 | (erc-tls :server \"irc.libera.chat\" :port 6697 |
| 2394 | :client-certificate | 2442 | :client-certificate |
| 2395 | \\='(\"/home/bandali/my-cert.key\" | 2443 | \\='(\"/home/bandali/my-cert.key\" |
| 2396 | \"/home/bandali/my-cert.crt\"))" | 2444 | \"/home/bandali/my-cert.crt\")) |
| 2445 | |||
| 2446 | When present, ID should be an opaque object for identifying the | ||
| 2447 | connection unequivocally. (In most cases, this would be a string or a | ||
| 2448 | symbol composed of letters from the Latin alphabet.) This option is | ||
| 2449 | generally unneeded, however. See info node `(erc) Connecting' for use | ||
| 2450 | cases. Not available interactively." | ||
| 2397 | (interactive (let ((erc-default-port erc-default-port-tls)) | 2451 | (interactive (let ((erc-default-port erc-default-port-tls)) |
| 2398 | (erc-select-read-args))) | 2452 | (erc-select-read-args))) |
| 2399 | (let ((erc-server-connect-function 'erc-open-tls-stream)) | 2453 | (let ((erc-server-connect-function 'erc-open-tls-stream)) |
| 2400 | (erc-open server port nick full-name t password | 2454 | (erc-open server port nick full-name t password |
| 2401 | nil nil nil client-certificate user))) | 2455 | nil nil nil client-certificate user id))) |
| 2402 | 2456 | ||
| 2403 | (defun erc-open-tls-stream (name buffer host port &rest parameters) | 2457 | (defun erc-open-tls-stream (name buffer host port &rest parameters) |
| 2404 | "Open an TLS stream to an IRC server. | 2458 | "Open an TLS stream to an IRC server. |
| @@ -2463,13 +2517,20 @@ The buffer is created if it doesn't exist. | |||
| 2463 | 2517 | ||
| 2464 | If OUTBOUND is non-nil, STRING is being sent to the IRC server and | 2518 | If OUTBOUND is non-nil, STRING is being sent to the IRC server and |
| 2465 | appears in face `erc-input-face' in the buffer. Lines must already | 2519 | appears in face `erc-input-face' in the buffer. Lines must already |
| 2466 | contain CRLF endings. Peer is identified by the most precise label | 2520 | contain CRLF endings. A peer is identified by the most precise label |
| 2467 | available at run time, starting with the network name, followed by the | 2521 | available, starting with the session ID followed by the server-reported |
| 2468 | announced host name, and falling back to the dialed <server>:<port>." | 2522 | hostname, and falling back to the dialed <server>:<port> pair. |
| 2523 | |||
| 2524 | When capturing logs for multiple peers and sorting them into buckets, | ||
| 2525 | such inconsistent labeling may pose a problem until the MOTD is | ||
| 2526 | received. Setting a fixed `erc-networks--id' can serve as a | ||
| 2527 | workaround." | ||
| 2469 | (when erc-debug-irc-protocol | 2528 | (when erc-debug-irc-protocol |
| 2470 | (let ((esid (or (and (erc-network) (erc-network-name)) | 2529 | (let ((esid (if-let ((erc-networks--id) |
| 2471 | erc-server-announced-name | 2530 | (esid (erc-networks--id-symbol erc-networks--id))) |
| 2472 | (format "%s:%s" erc-session-server erc-session-port))) | 2531 | (symbol-name esid) |
| 2532 | (or erc-server-announced-name | ||
| 2533 | (format "%s:%s" erc-session-server erc-session-port)))) | ||
| 2473 | (ts (when erc-debug-irc-protocol-time-format | 2534 | (ts (when erc-debug-irc-protocol-time-format |
| 2474 | (format-time-string erc-debug-irc-protocol-time-format)))) | 2535 | (format-time-string erc-debug-irc-protocol-time-format)))) |
| 2475 | (with-current-buffer (get-buffer-create "*erc-protocol*") | 2536 | (with-current-buffer (get-buffer-create "*erc-protocol*") |
| @@ -3866,7 +3927,8 @@ the message given by REASON." | |||
| 3866 | (when process | 3927 | (when process |
| 3867 | (delete-process process)) | 3928 | (delete-process process)) |
| 3868 | (erc-server-reconnect) | 3929 | (erc-server-reconnect) |
| 3869 | (with-suppressed-warnings ((obsolete erc-server-reconnecting)) | 3930 | (with-suppressed-warnings ((obsolete erc-server-reconnecting) |
| 3931 | ((obsolete erc-reuse-buffers))) | ||
| 3870 | (if erc-reuse-buffers | 3932 | (if erc-reuse-buffers |
| 3871 | (progn (cl-assert (not erc--server-reconnecting)) | 3933 | (progn (cl-assert (not erc--server-reconnecting)) |
| 3872 | (cl-assert (not erc-server-reconnecting))) | 3934 | (cl-assert (not erc-server-reconnecting))) |
| @@ -6626,21 +6688,13 @@ This should be a string with substitution variables recognized by | |||
| 6626 | "Return the network or the current target and network combined. | 6688 | "Return the network or the current target and network combined. |
| 6627 | If the name of the network is not available, then use the | 6689 | If the name of the network is not available, then use the |
| 6628 | shortened server name instead." | 6690 | shortened server name instead." |
| 6629 | (let ((network-name (or (and (fboundp 'erc-network-name) (erc-network-name)) | 6691 | (if-let ((erc--target) |
| 6630 | (erc-shorten-server-name | 6692 | (name (if-let ((esid (erc-networks--id-symbol erc-networks--id))) |
| 6631 | (or erc-server-announced-name | 6693 | (symbol-name esid) |
| 6632 | erc-session-server))))) | 6694 | (erc-shorten-server-name (or erc-server-announced-name |
| 6633 | (when (and network-name (symbolp network-name)) | 6695 | erc-session-server))))) |
| 6634 | (setq network-name (symbol-name network-name))) | 6696 | (concat (erc--target-string erc--target) "@" name) |
| 6635 | (cond ((erc-default-target) | 6697 | (buffer-name))) |
| 6636 | (concat (erc-string-no-properties (erc-default-target)) | ||
| 6637 | "@" network-name)) | ||
| 6638 | ((and network-name | ||
| 6639 | (not (get-buffer network-name))) | ||
| 6640 | (when erc-rename-buffers | ||
| 6641 | (rename-buffer network-name)) | ||
| 6642 | network-name) | ||
| 6643 | (t (buffer-name (current-buffer)))))) | ||
| 6644 | 6698 | ||
| 6645 | (defun erc-format-away-status () | 6699 | (defun erc-format-away-status () |
| 6646 | "Return a formatted `erc-mode-line-away-status-format' if `erc-away' is non-nil." | 6700 | "Return a formatted `erc-mode-line-away-status-format' if `erc-away' is non-nil." |
| @@ -7060,20 +7114,29 @@ See also `format-spec'." | |||
| 7060 | ;; FIXME: Don't set the hook globally! | 7114 | ;; FIXME: Don't set the hook globally! |
| 7061 | (add-hook 'kill-buffer-hook #'erc-kill-buffer-function) | 7115 | (add-hook 'kill-buffer-hook #'erc-kill-buffer-function) |
| 7062 | 7116 | ||
| 7063 | (defcustom erc-kill-server-hook '(erc-kill-server) | 7117 | (defcustom erc-kill-server-hook '(erc-kill-server |
| 7064 | "Invoked whenever a server buffer is killed via `kill-buffer'." | 7118 | erc-networks-shrink-ids-and-buffer-names) |
| 7119 | "Invoked whenever a live server buffer is killed via `kill-buffer'." | ||
| 7120 | :package-version '(ERC . "5.4.1") ; FIXME increment upon publishing to ELPA | ||
| 7065 | :group 'erc-hooks | 7121 | :group 'erc-hooks |
| 7066 | :type 'hook) | 7122 | :type 'hook) |
| 7067 | 7123 | ||
| 7068 | (defcustom erc-kill-channel-hook '(erc-kill-channel) | 7124 | (defcustom erc-kill-channel-hook |
| 7125 | '(erc-kill-channel | ||
| 7126 | erc-networks-shrink-ids-and-buffer-names | ||
| 7127 | erc-networks-rename-surviving-target-buffer) | ||
| 7069 | "Invoked whenever a channel-buffer is killed via `kill-buffer'." | 7128 | "Invoked whenever a channel-buffer is killed via `kill-buffer'." |
| 7129 | :package-version '(ERC . "5.4.1") ; FIXME increment upon publishing to ELPA | ||
| 7070 | :group 'erc-hooks | 7130 | :group 'erc-hooks |
| 7071 | :type 'hook) | 7131 | :type 'hook) |
| 7072 | 7132 | ||
| 7073 | (defcustom erc-kill-buffer-hook nil | 7133 | (defcustom erc-kill-buffer-hook |
| 7074 | "Hook run whenever a non-server or channel buffer is killed. | 7134 | '(erc-networks-shrink-ids-and-buffer-names |
| 7135 | erc-networks-rename-surviving-target-buffer) | ||
| 7136 | "Hook run whenever a query buffer is killed. | ||
| 7075 | 7137 | ||
| 7076 | See also `kill-buffer'." | 7138 | See also `kill-buffer'." |
| 7139 | :package-version '(ERC . "5.4.1") ; FIXME increment upon publishing to ELPA | ||
| 7077 | :group 'erc-hooks | 7140 | :group 'erc-hooks |
| 7078 | :type 'hook) | 7141 | :type 'hook) |
| 7079 | 7142 | ||