From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Karl Fogel Newsgroups: gmane.emacs.devel Subject: Re: Question: loading code when two packages are load? Date: Wed, 08 Sep 2021 23:25:58 -0500 Message-ID: <87lf46gysp.fsf@red-bean.com> References: <174C424B-3A6E-46E9-B8B5-FCC7C756F22B@mit.edu> Reply-To: Karl Fogel Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1134"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Stefan Monnier , "emacs-devel@gnu.org" To: Qiantan Hong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Sep 09 06:27:15 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 1mOBec-000Aed-7I for ged-emacs-devel@m.gmane-mx.org; Thu, 09 Sep 2021 06:27:14 +0200 Original-Received: from localhost ([::1]:37472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOBea-0007xe-0Y for ged-emacs-devel@m.gmane-mx.org; Thu, 09 Sep 2021 00:27:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOBdW-0007H7-7C for emacs-devel@gnu.org; Thu, 09 Sep 2021 00:26:06 -0400 Original-Received: from sanpietro.red-bean.com ([45.79.25.59]:59690) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOBdR-0006Wq-P3 for emacs-devel@gnu.org; Thu, 09 Sep 2021 00:26:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=red-bean.com; s=202005newsp; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-ID:In-Reply-To:Date:Reply-To:References:Subject:Cc:To: From:Sender:Content-ID:Content-Description; bh=qv8wey1i8QVOCN5QSijsr9e1xhuDmsZspVKOoRzrN0I=; t=1631161561; x=1632371161; b=F2gzCuDV2lAAYZ8LKRQqwg9+n84I8eDVsf8Z4GuiAjiHJE16IeSeZuDh05qT83WC6BFjody+XR8 hHgg5LHQaUwWm9GILwUUDMTlOWs0/vaQZM9e+MG3hKKwcsmShM6Glr/L6Y5JtQzadK/8gNt/zxxMy 6OZW51OJCQZVwr7fI9aMqyFpQCgyNruqbAw1+aJfXEiJ/fAafWsPZV+8c/eXmKc71CyyXtcPVxoNB G5tCasFc+1UN0BT3jnPGOMlijkF7/0Bn/h9J1ygZxjvaabAXxi6vxENZN4psexhH8CQ0VRR1i6eXF k7j5KLpk//SbLspB/Ceyyu67GNF1SHFmTjhA==; Original-Received: from 99-112-125-163.lightspeed.cicril.sbcglobal.net ([99.112.125.163]:45998 helo=floss) by sanpietro.red-bean.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mOBdP-00FCFB-HP; Thu, 09 Sep 2021 04:25:59 +0000 In-Reply-To: <174C424B-3A6E-46E9-B8B5-FCC7C756F22B@mit.edu> (Qiantan Hong's message of "Thu, 9 Sep 2021 02:05:50 +0000") Received-SPF: pass client-ip=45.79.25.59; envelope-from=kfogel@red-bean.com; helo=sanpietro.red-bean.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_PASS=-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:274420 Archived-At: On 09 Sep 2021, Qiantan Hong wrote: >> - Put the code inside an `with-eval-after-load`. > >Thanks! This looks like exactly what I need. >I don=E2=80=99t understand why the manual says >"well-designed Lisp programs should not use with-eval-after-load=E2=80=9D >and advocate for using require though.=20 >Isn=E2=80=99t with-eval-after-load exactly the lazy counterpart of=20 >require? TIL ("Today I Learned") about `with-eval-after-load'! It's a good=20 day :-). >> Would the "autoload" facility solve this problem? > >To my understanding autoload triggers file loading when function=20 >invoked, >while in my case I need to invoke function on file loading=20 >(to augment the behavior of that file). Ah -- I should have read more slowly and thoroughly to grok this,=20 sorry. >It sounds like after-load-functions (although eval-after-load=20 >works as well >because we just need to target some specific packages), >but somehow manual says it=E2=80=99s an =E2=80=9Cabnormal hook=E2=80=9D wh= ich I don=E2=80=99t=20 >really understand. > >The Hooks for Loading info section seems to try very hard to >talk people out of using itself. Heh. When using one of those facilities that Emacs has yet=20 discourages the use of, I usually put a comment explaining why=20 it's really the only solution for that particular situation and=20 how therefore this is one of those rare *appropriate* uses. Best regards, -Karl