GNU bug report logs - #57955
29.0.50; Allow session-local ERC modules

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: "J.P." <jp@HIDDEN>; Keywords: patch; dated Tue, 20 Sep 2022 13:06:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 57955 <at> debbugs.gnu.org:


Received: (at 57955) by debbugs.gnu.org; 21 Sep 2022 13:16:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 21 09:16:05 2022
Received: from localhost ([127.0.0.1]:32957 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oaza9-0007P3-4H
	for submit <at> debbugs.gnu.org; Wed, 21 Sep 2022 09:16:05 -0400
Received: from mail-108-mta83.mxroute.com ([136.175.108.83]:44859)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <jp@HIDDEN>) id 1oaza6-0007ON-Jd
 for 57955 <at> debbugs.gnu.org; Wed, 21 Sep 2022 09:16:03 -0400
Received: from mail-111-mta2.mxroute.com ([136.175.111.2]
 filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR)
 by mail-108-mta83.mxroute.com (ZoneMTA) with ESMTPSA id 1836030c9440002b7a.001
 for <57955 <at> debbugs.gnu.org>
 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256);
 Wed, 21 Sep 2022 13:15:53 +0000
X-Zone-Loop: ecf00f9e2a5950d8ef4ef8ed05eea8c4a625c2f935a4
X-Originating-IP: [136.175.111.2]
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=neverwas.me
 ; s=x;
 h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To:
 Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID:
 Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
 :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=uYmYjzylxd0k0B59Yss4q7xmduVPxvmXcx40DeCI/A8=; b=IuKKCrc57rfZwehIh+mSYotgAl
 3oTuhnn0pDPOBDyIogPMidyepK3WUG1fahpU0R9F6GfJTdBp5VrvM9moqU8tNePtyIhIdkZ4bH2q5
 lR7n2ip/ITxUxl5v8eOxWO+jcc7m1QNJPlYkMJK2VNZZQsRL27r1MlB8xU4ZahCMtoI+iz4UgUrPz
 nTyj8lilabrBvVr6sh7k/zTS4+FE126rxEIJR3GKC019aPP3K4jXly2jZd/RDslPIngD5nmtPmS0R
 B/T2Om5GYnquIccyMgyiIzJIsxdTLIGjKjCK/Q2sRUk9Tymq0orA9gloCb4oFwpE+NciBcEKuEylB
 gpt759ow==;
From: "J.P." <jp@HIDDEN>
To: Michael Albinus <michael.albinus@HIDDEN>
Subject: Re: bug#57955: 29.0.50; Allow session-local ERC modules
In-Reply-To: <87r106eybd.fsf@HIDDEN> (Michael Albinus's message of "Tue, 20
 Sep 2022 19:43:34 +0200")
References: <8735cm2o2l.fsf__21117.726997339$1663692322$gmane$org@HIDDEN>
 <87r106eybd.fsf@HIDDEN>
Date: Wed, 21 Sep 2022 06:15:48 -0700
Message-ID: <87czboswaj.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Authenticated-Id: masked@HIDDEN
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 57955
Cc: 57955 <at> debbugs.gnu.org, emacs-erc@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi Michael,

Michael Albinus <michael.albinus@HIDDEN> writes:

> Without knowing erc in general and your patch in detail: this sounds
> like you could profit from connection-local variables. Did you check
> this?

Not quite yet (only superficially).

At first glance, I'm not sure they're a perfect fit for this specific
issue, but I'll definitely investigate further. Either way, I'm thinking
they'd be a great solution (or inspiration) for an initiative we have on
the horizon, namely, devising a means of applying user options in a more
granular, contextual manner [1].

Also (if you happen to recall), a few of our recent exchanges ended with
me pledging to follow through on one thing or another. And yet, most of
those promises remain unfulfilled. Please know that I do plan on
addressing them "eventually" and that I very much appreciate your help
(and your patience).

Thanks,
J.P.


[1] In case you're interested, by "context," I'm referring to various
    logical (somewhat overlapping) IRC boundaries, such as

    - message: event-local, i.e., source-wise and message-type-wise
    - channel: target-local
    - network: connection-local

    Basically, I'm looking for something akin to a "context variable"
    facility, except not so much for managing concurrency but instead
    for transparently stashing and restoring message-processing
    environments matched against headers and protocol state. More info:

    https://lists.gnu.org/archive/html/emacs-erc/2021-10/msg00003.html




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57955; Package emacs. Full text available.

Message received at 57955 <at> debbugs.gnu.org:


Received: (at 57955) by debbugs.gnu.org; 20 Sep 2022 17:43:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 20 13:43:52 2022
Received: from localhost ([127.0.0.1]:59550 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oahHj-0003NM-QC
	for submit <at> debbugs.gnu.org; Tue, 20 Sep 2022 13:43:51 -0400
Received: from mout.gmx.net ([212.227.17.21]:56053)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <michael.albinus@HIDDEN>) id 1oahHe-0003N6-3J
 for 57955 <at> debbugs.gnu.org; Tue, 20 Sep 2022 13:43:50 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net;
 s=badeba3b8450; t=1663695816;
 bh=Dm0aKnKgQdM2xZe7C5wf0rOXyCyfGDfR+czeSn5KpnM=;
 h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date;
 b=I61CM3mNdsxCffhq29AoNlTWnxklaXAsUQ2uXef0ca19XDV8R3nSmD+EPacaO/L/o
 zFAuB8iZqT/EncjBPk4C9esVrjM5hN+KDb+UVlpo1t4a4alpXOUlKAzirxBzVcoYgO
 +/h5235e1kCqyxj4EVVY0GfjhzZi9vwOe1+WZGmk=
X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c
Received: from gandalf.gmx.de ([79.140.125.182]) by mail.gmx.net (mrgmx105
 [212.227.17.168]) with ESMTPSA (Nemesis) id 1ML9yc-1osm613O8A-00IGfp; Tue, 20
 Sep 2022 19:43:35 +0200
From: Michael Albinus <michael.albinus@HIDDEN>
To: "J.P." <jp@HIDDEN>
Subject: Re: bug#57955: 29.0.50; Allow session-local ERC modules
In-Reply-To: <8735cm2o2l.fsf__21117.726997339$1663692322$gmane$org@HIDDEN>
 (J. P.'s message of "Tue, 20 Sep 2022 06:05:38 -0700")
References: <8735cm2o2l.fsf__21117.726997339$1663692322$gmane$org@HIDDEN>
Date: Tue, 20 Sep 2022 19:43:34 +0200
Message-ID: <87r106eybd.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Provags-ID: V03:K1:YVqWuGgOcu3teWsi7WATMCF0D4/J+t020qlQKEwMW46vQDPpzuc
 bVXPQpLGUJM0qp5X1Can6/d02mcGOzarO8mCjT+alZ3vhHYP3Uf7sbbfxZanVOkrA8+kMKx
 rJCkpbWkI+Crb0cywkH8FqqjFh5EW7hUuNUkH4PrpIja6Tm1anbGI6if0bsoBrWXMqYGak+
 RMWACwF1yiMuJqkJ4hORQ==
X-Spam-Flag: NO
X-UI-Out-Filterresults: notjunk:1;V03:K0:/Cs0C6xBtaI=:nI5/EjB5B0wnD1ByaHtdWa
 eMCwk/kNSAlC+/Qk1Rcr0Lftq/07IdWe0lUeyGw8IwxU3JZeUkXtHurhye5JoOVNqLZjE1Eay
 1xRawyDGpbqpnCTK4l2s3xooRVrz0njnbBncI5RXv9dQKaTWhhmf/+kgzdOEDOEFd2P8AVNvf
 qg83egLyckS4FhYAJBGsmADlbOsjK0B0I72PdcTh0Jcz5EQJ4PajB8e58KpO6vN8O83+rTol/
 NdJkjvqKe6neIUrH3n2j53U1Pj9JjlHr36BVkOFQ1yzgh1xKmE52LoujxPNJ2AHAvlfHlJkD2
 /+FF9W4/CJ5ngnkbQ0t/0kYctn6sD2uzD0GlPMJl6I0IzFAexlx132P1dXobU0ZCI7RIq1KKC
 3Te9v7W7vFsiJVtoyMRJEYjx/hTbCdCk/5Jsf/ni3eFEiri5k18XRTL9vJp6skcEHMqUz8GDW
 66Hcv65tkSHoK9bHndWcd0Rdxye6MQpmUsIzFUemGYJgNQeQgk1pEaelSGK82fM55+/olAGQU
 n8IaP3Cej5qPDifYRjTpZfhwFluwjt2TVj1lVHPnTKEAWaB0wOArx3leMZzRwH32gaQZaX635
 dPF9c4LWR2LlOzlVCv19MP4RKFhMpb0vN/RwoRUTQ9o8F3tn4jZpbq94jwZp4M2qdp96Y7utD
 tEgCJ7ZOOgoIjyxSTfq6fEhRL1O4AkrJ0+PXFnHzwQ4KHUy5lUwq3Cv3zJnp4U8ey5hN0nYmo
 dxVoARcFXu8ku1rwgpdsgtnRYxB9TziDGVRjCg3KvMIIEJSiZ4lbTajGbAaYiOob4SLm5ICaw
 9qcPiCVWwNDAp/LaQsREzB1CERPgOZyALVrchyhK8eW2ybl/s5kScKCLO1BYD//I/oRmSlErV
 33v5mF2lSAdmxqAQOAzI/TbN2NcNSv/gpkW/m3lFf1KupnnKt8AQlSjjlGWfMoZMia+mCmgF5
 JjBBU5FidXkkL9iG5mQJOOA18e3nWLIkdd9zbEcufolpitkLeHkgo2WhKNbEq44YCVjtJmaR9
 q2Z+tZl6b9qO0y2Jcv66Bw4Mmm9yNnnQq2zsIlop47MQNA4VAh2h5nriQI3MHxhb+fyFSD8ns
 2wBAJNMo3y6ngz5Jade0vuapwj3Kb59DbGDTn7WIyJDv0auoLYaJIzYPwQ+CMql/HwR3vm+P1
 usT+aPbCV36FnlPkxBZEPlKtI2
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 57955
Cc: 57955 <at> debbugs.gnu.org, emacs-erc@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

"J.P." <jp@HIDDEN> writes:

> Hi people,

Hi,

> Since its inception, ERC has aimed to support local modules, that is,
> modules local to a connection. (If you need convincing of this, take a
> look at `define-erc-module'.) This makes sense for a good many reasons,
> chief among them simplified semantics when arranging for buffer-local
> variables and hooks. Ancillary benefits include let-binding
> `erc-modules' around entry-point invocations and selectively disabling
> modules for particular sessions (e.g., after capability negotiation).

Without knowing erc in general and your patch in detail: this sounds
like you could profit from connection-local variables. Did you check
this?

> Thanks,
> J.P.

Best regards, Michael.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57955; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 20 Sep 2022 13:06:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 20 09:06:01 2022
Received: from localhost ([127.0.0.1]:56551 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oacwq-0005Xc-Is
	for submit <at> debbugs.gnu.org; Tue, 20 Sep 2022 09:06:01 -0400
Received: from lists.gnu.org ([209.51.188.17]:45430)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <jp@HIDDEN>) id 1oacwo-0005XU-7h
 for submit <at> debbugs.gnu.org; Tue, 20 Sep 2022 09:05:59 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:33714)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <jp@HIDDEN>) id 1oacwi-0004Tw-9o
 for bug-gnu-emacs@HIDDEN; Tue, 20 Sep 2022 09:05:57 -0400
Received: from mail-108-mta51.mxroute.com ([136.175.108.51]:41155)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <jp@HIDDEN>) id 1oacwe-0008N5-LQ
 for bug-gnu-emacs@HIDDEN; Tue, 20 Sep 2022 09:05:51 -0400
Received: from mail-111-mta2.mxroute.com ([136.175.111.2]
 filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR)
 by mail-108-mta51.mxroute.com (ZoneMTA) with ESMTPSA id 1835b0115be0002b7a.001
 for <bug-gnu-emacs@HIDDEN>
 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256);
 Tue, 20 Sep 2022 13:05:41 +0000
X-Zone-Loop: 95530989caf8d8ece97d249344da982d9342f7cb2253
X-Originating-IP: [136.175.111.2]
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=neverwas.me
 ; s=x;
 h=Content-Type:MIME-Version:Message-ID:Date:Subject:To:From:Sender:
 Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description:
 Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
 In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=3F0SHVhmuVURosZQjIbN1WZS8Cle7NN3rYjG3zwaITc=; b=E7+S5ZNHiUSfKy1+I2JITpIgLk
 k9RHuII9p3oXNP1JxEMoHuki2AFwk+IFKeXLeGFxyg3wMdnoLXpC6eMRA2pYDpvM+qX10W1vsIm3x
 XEQD2B0ujRKIvS0QUSjzt3P+4jzNsnHyHo4UUNmMfT4uTyo2mmruuStEmwf0sbe210OUBY3a/eySu
 pIeB1p7KkmwHpzd05r6wxBXARYzFXONRUd7FT/dCNu2La2XAYCY5wuQpovhA80h96jkMcRj1hKWfY
 VA08WpOh1BT69HhF9Ro551Q5QZe2gdvP5uCJ0WNQMW4lE1eabYrS3DgaWhy4zJvvxs9jOVKyLz2iO
 a2/aoXxw==;
From: "J.P." <jp@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 29.0.50; Allow session-local ERC modules
X-Debbugs-CC: emacs-erc@HIDDEN
Date: Tue, 20 Sep 2022 06:05:38 -0700
Message-ID: <8735cm2o2l.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Authenticated-Id: masked@HIDDEN
Received-SPF: pass client-ip=136.175.108.51; envelope-from=jp@HIDDEN;
 helo=mail-108-mta51.mxroute.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

--=-=-=
Content-Type: text/plain

Tags: patch

Hi people,

Since its inception, ERC has aimed to support local modules, that is,
modules local to a connection. (If you need convincing of this, take a
look at `define-erc-module'.) This makes sense for a good many reasons,
chief among them simplified semantics when arranging for buffer-local
variables and hooks. Ancillary benefits include let-binding
`erc-modules' around entry-point invocations and selectively disabling
modules for particular sessions (e.g., after capability negotiation).

Unfortunately, this dream of ERC's authors was never fully realized.
Take a look at `erc-open', where you'll find would-be local vars being
set too early and thus clobbered when `erc-mode' (the major mode) is
activated. Various kludges have come along to circumvent this. For
example, the log module uses `erc-connect-pre-hook' to conduct its
buffer-local business. But it shouldn't have to. ERC can do better.

This patch aims to address this problem by partially changing the
purpose of the function `erc-update-modules' in a backward compatible
way. Instead of activating local modules immediately, it now returns
them in a list to be activated at a time and place of the caller's
choosing. The most opportune place for this, in terms of `erc-open', is
after all the core local variables have been determined, which exposes
them to module setup code. As a bonus, the major mode hook is likewise
deferred to this point.

This patch also reworks the module-to-features map and preferred-name
migration logic, which was incomplete. As far as third-party packages
are concerned, it's only been tested with erc-hl-nicks, thus far, but it
"should" work with others too. (Please let me know if that's a lie.)

Thanks,
J.P.

P.S. BTW, if anyone is friendly with the hl-nicks author, please ask
them to reach out regarding an unrelated custom.el issue; attempts to
contact them via GitHub have so far proven unsuccessful.


In GNU Emacs 29.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version
 3.24.34, cairo version 1.17.6) of 2022-09-19 built on localhost
Repository revision: 132d5cb0a3ec94afbb49772631861e00160ffffb
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12014000
System Description: Fedora Linux 36 (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
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XINPUT2 XPM 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
  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 mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search time-date subr-x mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
cl-loaddefs cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils rmc iso-transl tooltip eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd 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
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 lcms2
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit xinput2 x multi-tty make-network-process
emacs)

Memory information:
((conses 16 36059 6198)
 (symbols 48 5107 0)
 (strings 32 13115 1641)
 (string-bytes 1 372299)
 (vectors 16 9247)
 (vector-slots 8 146583 10252)
 (floats 8 21 25)
 (intervals 56 220 0)
 (buffers 1000 10))

--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0002-Support-local-ERC-modules-in-erc-mode-buffers.patch

From b88bcadffba84b64ae91d45b84736313ac49dfef Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <jp@HIDDEN>
Date: Mon, 12 Jul 2021 03:44:28 -0700
Subject: [PATCH 2/4] Support local ERC modules in erc-mode buffers

* lisp/erc/erc.el (erc-migrate-modules): add some missing mappings.
(erc--module-name-migrations, erc--features-to-modules,
erc--modules-to-features): add alists to support simplified
module-name migrations.
(erc-update-modules): Change return value to a list of minor-mode
commands for local modules that need deferred activation, if any.  Use
`custom-variable-p' to detect flavor.  Currently, all modules are
global, meaning so are their accompanying minor modes.
(erc-open): Defer enabling of local modules via `erc-update-modules'
until after buffer is initialized with other local vars.  Also defer
major mode hooks so they can detect things like whether the buffer is
a server or target buffer.
(define-erc-modules): Don't enable local modules (minor modes) unless
`erc-mode' is the major mode. And don't disable them unless the minor
mode is actually active.  Also, don't mutate `erc-modules' when
dealing with a local module.  It's believed that the original authors
wanted this functionality.
---
 lisp/erc/erc.el            | 108 ++++++++++++++++++++++++-------------
 test/lisp/erc/erc-tests.el |  47 ++++++++++++++++
 2 files changed, 119 insertions(+), 36 deletions(-)

diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 20f22c896f..8fa9d0c8a3 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -1390,7 +1390,9 @@ define-erc-module
 
 This will define a minor mode called erc-NAME-mode, possibly
 an alias erc-ALIAS-mode, as well as the helper functions
-erc-NAME-enable, and erc-NAME-disable.
+erc-NAME-enable, and erc-NAME-disable.  Beware that for global
+modules, these helpers, as well as the minor-mode toggle, all mutate
+the user option `erc-modules'.
 
 Example:
 
@@ -1426,16 +1428,21 @@ define-erc-module
          ,(format "Enable ERC %S mode."
                   name)
          (interactive)
-         (add-to-list 'erc-modules (quote ,name))
-         (setq ,mode t)
-         ,@enable-body)
+         (unless ,local-p
+           (cl-pushnew (erc--normalize-module-symbol ',name) erc-modules))
+         (when (or ,(not local-p) (eq major-mode 'erc-mode))
+           (setq ,mode t)
+           ,@enable-body))
        (defun ,disable ()
          ,(format "Disable ERC %S mode."
                   name)
          (interactive)
-         (setq erc-modules (delq (quote ,name) erc-modules))
-         (setq ,mode nil)
-         ,@disable-body)
+         (unless ,local-p
+           (setq erc-modules (delq (erc--normalize-module-symbol ',name)
+                                   erc-modules)))
+         (when (or ,(not local-p) ,mode)
+           (setq ,mode nil)
+           ,@disable-body))
        ,(when (and alias (not (eq name alias)))
           `(defalias
              ',(intern
@@ -2030,14 +2037,40 @@ erc-default-nicks
 (defvar-local erc-nick-change-attempt-count 0
   "Used to keep track of how many times an attempt at changing nick is made.")
 
+(defconst erc--features-to-modules
+  '((erc-pcomplete completion pcomplete)
+    (erc-capab capab-identify)
+    (erc-join autojoin)
+    (erc-page page ctcp-page)
+    (erc-sound sound ctcp-sound)
+    (erc-stamp stamp timestamp)
+    (erc-services services nickserv))
+  "Migration alist mapping a library feature to module names.
+Keys need not be unique: a library may define more than one
+module.")
+
+(defconst erc--modules-to-features
+  (cl-loop for (feature . names) in erc--features-to-modules
+           append (mapcar (lambda (name) (cons name feature)) names))
+  "Migration alist mapping a module's name to library feature.")
+
+(defconst erc--module-name-migrations
+  (let (pairs)
+    (pcase-dolist (`(,_ ,canonical . ,rest) erc--features-to-modules)
+      (dolist (obsolete rest)
+        (push (cons obsolete canonical) pairs)))
+    pairs)
+  "Association list of obsolete module names to canonical names.")
+
+(defun erc--normalize-module-symbol (module)
+  "Canonicalize symbol MODULE for `erc-modules'."
+  (or (cdr (assq module erc--module-name-migrations)) module))
+
 (defun erc-migrate-modules (mods)
   "Migrate old names of ERC modules to new ones."
   ;; modify `transforms' to specify what needs to be changed
   ;; each item is in the format '(old . new)
-  (let ((transforms '((pcomplete . completion))))
-    (delete-dups
-     (mapcar (lambda (m) (or (cdr (assoc m transforms)) m))
-             mods))))
+  (delete-dups (mapcar #'erc--normalize-module-symbol mods)))
 
 (defcustom erc-modules '(netsplit fill button match track completion readonly
                                   networks ring autojoin noncommands irccontrols
@@ -2116,27 +2149,22 @@ erc-modules
   :group 'erc)
 
 (defun erc-update-modules ()
-  "Run this to enable erc-foo-mode for all modules in `erc-modules'."
-  (let (req)
+  "Enable global minor mode for all global modules in `erc-modules'.
+Return minor-mode commands for all local modules, possibly for
+deferred invocation, as done by `erc-open' whenever a new ERC
+buffer is created.  Local modules were introduced in ERC 5.6."
+  (let (local-modules)
     (dolist (mod erc-modules)
-      (setq req (concat "erc-" (symbol-name mod)))
-      (cond
-       ;; yuck. perhaps we should bring the filenames into sync?
-       ((string= req "erc-capab-identify")
-        (setq req "erc-capab"))
-       ((string= req "erc-completion")
-        (setq req "erc-pcomplete"))
-       ((string= req "erc-pcomplete")
-        (setq mod 'completion))
-       ((string= req "erc-autojoin")
-        (setq req "erc-join")))
-      (condition-case nil
-          (require (intern req))
-        (error nil))
+      (require (or (alist-get mod erc--modules-to-features)
+                   (intern (concat "erc-" (symbol-name mod))))
+               nil 'noerror) ; some modules don't have a corresponding feature
       (let ((sym (intern-soft (concat "erc-" (symbol-name mod) "-mode"))))
-        (if (fboundp sym)
+        (unless (and sym (fboundp sym))
+          (error "`%s' is not a known ERC module" mod))
+        (if (custom-variable-p sym)
             (funcall sym 1)
-          (error "`%s' is not a known ERC module" mod))))))
+          (push sym local-modules))))
+    local-modules))
 
 (defun erc-setup-buffer (buffer)
   "Consults `erc-join-buffer' to find out how to display `BUFFER'."
@@ -2192,18 +2220,22 @@ erc-open
   (let* ((target (and channel (erc--target-from-string channel)))
          (buffer (erc-get-buffer-create server port nil target id))
          (old-buffer (current-buffer))
-         old-point
+         (old-recon-count erc-server-reconnect-count)
+         (old-point nil)
+         (delayed-modules nil)
          (continued-session (and erc--server-reconnecting
                                  (with-suppressed-warnings
                                      ((obsolete erc-reuse-buffers))
                                    erc-reuse-buffers))))
     (when connect (run-hook-with-args 'erc-before-connect server port nick))
-    (erc-update-modules)
     (set-buffer buffer)
     (setq old-point (point))
-    (let ((old-recon-count erc-server-reconnect-count))
-      (erc-mode)
-      (setq erc-server-reconnect-count old-recon-count))
+    (setq delayed-modules (erc-update-modules))
+
+    (delay-mode-hooks (erc-mode))
+
+    (setq erc-server-reconnect-count old-recon-count)
+
     (when (setq erc-server-connected (not connect))
       (setq erc-server-announced-name
             (buffer-local-value 'erc-server-announced-name old-buffer)))
@@ -2266,6 +2298,12 @@ erc-open
     (setq erc-dbuf
           (when erc-log-p
             (get-buffer-create (concat "*ERC-DEBUG: " server "*"))))
+
+    (erc-determine-parameters server port nick full-name user passwd)
+
+    (save-excursion (run-mode-hooks))
+    (dolist (mod delayed-modules) (funcall mod +1))
+
     ;; set up prompt
     (unless continued-session
       (goto-char (point-max))
@@ -2277,8 +2315,6 @@ erc-open
       (erc-display-prompt)
       (goto-char (point-max)))
 
-    (erc-determine-parameters server port nick full-name user passwd)
-
     ;; Saving log file on exit
     (run-hook-with-args 'erc-connect-pre-hook buffer)
 
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index b2ed29e80e..d3d319ab22 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -975,4 +975,51 @@ erc-message
     (kill-buffer "ExampleNet")
     (kill-buffer "#chan")))
 
+(ert-deftest erc-migrate-modules ()
+  (should (equal (erc-migrate-modules '(autojoin timestamp button))
+                 '(autojoin stamp button)))
+  ;; Default unchanged
+  (should (equal (erc-migrate-modules erc-modules) erc-modules)))
+
+(ert-deftest erc-update-modules ()
+  (let* (calls
+         (erc-modules '(fake-foo fake-bar)))
+    (cl-letf (((symbol-function 'require)
+               (lambda (s &rest _) (push s calls)))
+              ((symbol-function 'erc-fake-foo-mode)
+               (lambda (n) (push (cons 'fake-foo n) calls)))
+              ;; Here, foo is a global module (minor mode)
+              ((get 'erc-fake-foo-mode 'standard-value) #'ignore)
+              ((symbol-function 'erc-fake-bar-mode)
+               (lambda (n) (push (cons 'fake-bar n) calls)))
+              ((symbol-function 'erc-autojoin-mode)
+               (lambda (n) (push (cons 'autojoin n) calls)))
+              ((get 'erc-autojoin-mode 'standard-value) #'ignore)
+              ((symbol-function 'erc-networks-mode)
+               (lambda (n) (push (cons 'networks n) calls)))
+              ((symbol-function 'erc-completion-mode)
+               (lambda (n) (push (cons 'completion n) calls)))
+              ((get 'erc-completion-mode 'standard-value) #'ignore))
+
+      (ert-info ("Locals")
+        (should (equal (erc-update-modules)
+                       '(erc-fake-bar-mode)))
+        ;; Bar still required
+        (should (equal (nreverse calls) '(erc-fake-foo
+                                          (fake-foo . 1)
+                                          erc-fake-bar)))
+        (setq calls nil))
+
+      (ert-info ("Module name overrides")
+        (setq erc-modules '(completion autojoin networks))
+        (should-not (erc-update-modules)) ; no locals
+        (should (equal (nreverse calls)
+                       '(erc-pcomplete
+                         (completion . 1)
+                         erc-join
+                         (autojoin . 1)
+                         erc-networks
+                         (networks . 1))))
+        (setq calls nil)))))
+
 ;;; erc-tests.el ends here
-- 
2.37.2


--=-=-=--




Acknowledgement sent to "J.P." <jp@HIDDEN>:
New bug report received and forwarded. Copy sent to emacs-erc@HIDDEN, bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to emacs-erc@HIDDEN, bug-gnu-emacs@HIDDEN:
bug#57955; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 13 Oct 2022 14:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.