From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Question: loading code when two packages are load? Date: Wed, 08 Sep 2021 16:25:15 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6157"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: "emacs-devel@gnu.org" To: Qiantan Hong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Sep 08 22:26:33 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mO49P-0001PK-Q0 for ged-emacs-devel@m.gmane-mx.org; Wed, 08 Sep 2021 22:26:31 +0200 Original-Received: from localhost ([::1]:47472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mO49O-0008OC-87 for ged-emacs-devel@m.gmane-mx.org; Wed, 08 Sep 2021 16:26:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mO48I-00078l-HZ for emacs-devel@gnu.org; Wed, 08 Sep 2021 16:25:22 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:31962) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mO48G-0003oP-Bk for emacs-devel@gnu.org; Wed, 08 Sep 2021 16:25:21 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 3BB4A4408AF; Wed, 8 Sep 2021 16:25:18 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id BB7FD440921; Wed, 8 Sep 2021 16:25:16 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1631132716; bh=P/A5+2GYF5vPRl9Iw0+1hNaH8nsg7Qv0X8Lh+c43GLI=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=PeTowNduVsHgGSHEy+nWJ+xmBdlBrB1nIop7EV2lvMWFR9J4GGXc0+L6yLWnYL2qF OgQdDWDRrlATdR7R2/L4PKELh0dOr+SASV9S0DYeXmEcPNonugTI9dGBuw0WJOSNzw nCK1Wx4PBmdmy5mplMOPj9skwHpN6KjVMjxOaSv7t74Q+842CF415EjD++F9cISfq7 XcWJCFd0FRTmP5i6m00r2thaxgcUdDUgAbCXJOVIqjzMffQ+tA44UtWpJo4amqB8gg 1WvJ8gwp/rAJE7KhElRnDxTmUVmj0L56unnwMKOH/XEw8MxYZpjQVhRo5BY2JYhX+A U9J5HkEdsdKOw== Original-Received: from pastel (unknown [104.247.244.135]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 8A310120340; Wed, 8 Sep 2021 16:25:16 -0400 (EDT) In-Reply-To: (Qiantan Hong's message of "Wed, 8 Sep 2021 16:06:37 +0000") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:274389 Archived-At: > I=E2=80=99ve been working on the integration of crdt.el with a few other = packages (xscheme.el, comint.el). > Those code only make sense when both crdt.el and the =E2=80=9Cclient=E2= =80=9D package are loaded. > Is there a way to lazy load those code? Some ways to address these kinds of problem: - Move the relevant code to `crdt-.el` and then arrange for `crdt-.el` to be loaded when need for example using an autoloaded `crdt--setup` function and in `crdt.el` you do `(add-hook '-mode-hook 'crdt--setup). - Put the code inside an `with-eval-after-load`. - Just add enough `defvar`s and `declare-function` to silence the warnings. The first solution above is arguably the cleanest, but can be a too heavy if the code of `crdt-.el` is trivial. Stefan