Subject: 31.0.50; ERC 5.7: Improve the track module's erc-fools integration

From: "J.P." <[email-masked]>
Date: Fri, 15 Aug 2025 19:49:43 -0700

Severity: wishlist
Tags: patch

A user on Libera.Chat recently reported that the track module's mode
line segment reacts to messages from members of `erc-fools' when the
option `erc-fool-highlight-type' is set to something other than `all'.
Those offending variants, including the default of `nick', all arrange
for applying `erc-fool-face' to only a portion of an inserted message.

To reproduce from -Q:

  1. Connect to a server and join a channel containing "somenick"
  2. M-x erc-add-fool RET somenick RET
  3. Switch away from the channel buffer
  4. Notice the mode line reacts when "somenick" speaks

This behavior is present in all versions at least as far back as ERC 5.3
(Emacs 27). In addition to removing `erc-fool-face' from
`erc-track-faces-priority-list', setting

  (setopt erc-fool-highlight-type 'all
          erc-track-priority-faces-only 'all)

is also needed to silence the mode line segment effectively. (Omitting
either does not.)

There are many ways to go about addressing this. One lazy possibility is
shown in the attached patch, which has `track' ignore all invisible
messages, though this requires users to also do

  (setopt erc-text-matched-hook '(erc-hide-fools))

or similar to obtain the desired effect. On the plus side, users will no
longer have to fiddle with any of the other options mentioned above.

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.49, cairo version 1.18.2) of 2025-08-03 built on localhost
Repository revision: c935b68bed174386f46dec6be525a23397a4b5f8
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12401008
System Description: Fedora Linux 42 (Workstation Edition)

Configured using:
 'configure --enable-check-lisp-object-type --enable-checking=yes,glyphs
 'CFLAGS=-O0 -g3'
 PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINERAMA XINPUT2 XPM
XRANDR GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort compile comint ansi-osc ansi-color ring mail-extr emacsbug
lisp-mnt message mailcap yank-media puny dired dired-loaddefs rfc822 mml
mml-sec epa epg rfc6068 epg-config gnus-util text-property-search
time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils comp-run comp-common erc derived auth-source eieio
eieio-core icons password-cache json map format-spec erc-backend
erc-networks easy-mmode byte-opt bytecomp byte-compile erc-common inline
cl-extra help-mode erc-compat cl-seq cl-macs gv pcase rx compat subr-x
cl-loaddefs cl-lib erc-loaddefs rmc iso-transl tooltip cconv eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd touch-screen tool-bar dnd fontset
image regexp-opt fringe tabulated-list replace newcomment text-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo gtk
x-toolkit xinput2 x multi-tty move-toolbar make-network-process
tty-child-frames native-compile emacs)

Memory information:
((conses 16 159549 9446) (symbols 48 11837 0) (strings 32 29151 3461)
 (string-bytes 1 1023634) (vectors 16 17510)
 (vector-slots 8 189808 9616) (floats 8 35 1) (intervals 56 332 0)
 (buffers 1064 11))

>From 71c5939046d762b939be427c0a1d18afd7fc76b7 Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <[email-masked]>
Date: Thu, 14 Aug 2025 20:41:04 -0700
Subject: [PATCH] [5.7] Ignore certain hidden messages in erc-track

FIXME add news entry

* lisp/erc/erc-track.el (erc-track-exclude-hidden): New option.
(erc-track-modified-channels): Bail out if `erc-track-exclude-hidden' is
non-nil and the message property `erc--invisible' is present in the
table, which it is for messages from designated fools during portions of
`erc-insert-modify-hook' and `erc-insert-post-hook', that is until the
inserted message receives the permanent `erc--hide' property.
---
 lisp/erc/erc-track.el | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lisp/erc/erc-track.el b/lisp/erc/erc-track.el
index 2897c3ede93..70d99ed16cd 100644
--- a/lisp/erc/erc-track.el
+++ b/lisp/erc/erc-track.el
@@ -109,6 +109,11 @@ erc-track-exclude-server-buffer
 server and other miscellaneous functions."
   :type 'boolean)
 
+(defcustom erc-track-exclude-hidden t
+  "If non-nil, disregard certain normally invisible messages.
+For example, ignore those marked by `erc-hide-fools'."
+  :type 'boolean)
+
 (defcustom erc-track-shorten-start 1
   "Minimum number of characters for a channel name in the mode-line."
   :type 'number)
@@ -1032,6 +1037,8 @@ erc-track-modified-channels
              (not (let ((parsed (erc-find-parsed-property)))
                     (or (erc-message-type-member (or parsed (point-min))
                                                  erc-track-exclude-types)
+                        (and erc-track-exclude-hidden
+                             (erc--check-msg-prop 'erc--invisible))
                         ;; Skip certain non-server-sent messages.
                         (and (not parsed)
                              (erc--memq-msg-prop 'erc--skip 'track))))))
-- 
2.50.1