From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joost Kremers Newsgroups: gmane.emacs.help Subject: Re: About the usage of `with-eval-after-load'. Date: Sat, 18 Sep 2021 12:40:29 +0200 Message-ID: <87wnnetazo.fsf@fastmail.fm> 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="17065"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.6.3; emacs 27.2.50 Cc: help-gnu-emacs@gnu.org To: Hongyi Zhao Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 18 12:49:39 2021 Return-path: Envelope-to: geh-help-gnu-emacs@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 1mRXua-0004Av-QN for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 18 Sep 2021 12:49:39 +0200 Original-Received: from localhost ([::1]:42452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRXuZ-0007qD-D2 for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 18 Sep 2021 06:49:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50940) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRXu9-0007q1-Dk for help-gnu-emacs@gnu.org; Sat, 18 Sep 2021 06:49:09 -0400 Original-Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:47425) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRXu7-0002KK-Df for help-gnu-emacs@gnu.org; Sat, 18 Sep 2021 06:49:09 -0400 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 631593200900; Sat, 18 Sep 2021 06:49:03 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sat, 18 Sep 2021 06:49:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= references:from:to:cc:subject:date:in-reply-to:message-id :mime-version:content-type:content-transfer-encoding; s=fm1; bh= cYI5RSb6BfQhu0tRk3oaGL7EOaUVYMpowZJLDD9JOcE=; b=jKEYi8z6wZfBQlob hrxFAFXM+z5039iXa2oPkJVNqx3ELbB5JvwxzkU8Lq9eKM1CGgjNfd1bscjU/D2r ddBGflNMctHrrM0xhjp87du822SgAvf2vJWQbRQN+0kfmk88nk5+P7WGXAuzd7Dp E5ieKEYP/VcN7ODB++MtzFHn3T/g9wSAkgVyF+LHm0n7836nPikwlhzSXAGaIrWU 5IbMdUoDRXfh4G+qzwQajKcyRmFCEAA/EwiwEmBrPnE9IQ0/ARxR/OEQBk83Ipm0 qnYfVA+OFPDhTC9quOyiwPJUImyWDBP0kwK8eK2K0ViWSIwqNhJgol21FAGlyqbR FHWVvg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=cYI5RSb6BfQhu0tRk3oaGL7EOaUVYMpowZJLDD9JO cE=; b=myG7X1qhUCrLRy6BtFvvyWY+HATum8yJOlAjq6UCyNB7So7tX4uYqEjcW LX7mEgQbA3FCN0uSGYuaHBJ028RxDmJs72E/vnJxIAhyYu/1oq8lyDZ40/YLKlxy ybPwK2F58ocXqPG46qEqYWpd+IWV70+Xca5fYDrSHWMRR+CS+RT+cY4ISMJYeraC ZWxvEpiKNLeX1tsoSuhH5ySmQlzPmx4ix4EQl6GEE1IVt8rX3z5Tj7IDO2bovrOo 6VAjY6h+uqRYy+5o3TU/yVUmOdElurLxEQWTtlbhlRxKbUSK7FgRzznUD3uDw/Fa 7caNN2p2+uTTCeeFjeY8D8Uhs2qGA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudehkedgfedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfhgfhffvufffjgfkgggtgfesthhqredttderjeenucfhrhhomheplfhoohhs thcumfhrvghmvghrshcuoehjohhoshhtkhhrvghmvghrshesfhgrshhtmhgrihhlrdhfmh eqnecuggftrfgrthhtvghrnhepvddvgfeghfdtiefhvedvvddtjefhleejveeltdelffev hfeijeekhfdutdffgeefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepjhhoohhsthhkrhgvmhgvrhhssehfrghsthhmrghilhdrfhhm X-ME-Proxy: Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 18 Sep 2021 06:49:02 -0400 (EDT) In-reply-to: Received-SPF: pass client-ip=64.147.123.20; envelope-from=joostkremers@fastmail.fm; helo=wout4-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:133083 Archived-At: On Sat, Sep 18 2021, Hongyi Zhao wrote: > `C-h o with-eval-after-load RET' gives the following description: > > with-eval-after-load is a Lisp macro in =E2=80=98subr.el=E2=80=99. > > (with-eval-after-load FILE &rest BODY) > > Execute BODY after FILE is loaded. > FILE is normally a feature name, but it can also be a file name, > in case that file does not provide any feature. See =E2=80=98eval-after-= load=E2=80=99 > for more details about the different forms of FILE and their semantics. > ;;; > > Based on the above explanation, it seems that only one FILE can be > used, but according to my tries, the following code snippet also take > effect: > > (add-hook 'python-mode-hook 'hs-minor-mode) > (with-eval-after-load > "python" > (progn > (define-key python-mode-map (kbd "C-c TAB") 'hs-toggle-hiding) > (add-to-list > 'python-shell-completion-native-disabled-interpreters "jupyter") > ) > > 'elpy (pyvenv-activate "~/.pyenv/versions/datasci") > ) > > Is there anything wrong with my understanding of this macro? Any hints > will be helpful. Remember that in Lisp, a quoted symbol just evaluates to the symbol. So what happens in your code is that when "python.el" is loaded, three sexps are evaluated: the `progn`, the quoted symbol `'elpy` and the call to `pyvenv-activate`. The form *appears* to work because you probably load elpy whenever you open= a Python file, so you don't notice what's really going on. You'd have to experiment with two packages that are completely independent from each othe= r. BTW, `with-eval-after-load` doesn't need `progn`. That was one of the reaso= ns for introducing `with-eval-after-load` as an alternative for `eval-after-lo= ad`. HTH --=20 Joost Kremers Life has its moments