From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#24706: 26.0.50; Minor mode functions should do strict argument type checking Date: Sun, 16 Oct 2016 09:49:32 -0700 (PDT) Message-ID: <75ec3189-08f4-455f-bfa6-f21e1d0454d6@default> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1476636618 23967 195.159.176.226 (16 Oct 2016 16:50:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 16 Oct 2016 16:50:18 +0000 (UTC) Cc: 24706@debbugs.gnu.org, Philipp Stephani To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 16 18:50:14 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1bvodW-00055u-7Y for geb-bug-gnu-emacs@m.gmane.org; Sun, 16 Oct 2016 18:50:10 +0200 Original-Received: from localhost ([::1]:57105 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bvodY-0001vh-CC for geb-bug-gnu-emacs@m.gmane.org; Sun, 16 Oct 2016 12:50:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bvodS-0001uD-Kv for bug-gnu-emacs@gnu.org; Sun, 16 Oct 2016 12:50:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bvodO-0002C1-VI for bug-gnu-emacs@gnu.org; Sun, 16 Oct 2016 12:50:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:57229) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bvodO-0002Bo-RP for bug-gnu-emacs@gnu.org; Sun, 16 Oct 2016 12:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bvodO-0005S4-Cn for bug-gnu-emacs@gnu.org; Sun, 16 Oct 2016 12:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 16 Oct 2016 16:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24706 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24706-submit@debbugs.gnu.org id=B24706.147663658320925 (code B ref 24706); Sun, 16 Oct 2016 16:50:02 +0000 Original-Received: (at 24706) by debbugs.gnu.org; 16 Oct 2016 16:49:43 +0000 Original-Received: from localhost ([127.0.0.1]:35186 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bvod5-0005RR-E1 for submit@debbugs.gnu.org; Sun, 16 Oct 2016 12:49:43 -0400 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:27786) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bvod3-0005RF-LD for 24706@debbugs.gnu.org; Sun, 16 Oct 2016 12:49:41 -0400 Original-Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u9GGnZ9J008634 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 16 Oct 2016 16:49:36 GMT Original-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id u9GGnYWY024773 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 16 Oct 2016 16:49:35 GMT Original-Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u9GGnXVk028145; Sun, 16 Oct 2016 16:49:34 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 12.0.6753.5000 (x86)] X-Source-IP: userv0022.oracle.com [156.151.31.74] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:124555 Archived-At: > >> (define-minor-mode foo-mode nil) > >> its docstring will be > >> > >> "Toggle Foo mode on or off. > >> With a prefix argument ARG, enable Foo mode if ARG is > >> positive, and disable it otherwise. If called from Lisp, enable > >> the mode if ARG is omitted or nil, and toggle it if ARG is =E2=80=98to= ggle=E2=80=99." > >> > >> This appears to indicate that (foo-mode 'banana) > >> should disable foo-mode, but it enables it. > > > > No, it does not suggest that. But to be clearer, it should > > probably explicitly address the non-nil and non-`toggle' case, > > like so: > > > > If called from Lisp, enable the mode if ARG is omitted or > > nil, toggle it if ARG is =E2=80=98toggle=E2=80=99, and disable it if = ARG is > > any other non-nil value. >=20 > If the Lisp description is meant to be exhaustive by itself, we should > cover the numeric case too: >=20 > If called from Lisp, enable the mode if ARG is omitted, nil, or a > positive number; toggle it if ARG is `toggle'; and disable it > otherwise. Yes, and anyway what I wrote was wrong. The doc string of `define-minor-mode' has it right, as does your suggestion: When called from Lisp, the mode command toggles the mode if the argument is `toggle', disables the mode if the argument is a non-positive integer, and enables the mode otherwise (including if the argument is omitted or nil or a positive integer). I'd suggest the same order as in the `define-minor-mode' doc: When called from Lisp: * Toggle the mode if ARG is `toggle'. * Disable it if ARG is a non-positive integer. * Enable it if ARG is anything else. =20