unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 44858@debbugs.gnu.org, larsi@gnus.org
Subject: bug#44858: [PATCH] Make byte-compiler warn about wide docstrings
Date: Sun, 6 Dec 2020 05:09:45 -0600	[thread overview]
Message-ID: <CADwFkmkgqabxXdfPn27ut+G1_t-BNKa07t6WWOuiauWAbmVDLQ@mail.gmail.com> (raw)
In-Reply-To: <831rgfotpg.fsf@gnu.org>

Eli Zaretskii <eliz@gnu.org> 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<M, it would cause both false negatives and false positives.

Using 3 is not significantly better than 1, as the above numbers show.
But we do risk more false positives.  My preference is therefore still
the safer 1, as it will give no false positives.

We could start with 3 or 1 and adjust later as we learn more about how
this heuristic works in practice.  I don't have a very strong opinion,
as I think we will learn more in due time.

WDYT?





  reply	other threads:[~2020-12-06 11:09 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-25  1:36 bug#44858: [PATCH] Make byte-compiler warn about wide docstrings Stefan Kangas
2020-11-26 10:49 ` Lars Ingebrigtsen
2020-11-26 12:46   ` Stefan Kangas
2020-11-26 12:53     ` Lars Ingebrigtsen
2020-12-10 20:59       ` Stefan Kangas
2020-12-10 21:53         ` Stefan Kangas
2020-12-11  8:16           ` Eli Zaretskii
2020-12-11 20:03             ` Stefan Kangas
2020-12-11  7:33         ` Eli Zaretskii
2020-12-11 20:36           ` Stefan Kangas
2020-12-19 11:22             ` Eli Zaretskii
2020-12-19 16:50               ` Stefan Kangas
2020-12-19 17:14                 ` Eli Zaretskii
2020-12-29  1:27                   ` Basil L. Contovounesios
2020-12-29  2:16                     ` Lars Ingebrigtsen
2020-12-19 17:18                 ` Lars Ingebrigtsen
2020-12-19 23:48                   ` Stefan Kangas
2020-12-11  7:53         ` Eli Zaretskii
2020-12-19 23:55           ` Stefan Kangas
2020-12-20 17:53             ` Lars Ingebrigtsen
2020-12-28  5:18               ` Stefan Kangas
2020-12-11 15:13         ` Lars Ingebrigtsen
2020-12-30 12:07       ` Stefan Kangas
2020-12-31  4:42         ` Lars Ingebrigtsen
2020-11-26 14:19 ` Eli Zaretskii
2020-11-27  8:37   ` Lars Ingebrigtsen
2020-11-27 11:15     ` Stefan Kangas
2020-11-27 12:44       ` Eli Zaretskii
2020-12-06 11:09         ` Stefan Kangas [this message]
2020-12-06 11:19           ` Eli Zaretskii
2020-12-06 16:54           ` Drew Adams
2020-11-27 18:36     ` Drew Adams
2020-11-27 18:55       ` Drew Adams
2020-12-03 20:18 ` Tomas Nordin
2020-12-11 20:14   ` Stefan Kangas
2021-09-24 17:25 ` Stefan Kangas
2021-09-25  1:07   ` Lars Ingebrigtsen
2021-09-26 11:38     ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADwFkmkgqabxXdfPn27ut+G1_t-BNKa07t6WWOuiauWAbmVDLQ@mail.gmail.com \
    --to=stefan@marxist.se \
    --cc=44858@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).