"J.P." writes: > Demo implementation for an existing third-party package forthcoming. The demo described below illustrates a realistic use case for three closely related features: the one offered by this bug, the existing template-catalog framework, and the newly proposed hook-based "msgfspec" interface from bug67677. See that thread for the latest version of these changes as well. As an example of how this is meant to work, I've chosen to modify a project recently shared on Libera.Chat by an ERC user. It's an informal "fork" of erc-crypt that includes semi-automated Diffie-Hellman key exchange. For those not familiar, the package allows two parties to converse privately, in band, in a manner roughly analogous to OTR. The three most recent commits (mine) demonstrate overlapping ways of adapting the existing code to leverage what's hopefully an improved menu of interface options for influencing message formatting and insertion: 1. the "alternate text" slot of `erc-input' (this bug) 2. ERC's template-catalog framework for dictating how "speaker" message's appear when inserted (internal) 3. the public-facing side of (2), a hook-based interface called "msgfspec" that exposes individual components of a message template prior to formatting In case my original post wasn't clear, the main win offered by this combined, multifaceted approach over existing offerings is improved interoperability with other modules. The demo code is temporarily hosted in ERC's CI forge [1], and the relevant changes live in the last few commits of that repo. They roughly align with the three interfaces listed above, and the contrast between them hopefully reveals an obvious progression in terms of brevity, control, and flexibility. I've exported the changes in patch form for convenience, but you'll obviously have to clone the repo to try it. In addition to the commit messages and code comments, please see the recent activity in bug67677, whose latest patches are also required for the demo to work. Thanks. [1] https://gitlab.com/emacs-erc/bug68265-demo.git To actually run it, you need to fire up two emacs -Q instances, and evaluate the following, ensuring `nick' is distinct in each. (require 'erc) (erc-toggle-debug-irc-protocol) (toggle-debug-on-error) (with-current-buffer "*erc-protocol*" (toggle-truncate-lines)) (setq erc-fill-function 'erc-fill-static erc-autojoin-channels-alist '((foonet "#test")) erc-modules (cons 'crypt erc-modules)) (let* ((nick "bob") ;; ^~~~~~~~~~~~~~~~~~~ change this per instance! (erc-crypt-dir-userdef (expand-file-name (format "erc-crypt/%s/" nick) (temporary-file-directory)))) (make-directory erc-crypt-dir-userdef 'parents) (require 'erc-crypt) (with-current-buffer (erc :server "127.0.0.1" :nick nick) (unless (file-exists-p (expand-file-name "secret" erc-crypt-dir-userdef)) (erc-cmd-CRYPT "genkeys")))) Once you're up and running, navigate to the #test buffer, and type "/crypt dh ", where "" is the `nick' specified for the _other_ instance. After that, type "/query ", and commence chatting as usual. If you take a look at the "*erc-protocol*" buffer, you'll see all new messages are encrypted. If you're bored, try sending a giant multiline message.