[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug#68265: 30.0.50; ERC 5.6: Simplify alternate text insertion for o

From: J.P.
Subject: Re: bug#68265: 30.0.50; ERC 5.6: Simplify alternate text insertion for outgoing messages
Date: Fri, 12 Jan 2024 08:21:21 -0800
User-agent: Gnus/5.13 (Gnus v5.13)

"J.P." <jp@neverwas.me> 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.


[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)
      (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!
              (expand-file-name (format "erc-crypt/%s/" nick)
        (make-directory erc-crypt-dir-userdef 'parents)
        (require 'erc-crypt)
            (erc :server "" :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 <othernick>", where "<othernick>" is the `nick' specified
    for the _other_ instance. After that, type "/query <othernick>", 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.

Attachment: 0001-POC-Use-erc-pre-send-functions-API.patch
Description: Text Data

Attachment: 0002-POC-Use-format-template-based-API.patch
Description: Text Data

Attachment: 0003-POC-Use-proposed-msgfspec-API.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]