From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit-Claudel?= Newsgroups: gmane.emacs.devel Subject: Re: Should mode commands be idempotent? Date: Wed, 20 Sep 2017 00:10:51 +0200 Message-ID: <5358b04b-70cb-bbaf-1887-bd83613e9c2b@gmail.com> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1505859061 3355 195.159.176.226 (19 Sep 2017 22:11:01 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 19 Sep 2017 22:11:01 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 20 00:10:57 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1duQjJ-0000hG-O8 for ged-emacs-devel@m.gmane.org; Wed, 20 Sep 2017 00:10:57 +0200 Original-Received: from localhost ([::1]:45673 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duQjR-0007wC-64 for ged-emacs-devel@m.gmane.org; Tue, 19 Sep 2017 18:11:05 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duQjL-0007vc-DO for emacs-devel@gnu.org; Tue, 19 Sep 2017 18:11:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duQjI-0001Cn-8V for emacs-devel@gnu.org; Tue, 19 Sep 2017 18:10:59 -0400 Original-Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]:47615) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1duQjI-0001BL-1L for emacs-devel@gnu.org; Tue, 19 Sep 2017 18:10:56 -0400 Original-Received: by mail-wm0-x22f.google.com with SMTP id 13so2486797wmq.2 for ; Tue, 19 Sep 2017 15:10:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=b5OvQW4QuG2rGtcnqqt75gk4hmDV7yWTZS/eKJGofAQ=; b=oycw/48fTpA2saSx8BjfsjsPgssTDOEO5x2+w9iwFm8GzqqX7bGnS7LqpxqXdlisvp USmXALLET1x9rHirwX6ppLysulcSlqR68SgkH9niCA/+qHFOsQCK0Gc2HV1lu5cH45za Fw5MS7qO4B0s7tETUV1MFJH4CgzngffoO3y/jMyHisTzAsqjGY+JvFzUzcz0Rxfj/Y7A dll5Az09dcYrTobEexjljxAL2ArVXPWL3ORqwAlIY8uaSTNBQSmAF/IKToQY5HrZeEoI 3bhxLwjFniuZ1P/XJRvgvXjhVgk2nCNkjLviJ1tSPSdenQgd1nQlJ4O8tvYjAUgN3Lge TOTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=b5OvQW4QuG2rGtcnqqt75gk4hmDV7yWTZS/eKJGofAQ=; b=Nr1YOEV4Sc1x8VHuTMB/keO+cSbBmTI+64ssdFBd0zrcaObYtNWEI2qRwTxwKDninV y2VQPGSrziZYU7M85dBMdyoWlCr0PK9vHSwmpM55I3VQyrpJoK3TvhVjvvdQBd5jfgId DK2WsHpeAQcQpXka2vtv5mzIPUjaxxt8kULmKo2ebE9uwHUF29Klr7Rxetx/135UfsRP 1ORw+pDdvh0vWapCSLqVt3TFWwDkjRZVhZK7NTzGchpkrI1dg+TcfzbHII09xOlTCdDE bQqGxAxPs9MHQqkcJLv53AkAioXS5cZM56gwHNFPYPgtLVJ+FrUmmArgFbUBcUqPmrkq EmEA== X-Gm-Message-State: AHPjjUjnZOqlkFvJqPd9LoEdj6lOih3vCy1dlLMgbxJN3tjfVv6Kp66K RSnuurNZk8G+FXqJcSvvukUbgMOl X-Google-Smtp-Source: AOwi7QB38oSKUFdJWNqJPSU1kiP6i8fvFH/yY07G98P5LjJ4YGWrrNAARUzkZF7NpqKYGWlY9fWECg== X-Received: by 10.28.143.203 with SMTP id r194mr2327560wmd.39.1505859053385; Tue, 19 Sep 2017 15:10:53 -0700 (PDT) Original-Received: from [192.168.1.82] (43.225.24.109.rev.sfr.net. [109.24.225.43]) by smtp.gmail.com with ESMTPSA id k52sm320623wrf.62.2017.09.19.15.10.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Sep 2017 15:10:52 -0700 (PDT) In-Reply-To: Content-Language: en-GB X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22f X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:218547 Archived-At: On 2017-09-19 21:58, Philipp Stephani wrote: > I think it's generally expected that mode commands (both major and minor) are reasonably idempotent, i.e. calling them twice should have the same effects as calling them once (unless using 'toggle, of course). However, I couldn't find this requirement in the manual, should it be added to the "Modes" section? I was not aware of this convention :/ Is there a way inside of a minor mode to check if it was already enabled before the current call, short of having a second variable for that? Most modes I've seen just check whether they're enabled or disabled, and do something based on that: (define-minor-mode foo-mode "Foo." :lighter " foo" (if foo-mode (foo-mode-enable) (foo-mode-disable))) This is often not idempotent (see visual-line-mode for a concrete example). Clément.