From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#44858: [PATCH] Make byte-compiler warn about wide docstrings Date: Sun, 6 Dec 2020 05:09:45 -0600 Message-ID: References: <83h7pcqjxy.fsf@gnu.org> <87pn3zjivc.fsf@gnus.org> <831rgfotpg.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36019"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 44858@debbugs.gnu.org, larsi@gnus.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 06 12:10:11 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 1klrvf-0009GO-ME for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 06 Dec 2020 12:10:11 +0100 Original-Received: from localhost ([::1]:57794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1klrve-0006Yr-ML for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 06 Dec 2020 06:10:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1klrvW-0006Xy-CN for bug-gnu-emacs@gnu.org; Sun, 06 Dec 2020 06:10:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37467) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1klrvW-0001vS-3y for bug-gnu-emacs@gnu.org; Sun, 06 Dec 2020 06:10:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1klrvV-0008Iv-Ut for bug-gnu-emacs@gnu.org; Sun, 06 Dec 2020 06:10:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 06 Dec 2020 11:10: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.160725299331902 (code B ref 44858); Sun, 06 Dec 2020 11:10:01 +0000 Original-Received: (at 44858) by debbugs.gnu.org; 6 Dec 2020 11:09:53 +0000 Original-Received: from localhost ([127.0.0.1]:49013 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1klrvN-0008IT-85 for submit@debbugs.gnu.org; Sun, 06 Dec 2020 06:09:53 -0500 Original-Received: from mail-pj1-f53.google.com ([209.85.216.53]:54283) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1klrvL-0008IG-Kq for 44858@debbugs.gnu.org; Sun, 06 Dec 2020 06:09:52 -0500 Original-Received: by mail-pj1-f53.google.com with SMTP id f14so5697185pju.4 for <44858@debbugs.gnu.org>; Sun, 06 Dec 2020 03:09:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:in-reply-to:references:mime-version:date :message-id:subject:to:cc; bh=OWdFGowPe7F5IcKOZIYNomJvQ8Rx7Curiv0cHZVzeXU=; b=ctK7FBylG6yb1FLRJMvdKp7cYeK+O8RZikrpgOuPcSvVLFt08WXSS3E2W1xVkTC1LX Myhm7n87EeQlbhO4EAwF4PxcfMufL6l/Dqg4+qoYousv+TPI7umctAJlAVjONJ+Eh62r Izv1tjh7FM155AveLKtQxQYr0/NCa+9dNFpC5ckq5fZQvv7YeI9BaRidRiQAGNDUnzxw /S5nUrM5LGz77iK5J6Ut4f5vk/F8fAaoinjp6cOdC56Qf0NKcORg6UA0mHp+kwjoiirI gc6rjy5v1i54W0ECc/L7ubl6QoqVpn4gb4hK41fSGxj4Ulp/IU/HKLVLkjk0h2Gg2AL2 DI+A== X-Gm-Message-State: AOAM530hsmdjoFVpMyQMRDCLdSWf/n3ChA2Ue0ZQem7KGLuxAFIyUu5Z Tje1CRvGD1DoWirMmVFgQOW1Ng9+tS6HywcPT/0= X-Google-Smtp-Source: ABdhPJwSGmc17mEWdURkf4nKKM9DX4mD9eRA98dl7frhCufGw7Vjjekg9E/93LBzsvnW4RFqtV0rVBl0O+vPrrlYNBg= X-Received: by 2002:a17:902:9b85:b029:da:1684:cc82 with SMTP id y5-20020a1709029b85b02900da1684cc82mr11623522plp.41.1607252985971; Sun, 06 Dec 2020 03:09:45 -0800 (PST) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 6 Dec 2020 05:09:45 -0600 In-Reply-To: <831rgfotpg.fsf@gnu.org> 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:195078 Archived-At: Eli Zaretskii writes: >> > > How about some simplified heuristics, like assume that the expansion >> > > takes no more than N characters (where N could be something like 5)? >> > > This should work in, like, 80% of cases, I think. >> > >> > Yup. And 15% is mostly when it expands to `M-x some-long-command' >> > because the keymap hasn't been loaded yet, I think? Which we could >> > conceivably fix by loading the file when the used `C-h f's an autoloaded >> > function with one of these constructs? Perhaps a bit hacky... >> >> I would be wary of using a heuristic here, because I think false >> positives are worse than false negatives in this case. > > Can we have some numbers, please? how many false positives do you get > by assuming the expanded key sequence takes 5 characters? what about 3 > or 4 or 7? I have run some tests. The first column is the number of characters. The second column is the number of "wide docstring" warnings with my patch. The third column is when I add in warnings for lambda docstrings (commented out in the patch): | Characters | Warnings | Warnings (w/lambda) | |------------+----------+---------------------| | 0 | 109 | 451 | | 1 | 110 | 452 | | 2 | 110 | 452 | | 3 | 110 | 454 | | 5 | 110 | 463 | | 6 | 111 | 468 | | 7 | 111 | 475 | We don't seem to get much additional benefit from a heuristic with a higher number of characters (i.e. not a lot more warnings). I checked some of the warnings when using 7 characters (with lambda), and all new warnings I checked were false positives: help.el:194:1: Warning: docstring wider than 80 characters isearch.el:1001:8: Warning: docstring wider than 80 characters simple.el:5616:8: Warning: docstring wider than 80 characters >> We unfortunately don't have any way of silencing individual >> warnings, so a user seeing a false positive is left with two >> suboptimal choices: ignore the warning (a bad habit to train our >> users in) or change the formatting of a docstring to stop it >> (potentially making it subjectively worse in the process). > > The assumption is that using such heuristic will cause false > negatives, not false positives. Do you see any bad consequences to > false negatives? Not sure what you mean here; my assumption was that it would cause false positives. I see no bad consequences to false negatives, so I'm not overly worried about them. (False negatives are neither worse nor better than the status quo.) >> How about using the somewhat safer heuristic of treating substitutions >> as one character wide? Would that make sense? > > I'd say, at least 3, because there are very few non-trivial key > bindings bound to a single character. AFAIU, if N is the number of characters, N=1 would cause only false negatives. For any N>M, where M is the length of longest command name in use, it would cause only false positives. For any N where N>1 and N