From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus Newsgroups: gmane.emacs.help Subject: Re: [Question] use-package's :init or :config for enabling modes Date: Sun, 19 May 2024 21:15:07 +0200 Message-ID: References: <87zfslya6d.fsf@rodrigomorales.site> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15925"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: Rodrigo Morales Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 19 21:15:53 2024 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 1s8m0f-0003v5-69 for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 19 May 2024 21:15:53 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s8m08-0003gE-Cq; Sun, 19 May 2024 15:15:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s8m07-0003g3-1X for help-gnu-emacs@gnu.org; Sun, 19 May 2024 15:15:19 -0400 Original-Received: from sonic316-11.consmr.mail.bf2.yahoo.com ([74.6.130.121]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s8m04-0007KE-C8 for help-gnu-emacs@gnu.org; Sun, 19 May 2024 15:15:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1716146114; bh=BfYQcmXnvaFpSOfHhMRW7cQGNF+5ezzpyA2uqkEXCjQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject:Reply-To; b=PnfDcq5cNu/+CQ35TDgNYrR4nSHUZoy9sQjZRituBTQO0bekquX6s2EENLnC5y6jDuk9Dx2MAPfV8dfVsSBCNJWBImuVP2QnkvBPTmx9nR3lFeN3UZo+kKjMB7eRKddxEnrTq16dgBL4/CAM6Bb4+gYgQHa6Li736Z6/mMxywJ42/ugGr5aYHMT7q8y8TJmYzSuVCVeBFkM+OA9LbD5ZJijDpXEcPC5MWXc6JLOPxT1agk4XRzsn2YGikkvHiG6BX4mAbbPhQGW3kQKiU0rsFmV7K69K6/5CCkoklR1VkOZ91vpgoY/jAqj3EOhhQXzsGf2aBW5y2QCOTqzgVsvIwA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1716146114; bh=zn7L1DZa4QNmsOR2x2AqdIYzhe9ZACgmHpJuaECWUK8=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=WaDfWsMm9oH+DlU4ZO/AmORFdsoz0HHAg9dfrl1b/TQ40xW69kyyWSImIMqpCLJeb6Togc8NT3au1MGxOq4ziLRUld/5Nrl7vjrZuD7CFlS0yz2ceYP9lNR3BfHON8cz5uQ9NnBY62iW8uYEY7oRztP+W20OydThuFGX5C/bESs8fE9ks5bZP/nR7HEN2wgnx+Qt2ahsrMOz1mGgt3HK2HWafmbY98y/KLE8PZ/cV4HOHgaG4zD+xT6kOYdXC3pbrGSGVehkX5MIwgKAJk84MQ9brIa7UqRiCx9wTEnp5YddZEFw6S4hqFNfOOgvlqQhGATwYwxSOFIajulBy4Mzow== X-YMail-OSG: 4TrxXG0VM1kpu9hAl2MLL3GngSkyIKq_6g2gWiWxkbcq0aPjOifRAGyZ0f13GP4 4cPtpfjFIlMgV1jehuorJtVnR2_7L_WF.ybNuNmGW4ocNbg5KnKm5W9YyIePdMnssubEhPThUFDU OYjMEV1nliCAbhROZGYzUugv4dTTi8ZlHPTQl4c6Ixnp72I22Xxr_f17RPibCJz2xKBfc.MiAXeg yg3UDJp0yquQ03fGdWTmY5H5cmvasFMVso9_TjW2csQxs6e4BOoCL09Y5Y6WCsqzL4YLlgyCvewG _h74JwtzE8.XxczBPSCKTWJiMdHFMV7C_zzDE1u7skE_2ep2boFbUIV69JYSHJEfafyxyksKfa9N k_11XN03TM9WxYnvr4k4PyPPNpWCgBxo7edZqqDdcj8M2Aab2DFfUAgMnOmLtJnwn05xY8pVK76i EeHeeicHoieBdWBZxy.3eDDPL7kC.yQF2Kf45h1GUK8RwJA9I45PFS6lHi7KLwrYSV0uXFdvkUI. sPb4G0lQ8oCyKXe1IjrJgFVgClHdQd2ivlsdy.7Mg5tO9L6v7qjLRpJn0cGWoHRbQpcK0pW_SH9x jylUWJ90_CveQW_95jWr7te27esUhy6wOdJF8godC7soHffoFO5GrnrRIABvGgGZ8Eggd_4_7EaG i0PZLqF1KmxkvccE_gBxlC3AlYD942USy99aFKjs.wfIrjm_AsoDvyJ93859cg0AUs3.kSEbAGQY QXbzGRH3tshXAHpbjnU57E10kKmulyTeYTFpP5oIWSUu2DyZm3X3PsNp6MWuU7x2PF8RiCdWdNVQ h2y6BcfPiLwAoDbz4sZKGvI8K2NnLk9TuZaLiYTGkl X-Sonic-MF: X-Sonic-ID: 4354e55f-5628-4b9d-97f0-73c2f27c2686 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic316.consmr.mail.bf2.yahoo.com with HTTP; Sun, 19 May 2024 19:15:14 +0000 Original-Received: by hermes--production-ir2-7b99fc9bb6-ctx6m (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 2e8801b941dcbecf08706f11629bb927; Sun, 19 May 2024 19:15:08 +0000 (UTC) Content-Disposition: inline In-Reply-To: <87zfslya6d.fsf@rodrigomorales.site> X-Mailer: WebService/1.1.22356 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Received-SPF: pass client-ip=74.6.130.121; envelope-from=spacibba@aol.com; helo=sonic316-11.consmr.mail.bf2.yahoo.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.29 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-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:146784 Archived-At: Hi: I am not specialist here, but they exist because the :init is ALWAYS executed while loading the init.el, but the :config is executed AFTER loading the package (using eval-after-load). In your example the package is loaded immediately-unconditionally because there is not defer, so, you don't see any difference; but if some package is loaded lazily you will see the difference. When we defer the load (either with the :defer, :command or :keys) the package is lazily loaded using the autoload mecanisms. #+BEGIN_SRC elisp (use-package vertico :defer t :init (message "Call 1") ;; this will execute always :config (message "Call 2") ;; this will execute after M-x vertico-mode (vertico-mode 1)) #+END_SRC Hope this helps, Ergus On Sun, May 19, 2024 at 12:38:02PM GMT, Rodrigo Morales wrote: > >I emptied =~/.config/emacs/init.el= file and I inserted the following sexp and launched Emacs. =vertico-mode= was enabled. > >#+BEGIN_SRC elisp >(use-package vertico > > :config (vertico-mode)) >#+END_SRC > >I emptied =~/.config/emacs/init.el= again and I inserted the following sexp and launched Emacs. =vertico-mode= was enabled. > >#+BEGIN_SRC elisp >(use-package vertico > > :init (vertico-mode)) >#+END_SRC > >As shown above, whether we use =:init= or =:config= both can be used for enabling a mode. So my question is: What's the difference between using =:config= and =:init= for enabling a mode that is defined by a package. > >* System information > >GNU Emacs 29.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.41, cairo version 1.18.0) >