From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Christopher Dimech Newsgroups: gmane.emacs.help Subject: Re: Defining minor mode with minor-mode condition Date: Tue, 4 May 2021 15:03:44 +0200 Message-ID: References: <87lf8v560d.fsf@fastmail.fm> 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="35694"; 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 Tue May 04 15:06:03 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 1ldukV-0009D5-Iy for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 04 May 2021 15:06:03 +0200 Original-Received: from localhost ([::1]:45006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldukU-000559-Kc for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 04 May 2021 09:06:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lduiR-0004m4-WF for help-gnu-emacs@gnu.org; Tue, 04 May 2021 09:03:57 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:36265) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lduiL-0003Hf-GU for help-gnu-emacs@gnu.org; Tue, 04 May 2021 09:03:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1620133424; bh=Oa17KjROIGZ3Eutt+DD2Z6q0dB2g1m2AG23zN6wMv3k=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=aqItT3na7rhP/81KoYLHo6dIlJfDahqwRLLou/6CZqMMW5agHFqtW8PoSEePu6oD1 EB6/Bf17TGV2LS6oue8CDnsm8q3yo0WRoCrd6gcadfQJ+7Zb3yNHbGNTgSP5f6h9at b1kC0bc7kFpiTbkxctdvwf8aLc/UemLlWX+beq8c= 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-bs01.server.lan [172.19.170.58]) (via HTTP); Tue, 4 May 2021 15:03:44 +0200 Importance: normal Sensitivity: Normal In-Reply-To: X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:XHMBkJg2vuNkb20rSkfyXcuYDJ6eUjiluy+NE1MZ7IXASC8d7uQbpkmpLYePDay6/R8uT Jpycaz/l9yNyTLyFfkmsXbRlJGj5WlodFWoj45+hWMPongzhysje+n6xFixKPA4EJq0SEV3KUaqu MeRwFNxwTe00Q+KDMEa9s2uJkq8mIEUIm8zdjk1VoHXbb/GksRz/8FIzEvDCTXHjNknRn8vIR3v9 ecMKJ5oMydfu7XeV8EPadTLaweqDLdVnuYkxXXqtGTjMm6yN4asdTvp5PdOvEfeQWUYsc3DdecZx 4g= X-UI-Out-Filterresults: notjunk:1;V03:K0:9oE6Em6Mq6U=:tpEPs/dC2BIywVzpcyPUhh sg1Lepa+tJzca841R5P7vlU8zdeZzupEXDVq7TNNBE3xXW3eL9d11E+tqdQ8xGik3VxSb/yuN o8kllV1aOGh/hvnpdwAi30JpOqCJ1CWizFmg+GkA4tUFpRR9AqYv3Pvd8bF8YMdVIZcZ5Ec96 3H8f8B74G5rMBnpKhj7RbGvr3pqmH9tjMpjO49ysjEsA4bd78d1kQ5QTrZ+VmB7pe47AObIjl 0kvMlplIKtQwcgBHujQ3eEtJOitNb5ghQzohxWzy2zhpypPu+xyz/rnZyCxgm5GeTjf6LZOBS 8qMq7Y4dJuxhznTh0uGuhQhWvAcLcfZ3GDHZV/9QUIZZhEsjlivb60Wxw3Ev7xQNzw6METDMS q1gK9kXzOJTCDZ0E3DSfG1Nem9vAg4E8pG0fOmYun00uh5706teki+bv/fuN/zWYw7vpTgw2R vhn/0E8njmMw8cuE4OjDpEQUn28s5h0OLU+6OwE5JpyVFG7RUTKIZPGq2e1e+x/MIR2S2tPXt uHByXxC5AVB77PbeH4jrxje6elzxiJ2HKKp/9HY0qBlVgLqVkQOtIxsfEDXY/LzKsUSuwLAm0 N/ehVlcX8VXvYfiKI49DUp6WvlVwLreuC0hW2MeBNnZsXrrCUoadgHwsW0dCrzNGHjFV8ZbU8 ywDCGMD0guIqt3bcrvBQ8I9atcYNsY7FDadZ/2QzPl6e559k7VjH65i0iIR7gJ8Q/huqNQs4p uUqtstET7tH0n0mfm5hBn2WZ5vRMfNboI0rjbBNfuig84GzRXy6Vtnzsy11BSuPmlNxKE3DN Received-SPF: pass client-ip=212.227.15.18; envelope-from=dimech@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:129423 Archived-At: > Sent: Wednesday, May 05, 2021 at 12:52 AM > From: "Stefan Monnier" > To: help-gnu-emacs@gnu.org > Subject: Re: Defining minor mode with minor-mode condition > > > ;;;###autoload > > (define-minor-mode crucibulum-minor-mode > > "Minor mode for assisting with superior & inferior typeface." > > :init-value nil > > :global nil > > :lighter " Crucibulum" > > > > (if crucibulum-minor-mode > > (progn > > (enable-texcom-typeface) > > (enable-ricci-notation)) > > (disable-texcom-typeface) > > (disable-ricci-notation))) > > [ Of course those `:foo nil` keyword arguments are redundant. ] > I actually often find it convenient to unconditionally "disable" first: > > (define-minor-mode crucibulum-minor-mode > "Minor mode for assisting with superior & inferior typeface." > :lighter " Crucibulum" > (disable-texcom-typeface) > (disable-ricci-notation) > (when crucibulum-minor-mode > (enable-texcom-typeface) > (enable-ricci-notation))) > > the advantage is to avoid problems where, say, `enable-texcom-typeface` > is not idempotent, so if you call (crucibulum-minor-mode 1) several time= s > you might end up with multiple copies of the same thing added to a list. > - Stefan You make a very good point > > >