From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: steve-humphreys@gmx.com Newsgroups: gmane.emacs.help Subject: Re: Hooks in minor modes Date: Fri, 30 Apr 2021 06:12:19 +0200 Message-ID: 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="18155"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 30 06:13:24 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 1lcKWq-0004eC-DR for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 30 Apr 2021 06:13:24 +0200 Original-Received: from localhost ([::1]:37488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcKWp-0008WT-5A for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 30 Apr 2021 00:13:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55892) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcKVv-0008W7-6W for help-gnu-emacs@gnu.org; Fri, 30 Apr 2021 00:12:27 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:51167) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcKVs-0006DC-5w for help-gnu-emacs@gnu.org; Fri, 30 Apr 2021 00:12:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1619755939; bh=SUha8LVukSZxEy8w+Hv+tps4w4jRYa7kzvnO2OKBfUc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=TDNnBjm+zyH31DSFqL7f0FZ4/Ra9Ng3pHf5XMHOUbDWknyL4kfZOfmCqe7YNo0TVm bjp6SiuskwAwjduUi8LwPFSdxudreAC3rSqV/3QxHLzBq1GdKT2CrUGrwlD1hvDZwQ E2BH0yVoVmwF27uE4XbaPo5lRN1nB3VRkdd5ntIU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [213.165.168.94] ([213.165.168.94]) by web-mail.gmx.net (3c-app-mailcom-bs05.server.lan [172.19.170.173]) (via HTTP); Fri, 30 Apr 2021 06:12:19 +0200 Importance: normal Sensitivity: Normal In-Reply-To: X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:680s+OZ7j/QXIO0lLpqY3gOo5IkmqtIMB/R1EGTVhJjenLUIqhGC/9Cdv2hGrOvMT+z64 xcu6Ys8A8rqo4lFUWvAqUBu5haRqg/ACriGZrnQPCzbfi/3HhVl8eamuQoZym38vHAnSa1z+/dkR KalDuGjtunwCEXbel6khWa9WOj4DjwjdGxYtLlwvcAc8SHhPro8Qc1e23d75K1vvDvLHqncMF8SY JPMQYV8NMYXMenh79esV3xnN1zNhgvRFM4iF6RLpXkgmyp1WOw+5HTx8+RzTPs879URw8yP2MQur Og= X-UI-Out-Filterresults: notjunk:1;V03:K0:udVMttsv3fw=:3WHE6NbHetIzpC+jxeRFUn WDEagkQRKFw2zAr88tSbmTV5s6oCE09akTJCIIE4zMT8EROnddAsrm7CSjlxJRxnc5s+T1dQq CPK3/zelWB5xHTb21rQfAv5uynGkfXgJnEl5pNSTzea0U7io0/BHtVuMAV1mTjnQtVEC+635u ujkKgHiNbHFaSbvDgzYksRij5la0yffN7mrDiKGX7q9+MUC+KJDr4v6JRCKXeNVQDBq+3DMMW sFybvp2c3t2RGyPmKUvnFxeKsAiH5GX+q4yz5uTpobwnWUiiG3oTrLJ3AVHLBhDlP128ZL1l3 gqyVXrI6Z4DU3WhTvRz4SeyM2hFzmXhGxf6qnpCM0BfRoF78CElimxSxSbmTVy3Lk+7dGhPYj R6s891f0I9FecCOA/OCkqThy5XMxt+tH0RVzU4xZY8d5fVVIpN6lQcMjyZrDE7JNaQ8SN8z+/ rb5oDkY/RzY3tHXIEoPSGjsboO0bHZV4M5sDn2yObO5X8+SGF5MQP0n7ZDHNLFPiWpv4YI+hF xTcDWlR96TZJQnF5/NGCYPoADRHeEWU+zV2KWBXKyjbaQBg2aFmDIfPebQuhkA3Ck1WuVv241 2aIiPtcssRyRqlIt/QCj2WmXWL7K7Loq0PnwINZ9VeoDcMAtmtV89B3e3erxmsX1H3GLYhogg c3rKj4HD6oZUOSL51io+WFgNYe32F0ULFbnp/UOewxQiFEW6WtrqtKPKziCOpnUirrXVJswgM jiqhaa31IXXLzHW0a9+r3HuzNfd2spX/K40Ch+1rJh8bp+y1h/xxyz4vWqd6SqwblYuZHVyW Received-SPF: pass client-ip=212.227.17.22; envelope-from=steve-humphreys@gmx.com; helo=mout.gmx.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.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:129203 Archived-At: That would mean that simply calling (require 'my-minor-mode) would not automatically activate the functionality provided by 'my-minor-mode', unless the user specifically calls another function called 'activate-my-minor-mode'. 'my-minor-mode' is a top-level mode that calls other elisp files for accessing a range of functionalities (e.g. other minor-modes for various programming languages and additional utilities for colour highlighting, traversing text, auto-completion and so on). Quite suitable for new users because they can simply call just the following two commands. (require 'my-minor-mode) (activate-my-minor-mode) > Sent: Friday, April 30, 2021 at 3:31 PM > From: "Stefan Monnier" > To: help-gnu-emacs@gnu.org > Subject: Re: Hooks in minor modes > > > Is it acceptable to set mode hooks in a minor mode so that the minor > > mode is available by default, rather than requiring the user to includ= e > > > > (add-hook 'texinfo-mode-hook 'my-minor-mode)) > > Depends when you do that and it likely depends whom you ask. > > The convention that we strongly encourage to follow is that *loading* an > ELisp file should not noticeably change Emacs's behavior (among other > things, because files may be loaded without the user's explicit > request). So doing such an `add-hook` at the top-level of your file > would probably not be considered as acceptable from that point of view > (unless activating `my-minor-mode` by default has no visible effect, > which is definitely possible but unusual). > > > Stefan > > >