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#26564: Document that only functions and not variables can end with "-p" Date: Wed, 19 Apr 2017 10:26:53 -0700 (PDT) Message-ID: 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 1492622907 8101 195.159.176.226 (19 Apr 2017 17:28:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 19 Apr 2017 17:28:27 +0000 (UTC) To: Kaushal Modi , 26564@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Apr 19 19:28:22 2017 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 1d0tOu-0001xx-Tw for geb-bug-gnu-emacs@m.gmane.org; Wed, 19 Apr 2017 19:28:21 +0200 Original-Received: from localhost ([::1]:49532 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0tP0-0006Ce-Rd for geb-bug-gnu-emacs@m.gmane.org; Wed, 19 Apr 2017 13:28:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0tOg-00063o-G7 for bug-gnu-emacs@gnu.org; Wed, 19 Apr 2017 13:28:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0tOc-0004pS-Gq for bug-gnu-emacs@gnu.org; Wed, 19 Apr 2017 13:28:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:59083) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d0tOc-0004pG-Cy for bug-gnu-emacs@gnu.org; Wed, 19 Apr 2017 13:28:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1d0tOc-0006H7-4l for bug-gnu-emacs@gnu.org; Wed, 19 Apr 2017 13:28: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: Wed, 19 Apr 2017 17:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26564 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 26564-submit@debbugs.gnu.org id=B26564.149262282624053 (code B ref 26564); Wed, 19 Apr 2017 17:28:02 +0000 Original-Received: (at 26564) by debbugs.gnu.org; 19 Apr 2017 17:27:06 +0000 Original-Received: from localhost ([127.0.0.1]:57282 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d0tNh-0006Fs-OG for submit@debbugs.gnu.org; Wed, 19 Apr 2017 13:27:06 -0400 Original-Received: from userp1040.oracle.com ([156.151.31.81]:26092) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d0tNf-0006FP-Qy for 26564@debbugs.gnu.org; Wed, 19 Apr 2017 13:27:04 -0400 Original-Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v3JHQuKm019365 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 19 Apr 2017 17:26:57 GMT Original-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id v3JHQuuR004423 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 19 Apr 2017 17:26:56 GMT Original-Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id v3JHQsrZ018856; Wed, 19 Apr 2017 17:26:55 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 12.0.6767.5000 (x86)] X-Source-IP: aserv0021.oracle.com [141.146.126.233] 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:131765 Archived-At: > The discussion on whether variables should end in "-p" came up few time o= n emacs-devel, at least the ones I was part of: >=20 > 1.=C2=A0https://lists.gnu.org/archive/html/emacs-devel/2016-07/msg00734.h= tml > 2.=C2=A0http://lists.gnu.org/archive/html/emacs-devel/2017-04/msg00540.ht= ml >=20 > Doing a rudimentary search in emacs/lisp/ code-base shows a sign of an un= documented convention that predicate functions, functions that return eithe= r nil or non-nil can end in "-p" (if the function name is multi-word, like = nested-alist-p), or just "p" (if the function name is a single word, like s= tringp). >=20 > I ran ag[1] in emacs/lisp: >=20 > 1. 1511 matches -- defuns and defsubsts ending in -p -- ag 'def(un|subst)= \s+[^ ]+-p\s+' --stats > 2. 149 matches -- defvars, defconsts and defcustoms ending in -p -- ag 'd= ef(var|const|custom)\s+[^ ]+-p\s+' --stats =C2=A0 > 3. 65 matches -- Just the user-facing defcustoms -- ag 'defcustom\s+[^ ]+= -p\s+' --stats >=20 > That corroborates that more functions tend to end in "-p" than variables. A better measure would be # of `-p' vs number of NON-`-p', for both functions and variables. But I'm sure that the same result holds: far more `-p' functions than `-p' vars. Stefan, at least, has actively discouraged the use of vars with `-p' names, in emacs-devel. That could partly explain the numbers. Also, there is nothing in the Elisp manual coding conventions about `-p' for var names, so users wouldn't get the idea to do that from the manual. That too could partly explain the numbers. > This bug report is to make a request to incorporate this unspoken rule as= a rule in the Elisp manual. >=20 > What would be the correct section to do so? > > [1]:=C2=A0https://github.com/ggreer/the_silver_searcher FWIW, I disagree with a guideline to not name Boolean vars using `-p'. 1. Variables and functions are already in separate spaces - they can be examined/found separately (`boundp' vs `fboundp'). =20 What do you hope to gain by outlawing/discouraging `-p' for=20 Boolean variable names? It cannot be to avoid confusing a variable and a function, since the those kinds of animal are already separate in Emacs Lisp. 2. A variable is, abstractly (e.g., in a formal abstract data type), a nullary function. It makes just as much sense to name a Boolean variable using `*-p' as it does to name a Boolean function using that convention. Just one opinion. Stefan disagrees, for instance (but with no reasons given). 3. Is there a proposal for a _different_ naming convention for Boolean variables? I'd argue that we should have some such a naming convention. And I'd argue that it should be different for options and non-option variables. I use `-flag' for Boolean options and `-p' for Boolean non-option variables. (I did not come up with the `-flag' convention, BTW. Someone else did, long ago. I thought it was a GNU Emacs convention, (maybe it was?) so I stuck to it. Stefan is not a fan of `-flag' (or any naming convention for vars). 4. There should be some easy way to ask for help on Boolean variables. Better yet would be a way to ask for help on a user option, filtering by defcustom type. FWIW, I have code that does that. It provides help commands that let you show the help for things based on different=20 criteria, and for options that includes the custom type. You can match the type in different ways, depending on the prefix argument: - None: OPTION is defined with TYPE or a subtype of TYPE. TYPE is a regexp. - `C-u': OPTION is defined with TYPE or a subtype of TYPE, or its current value is compatible with TYPE. TYPE is a type definition or its first symbol. - Negative: OPTION is defined with TYPE (exact match). TYPE is a regexp. - Positive: OPTION is defined with TYPE, or its current value is compatible with TYPE. TYPE is a type definition or its first symbol. - Zero: OPTION is defined with TYPE or a subtype of TYPE. TYPE is a type definition or its first symbol. - `C-u C-u': OPTION is defined with TYPE (exact match). TYPE is a type definition or its first symbol. _Without_ such a capability, it should be possible, at a minimum, to get only Boolean options, using a name-pattern match. Again, just one opinion.