Cache UI string for channel modes in ERC
authorF. Jason Park <jp@neverwas.me>
Tue, 21 Nov 2023 03:45:30 +0000 (19:45 -0800)
committerF. Jason Park <jp@neverwas.me>
Fri, 24 Nov 2023 21:38:52 +0000 (13:38 -0800)
commit5bc84a0c9e4be93eada835ee41951296017c6faa
tree25cd94508650967ccefded522751347d3aeaff69
parent2fca889cfb4fa495a6ffa0c7fe368551ee9a32bc
Cache UI string for channel modes in ERC

* etc/ERC-NEWS: Add entry for more expansive "%m" in header line.
* lisp/erc/erc-common.el (erc--channel-mode-types): New slot
`shortargs' for caching truncated mode args.
* lisp/erc/erc.el (erc--mode-line-chanmodes-arg-len): New internal
variable for adjusting the truncation length of channel-mode arguments
as they appear in the header line.
(erc--mode-line-mode-string): New variable for caching the relevant
"modestring", if any, in ERC buffers.
(erc--process-channel-modes): Don't associate args with group 4/D,
which are all nullary modes.  This fixes a bug in which arguments were
associated with the wrong letters.  Also, set cached mode string for
channel.
(erc--user-modes): Simplify slightly by removing likely useless
variant for overloaded arg AS-TYPE.  This function is new in ERC 5.6.
(erc--channel-modes):  New function.  A higher-level getter for
current channel mode representation to complement `erc--user-modes'.
(erc--parse-user-modes): Set `erc--mode-line-mode-string in server
buffers.
(erc--handle-channel-mode): Change model to associate modes of type A
with a running plus/minus tally of state changes since joining the
channel.
(erc-update-mode-line-buffer): Use cached verbose representation of
channel or user modes instead of calling `erc-format-channel-modes'.
* test/lisp/erc/erc-tests.el (erc--update-channel-modes): Update to
reflect new running tally associations for type A modes.
(erc--channel-modes): New test.
(erc--user-modes): Update to reflect parameter simplification.
(Bug#67220)
etc/ERC-NEWS
lisp/erc/erc-common.el
lisp/erc/erc.el
test/lisp/erc/erc-tests.el