From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Platon Pronko Newsgroups: gmane.emacs.help Subject: Re: add-hook without need for intermediate functions Date: Sat, 10 Jun 2023 16:20:48 +0800 Message-ID: <86d4a1ab-3214-f8be-62f2-2f68c9ae1cf2@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13687"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 To: uzibalqa , uzibalqa via Users list for the GNU Emacs text editor Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 10 10:21:45 2023 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 1q7tqz-0003SN-1r for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 10 Jun 2023 10:21:45 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7tqE-0008BH-Ti; Sat, 10 Jun 2023 04:20:58 -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 1q7tqC-0008B5-GF for help-gnu-emacs@gnu.org; Sat, 10 Jun 2023 04:20:56 -0400 Original-Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q7tqA-0001R0-Jc for help-gnu-emacs@gnu.org; Sat, 10 Jun 2023 04:20:56 -0400 Original-Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-650c89c7e4fso2753548b3a.0 for ; Sat, 10 Jun 2023 01:20:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686385253; x=1688977253; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=PDsLiOxjzgMczLr4o+lSH1J+dPD/DUgbikfDnewn218=; b=INEq7bkRjXiEF1wewq727F2VLKtxaGs3q07ZSs13pJHWykURx6P6a5cH4eUcMJIuo5 XmcDZhSoLcHZ3e4TY3G+FUpiCGE9Swg9IBiVAkPSVEp96CGE4e9CHxAuvbmhcNNl6qzd 8OAbACt2Vt16kbXqXZ57npXkMDuo09X9HMezCLMh9NCKQLnEPV6piRqGDItahAQIFbvo cU6Mlr80MUhQreJOb0mt36iM0AcM3B6O81SvZF8pimEchhN5LYOOwdN3bo2qmz32NAJi 9CYZEJ86/LzKJdB7V9+nETlMKMCVDJMbIXO0Z5w9/5DHRMs8DbsP3fZ66oADXF/8AjJV S59g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686385253; x=1688977253; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PDsLiOxjzgMczLr4o+lSH1J+dPD/DUgbikfDnewn218=; b=FnspYQG/vqaQNOz4YxvFy20r1KNKrAub4ZqdRiP8A1LkygAx+eYoin0E3hvX/JIwSH bxUtaA9o6EPowKawoQsyTyDERo9a5SX9m13GFtL2GVYTN77hX/RA/dbtIahjj3MytVow +jkrwbeVn82q6cbpEdKNIKai0bNHD7RKb0qYbTuqg3fLmESpO2h2OgkIVnmUxKJ3qClK +bEgBay5mugqEPNHymcmdp1QdqXKq0Wl+bLsuC1e+/tlwvKLqqRCe2VcwWcQFEP0oG7R cP5smczuWuaV87+jXB9XnrknMk3NTGW2YlqxVGzXx8CdaV+xPz1Wq3LzQARzL6YzSq1/ CTLQ== X-Gm-Message-State: AC+VfDxSVecSh9lEmhcFw7wZWTYl02R8Jxqqia/dq00sjFCQ/a7Zedei 4vwMHCTK4Wp5Xfv2jH+hvBv538MIZ/M= X-Google-Smtp-Source: ACHHUZ5t/I0GF//3O9p0dR3HAFYjMVHore2+VxI5AZc7aRQsMvGPjit/Cg7P8G9bexe9ZsgIIOx04Q== X-Received: by 2002:a05:6a21:670a:b0:10b:fe06:97dd with SMTP id wh10-20020a056a21670a00b0010bfe0697ddmr3546625pzb.54.1686385252649; Sat, 10 Jun 2023 01:20:52 -0700 (PDT) Original-Received: from [192.163.0.137] ([103.24.106.35]) by smtp.gmail.com with ESMTPSA id q31-20020a631f5f000000b00520f4ecd71esm3932887pgm.93.2023.06.10.01.20.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 10 Jun 2023 01:20:52 -0700 (PDT) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=platon7pronko@gmail.com; helo=mail-pf1-x432.google.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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, NICE_REPLY_A=-0.09, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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:143905 Archived-At: On 2023-06-09 23:48, uzibalqa wrote: > > I have seen that since Emacs 24.1 one does not need the intermediate 'turn-on-foo-mode' > style functions when using hooks. > > Does this apply to all modes, including minor modes ? > > And thusly one can write > > (add-hook 'emacs-lisp-mode-hook #'foo-minor-mode) > > > foo-minor-mode is just a function, so it is called when hook executes. Any other modes that are turned on via a single function call will also "work". However note that this won't work for your use-case (from previous thread) - hook is called both when mode is turned on, and when it is turned off. So in your code snippet foo-minor-mode will be turned on when emacs-lisp-mode is turned off, which is probably not something you would want. -- Best regards, Platon Pronko PGP 2A62D77A7A2CB94E