From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: Nested `with-eval-after-load'? Date: Wed, 12 Aug 2015 19:21:40 +0200 Message-ID: <87zj1wo21n.fsf@web.de> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1439400691 27096 80.91.229.3 (12 Aug 2015 17:31:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Aug 2015 17:31:31 +0000 (UTC) Cc: help-gnu-emacs To: Alexander Shukaev Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 12 19:31:24 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZPZs3-0003hE-Na for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Aug 2015 19:31:23 +0200 Original-Received: from localhost ([::1]:39672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPZs3-0007dJ-5M for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Aug 2015 13:31:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPZin-00014P-4U for help-gnu-emacs@gnu.org; Wed, 12 Aug 2015 13:21:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZPZii-0002z0-VI for help-gnu-emacs@gnu.org; Wed, 12 Aug 2015 13:21:49 -0400 Original-Received: from mout.web.de ([212.227.15.3]:53216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPZii-0002yC-MN for help-gnu-emacs@gnu.org; Wed, 12 Aug 2015 13:21:44 -0400 Original-Received: from drachen.dragon ([90.186.149.125]) by smtp.web.de (mrweb002) with ESMTPSA (Nemesis) id 0MQO44-1ZFnA22Tro-00Tjvr; Wed, 12 Aug 2015 19:21:42 +0200 In-Reply-To: (Alexander Shukaev's message of "Mon, 10 Aug 2015 22:13:24 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-Provags-ID: V03:K0:Idp27HnoCbBZ4RPlz8qhSp8uEsBZQW9jelobPdXvPg4XDu/qn4m dwMm6HtBIS89xwfu5VF4o1e+Jy/ekFMx94vLWTzhBBSOiJZgjd/9sHgqRS+ck79QbAIlkQb rHtujJI28Pz95wCJWYgVkERawlHcJBTKasN1Fgm98sj3fzeA3GMV0uiStUJSpH3D5yU+oKw PscVGIpSM1apiNE4cV+ZA== X-UI-Out-Filterresults: notjunk:1;V01:K0:kq7qWFXz62M=:uUQd1aPD1G5EwP8TU1ONzs YBAugMqCpE5zxZEcSRYHTUqi9lF76WywTIlFQohnLQsUHQ7xXnswX/lZoDB7nRwGECtJ2n31m YYvSMqiqLFrDMwoKuhVkj4RZ1yMQB4XBpuwiKxXuPix5Ud1Zaka3isiap/Gl2QAGG26p/momW ezCMcD+rPrlYU0hXibNPIPRnvLLzq8oU13SZ7bFWPuAh7vfSZJdJDIWD0kmI7ZTLf1lcGfnvS Cib1Ra7fpeTgHb6l8hwPNVSyooHG5o8z60soDpbybrN8HyEwMlRsiJGzDeX1oLNBaUaIhsB7d eCRQDSshiVuGfoCPMs1H9ex5w7oTapOO8Zx8RdS1j5v9GJss/vlddEPLH1tJhD63j03k05JC3 hjSp5G7bjEn7YgZEA20QXHyr94iH26h7gDy3ztlts5mVjzlg95dRb23LMYg8vv+0xexFFusSu tuUsY6GJZ6njrhGGrWhgwzVw8kgwcQ0VgiC9lyJnp5Tg5+f97RlOxpM/WCLonSdt9G6C41QZW bQO7hmHbMqnX7LJ1hPYn7HjyPcsA8W/s9m8ILwrij+8rpn6CLEmjQVafrgOdJYR0HstqqY4Vm t1oww/6C2vHl8eW2tq7BxPOiwELPLMSgvFY0Y8uXlc/ZMQSwEiRcfvmy8OkRwULRhFDxAFzxj G2XG2SQcUOjnyEIccBFckMtHKDjIhQWdKy+Uq5w63TRUmHRAHlaaunYxR/CtcldjZYQzLHpcP k/Y4L1oXErRNn1jTmqSith41v72rUGtaW9idww== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 212.227.15.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:106511 Archived-At: Alexander Shukaev writes: > Hello, > > is nested `with-eval-after-load' considered a bad practice? At least I would try to avoid that where I can. > I'm curious because of the following > > (with-eval-after-load 'x > (with-eval-after-load 'y > (message "Hello, World!"))) > > (require 'x) > (require 'y) > ;; prints "Hello, World!" > (unload-feature 'x) > (require 'x) > ;; prints "Hello, World!" > ;; prints "Hello, World!" > > Is this true that "Hello, World!" would be printed 2 times after > reloading (i.e. the same after-load routine would be added twice for > the `y' package)? In this example I think you get only one "Hello, World!" at the end, not two. When you do the second (require 'x) call, there is an entry for each x and y in `after-load-alist'. The entry for y is irrelevant since you don't reload y. So, after the second (require 'x), (with-eval-after-load 'y (message "Hello, World!")) is executed. And because y is already loaded, you get one "Hello, World!" message. For your question about adding duplicates: `with-eval-after-load' builds a function and adds it to `after-load-alist'. Normally, `with-eval-after-load' tries to avoid to add duplicates of one and the same function (it tests for presence with `equal' before adding any function in the according alist value). But note that `with-eval-after-load' unconditionally executes any code when the according feature is already present (like in your example). So, your question is too general to give a more concrete answer. What is your real-life problem? Michael.