From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.help Subject: Re: with-eval-after-load with sh-mode Date: Fri, 02 Jul 2021 15:08:33 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28302"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: lisa-asket@perso.be Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 02 15:13:54 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 1lzIzR-00075D-KD for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 02 Jul 2021 15:13:53 +0200 Original-Received: from localhost ([::1]:57706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lzIzQ-00046y-L2 for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 02 Jul 2021 09:13:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzIuP-0002zl-RW for help-gnu-emacs@gnu.org; Fri, 02 Jul 2021 09:08:42 -0400 Original-Received: from mail-oln040092065059.outbound.protection.outlook.com ([40.92.65.59]:27458 helo=EUR01-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzIuL-0002Aj-A9 for help-gnu-emacs@gnu.org; Fri, 02 Jul 2021 09:08:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PHaZBIWzwzUpuVtkAIhIRe0Lqs5H2WEj3yIMoka+jSzqoZ1gAJJ3v0pC+EAwzJGN6AoaHffk6ouDIjVoMewvhFrlxlhJpAL6OyGWFVEtZRij0lzDQfoyZQkaaxbH/ZFoQI2jE0/pNE5aWIFBoCL8K9K16bWZ3mwFsuTSGHGtLkrGSAyjf8vd3W/dCI823A9r6jwjlPIgs9dWFeoH6OwTn5RIsZZIAJJNovJ+DMTPQikn2Vo/5UARR8diO6XpA7I/3NBOlfY/BqnTRswmCA/1K6pdON6eUdAOsrR8LqhSdrglsz5h+o3kq1HWUUJSBEOaAp0+X7xbnozj7ESmC3SHeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=It5gOKbwTnX6J131LA9aUnC4q0zxor0Krcx0CcW9rhs=; b=gsEGMjkZHs0emqXUlUDkP1SPueNBgGjMGlhbX2UUsYqZ5zYv8ZONlHmrfOnmoovcSMYGk7s+9S2Zc1ji1vWUQkFnnZ1AiZj0wwP7vVYQpBzeG49g7BvCyUjvpkmaL948tAGB2Vrq0iHCuYUIdV/sp9JdLWpeNimslgasyv8ERX4CHfjq+HM3P9AX0yTDkEALbfqsCN/XdrweUs+eWlkVY+pHCTsGfgPBKZE6pR9tX4sZerh9K6PY0QFLrhR9SZoFaCYmDd7Jfn1QK4RhWmcByPXuX5wZuePil//zqzycmkUR9C/IqOEDUL2aUJlE4ujbSd86147/vGqtLrfpjw/63g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=It5gOKbwTnX6J131LA9aUnC4q0zxor0Krcx0CcW9rhs=; b=phHfkeck7OkjaVAingZVXDweOn0t5HUHMuvE1GVaiAfjF8oAxyMVOfCI2pQgNjb5KZHgpU3Tvma+wWqQ9N8MNqD9mNQf+lwf1FpR5wRYmD48Av7e4LwrNXh0EBvXkFyTNAANcdMSvIa46O1vfkG47W5XC/qgmPCN54+SbMFctfcX8i11N/zLBvzKKcDF8kriRIOUKPHpVIPawpn9lHb1RDbMgb/p9FQ3+WSdi97Ptg8voPAsmacN4lr1NWgv+vLMaQXxPLNsRJgveV4MoYmXj6ZXwYBiGhGuCRzBEWqlhtNzxCzhgZ1lxHK13gou1l0ZjbN30wp8ReUy/Uduicirhw== Original-Received: from DB5EUR01FT027.eop-EUR01.prod.protection.outlook.com (2a01:111:e400:7e1a::4f) by DB5EUR01HT052.eop-EUR01.prod.protection.outlook.com (2a01:111:e400:7e1a::184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22; Fri, 2 Jul 2021 13:08:34 +0000 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2a01:111:e400:7e1a::41) by DB5EUR01FT027.mail.protection.outlook.com (2a01:111:e400:7e1a::257) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22 via Frontend Transport; Fri, 2 Jul 2021 13:08:34 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:149ECEE8A52C9419957292D085BE3890AD9E13CB385FB16F0A3C02E033F5332B; UpperCasedChecksum:F0F7CCDDB60503163FBD36DC8303519F9993E624CA42CAA1D5BFFDF24DA7D4F2; SizeAsReceived:7414; Count:46 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::656a:1596:f5dc:12ea]) by AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::656a:1596:f5dc:12ea%7]) with mapi id 15.20.4287.023; Fri, 2 Jul 2021 13:08:34 +0000 In-Reply-To: (lisa-asket@perso.be's message of "Fri, 2 Jul 2021 12:35:16 +0200 (CEST)") X-TMN: [6tOyqAp2hRjF9TgJtVl+dbvUwwr/19io] X-ClientProxiedBy: AM6P195CA0091.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:86::32) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <87y2aoj226.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (81.232.177.30) by AM6P195CA0091.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:86::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.21 via Frontend Transport; Fri, 2 Jul 2021 13:08:33 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 46 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 69af823b-fca1-4ba9-3be0-08d93d5a7efb X-MS-TrafficTypeDiagnostic: DB5EUR01HT052: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RHwEJkixWAXEJnRgO/Xt522n6DH1fS0CvOJDLsgFsRbzCFLGhP4zCX7qe5Sa+ufSt/r9c744z9fMPwaPDPIcSgVgCMf5uNPCTFvGrjBATmJPRs14YTA+jca8aax7NZTMw/2IsExzt1CcVGpU7bwq2okvyARCm8yeJVIe18uR3TxkuVmT4mkhzs9sZ3IRSUgvquMliI8qmwA9Dt081Yz141PbY9C1FAHy06Vot+4nbhV+bqWTCjnnRhiRJ2dEH9qJS9IMqz4EbE5kZ15se+7E0NH3C3P1FbZV8b4FULuerAb5EvKkOju1d5Y0Xtn2lJaYwiV7Zi40VTFBeY6pVk2GnhCYwVYY7RzlmBgwNKpuw6a9A4vi18VyKr+5vra1LyCrw2XKLK58pn5aw0frKR9ZsBj6mFdiQUYiz6IhHaNtSPFHCZTm/m3AmayavD5dSddWKQIgSSj/QJE/YN0EJQ3H+q/VPhTM6rtmtGlHJTWd3jOlF9XhEiIidogF+9O/oex99CqePPzoCMSE3RIMxSL/aA== X-MS-Exchange-AntiSpam-MessageData: NZsHWsQIhxxpPKjF30n60XTxuTihMxgkThjr1tsj47EDIcFC/EK3Au4jERj9zaCSKvIA7zsKQq0BDuVv3D1Jhd2dp0uODzBkrDz6IXSb+BM61KZunDIm+OCDs5lTUhxx2v/x4/q55aeLwy15m83Syw== X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69af823b-fca1-4ba9-3be0-08d93d5a7efb X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2021 13:08:34.0552 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: DB5EUR01FT027.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5EUR01HT052 Received-SPF: pass client-ip=40.92.65.59; envelope-from=arthur.miller@live.com; helo=EUR01-HE1-obe.outbound.protection.outlook.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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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:131396 Archived-At: lisa-asket@perso.be writes: >>From: Arthur Miller >>To: lisa-asket@perso.be >>Subject: Re: with-eval-after-load with sh-mode >>Date: 02/07/2021 10:56:14 Europe/Paris >>Cc: help-gnu-emacs@gnu.org > >>lisa-asket@perso.be writes: > >>>From: Arthur Miller >>>To: lisa-asket@perso.be >>>Subject: Re: with-eval-after-load with sh-mode >>>Date: 02/07/2021 10:42:38 Europe/Paris >>>Cc: help-gnu-emacs@gnu.org >> >>>lisa-asket@perso.be writes: >> >>>> How can I use `with-eval-after-load` with sh-mode? >>>> >>>> Basically I want to defer call to sh-mode-map until sh-mode is loaded >>>> >>>> (with-eval-after-load 'sh >> >>>Try this: >> >>>(with-eval-after-load 'sh-script >>>(message "My cool one-time config follows here ...")) >> >>>sh-mode is defined in lisp/progmodes/sh-script.el. >> >> What is the difference between >> >> (with-eval-after-load 'sh-script >> (myfun)) >> >> and >> >> (add-hook 'sh-mode-hook #'myfun) > >>Obviously sh-mode-hook gets executed every time you load sh-mode, i.e, >>when you open a shell file. > >>eval after load will kick in when feature is loaded, i.e. when you read >>in (load or require) sh-script.el, so it least in theory it should get >>executed only once, unless you unload feature 'sh-script for some reason. > > This leads to another consideraion. There are certainly advantages about using > `with-eval-after-load`. But, then, what are the circumstances for using `add-hook`? As said above: the circustance is when you wish a piece of code to run every time a mode is loaded. You should probably read the fine manual: https://www.gnu.org/software/emacs/manual/html_node/emacs/Hooks.html https://www.gnu.org/software/emacs/manual/html_node/elisp/Hooks-for-Loading.html