From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Omar Polo Newsgroups: gmane.emacs.help Subject: Re: About the usage of `with-eval-after-load'. Date: Sat, 18 Sep 2021 12:28:16 +0200 Message-ID: <87mtoaqio8.fsf@omarpolo.com> 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="19627"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.6.6; emacs 28.0.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:32:43 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 1mRXeF-0004t8-5N for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 18 Sep 2021 12:32:43 +0200 Original-Received: from localhost ([::1]:39064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRXeC-0004jb-Ea for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 18 Sep 2021 06:32:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRXd6-0004jA-9N for help-gnu-emacs@gnu.org; Sat, 18 Sep 2021 06:31:32 -0400 Original-Received: from mail.omarpolo.com ([144.91.116.244]:58866) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRXd3-00048V-N1 for help-gnu-emacs@gnu.org; Sat, 18 Sep 2021 06:31:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omarpolo.com; s=20200327; t=1631961082; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ih5pT5J7CYhnbAef5LoLi1/76ad2YBrK42Hg/Jl4eSk=; b=rYJTZVPRx4KFCaOZsCNPwO5tOHKNOewUMJoBiRr6eyhMOQTxJfdEWK741Zea422pq0E1wv mno8WIlL/ptkAy97cve6CAN7376dJjOZZUmNf8WGh8UOVhTmM7WPICwF9redhOFnCqcqWw 39DNmek3F6GkHTFmBxB5Cu2NVaNR/Sg= Original-Received: from localhost (host-79-50-237-28.retail.telecomitalia.it [79.50.237.28]) by mail.omarpolo.com (OpenSMTPD) with ESMTPSA id 6d97e34f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 18 Sep 2021 12:31:21 +0200 (CEST) Original-Received: from venera (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 19aaa649; Sat, 18 Sep 2021 12:31:19 +0200 (CEST) In-reply-to: Received-SPF: pass client-ip=144.91.116.244; envelope-from=op@omarpolo.com; helo=mail.omarpolo.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-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:133082 Archived-At: h Hongyi Zhao writes: > `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") > ) this is wrong. as the signature says, it accepts a first argument "file" and then the body to execute. here, it seems that you want to execute something when `python' is loaded and something else when `elpy' is loaded, which warrants two `with-eval-after-load': (with-eval-after-load 'python (define-key ...) (add-to-list ...)) (with-eval-after-load 'elpy (pyvenv-activate ...)) Other than that, I don't usually write python so can't comment further on the code > Is there anything wrong with my understanding of this macro? Any hints > will be helpful. > > Regards Cheers,