From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#44858: [PATCH] Make byte-compiler warn about wide docstrings Date: Fri, 11 Dec 2020 09:53:27 +0200 Message-ID: <83lfe43hjc.fsf@gnu.org> References: <87zh34wfxo.fsf@gnus.org> <87v9dss2ic.fsf@gnus.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20498"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 44858@debbugs.gnu.org, larsi@gnus.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 11 08:54:27 2020 Return-path: Envelope-to: geb-bug-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 1kndFy-0005Dw-J4 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 11 Dec 2020 08:54:26 +0100 Original-Received: from localhost ([::1]:38208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kndFx-0005Yq-Lq for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 11 Dec 2020 02:54:25 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kndFa-0005Y1-7Z for bug-gnu-emacs@gnu.org; Fri, 11 Dec 2020 02:54:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56534) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kndFZ-0000gY-Um for bug-gnu-emacs@gnu.org; Fri, 11 Dec 2020 02:54:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kndFZ-0004F0-SG for bug-gnu-emacs@gnu.org; Fri, 11 Dec 2020 02:54:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 11 Dec 2020 07:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44858 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 44858-submit@debbugs.gnu.org id=B44858.160767323616289 (code B ref 44858); Fri, 11 Dec 2020 07:54:01 +0000 Original-Received: (at 44858) by debbugs.gnu.org; 11 Dec 2020 07:53:56 +0000 Original-Received: from localhost ([127.0.0.1]:39847 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kndFU-0004Ef-Dy for submit@debbugs.gnu.org; Fri, 11 Dec 2020 02:53:56 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:43414) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kndFS-0004ES-My for 44858@debbugs.gnu.org; Fri, 11 Dec 2020 02:53:55 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:57974) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kndFM-0000bb-Pu; Fri, 11 Dec 2020 02:53:48 -0500 Original-Received: from [176.228.60.248] (port=3876 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kndFK-0002VF-JM; Fri, 11 Dec 2020 02:53:47 -0500 In-Reply-To: (message from Stefan Kangas on Thu, 10 Dec 2020 14:59:16 -0600) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:195723 Archived-At: > From: Stefan Kangas > Date: Thu, 10 Dec 2020 14:59:16 -0600 > Cc: 44858@debbugs.gnu.org > > +** byte compiler Please capitalize "Byte". > +*** The byte-compiler now warns about too wide documentation strings. > +By default, it will warn if a documentation string is wider than the > +largest of 80 characters or 'fill-column'. See the new user > +option 'byte-compile-docstring-max-column'. The last sentence will be more useful if you make it more informative, e.g. This is controlled by the new user option 'byte-compile-docstring-max-column'. > +(defvar byte-compile--wide-docstring-substitution-len 3 > + "Substitution width used in `byte-compile--wide-docstring-p'.") The doc string should be more detailed. Let's at least explain what hides behind "substitution", and say that the value is a heuristic. > +(defcustom byte-compile-docstring-max-column 80 > + "Length that a doc string can be before the byte-compiler reports a warning." I suggest "width", not "length", since you both use the former elsewhere, and because "column" goes better with "width". Also, "can be before" is not the clearest way of saying this. I suggest Recommended maximum width of doc string lines. The byte-compiler will emit a warning for doc-string lines wider than this. If `fill-column' has a larger value, it will override this variable. > +(defun byte-compile-docstring-length-warn (form) > + "Warn if documentation string of FORM is too wide. > +It is too wide if it is longer than the largest of `fill-column' > +and `byte-compile-docstring-max-column'." "It is too wide if it is longer" is inaccurate, I think, because we actually test each _line_ of the doc string against the limit, while the above seems to imply the overall length of the doc string (which could be multi-line) is tested. So: It is too wide if some of its lines is wider than the largest of... > --- /dev/null > +++ b/test/lisp/emacs-lisp/bytecomp-resources/warn-long-docstring-autoload.el > @@ -0,0 +1,3 @@ > +;;; -*- lexical-binding: t -*- > +(autoload 'foox "foo" > + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") I see that none of the tests use multi-line doc strings, is that right? If so, I think it would be good to have at least a couple, one where the first line is too wide, and another where some line other than the first is too wide. Also, what about testing the fact that fill-column overrides the value of the new option? Thanks.