From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Guath Newsgroups: gmane.emacs.bugs Subject: bug#31656: 26.1; `fill-paragraph' malformats in emacs-lisp-mode Date: Fri, 1 Jun 2018 12:36:00 +0200 Message-ID: References: <83sh66g8wb.fsf@gnu.org> <87bmcuc0bo.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000005c65be056d922733" X-Trace: blaine.gmane.org 1527849307 27576 195.159.176.226 (1 Jun 2018 10:35:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 1 Jun 2018 10:35:07 +0000 (UTC) Cc: 31656@debbugs.gnu.org To: npostavs@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jun 01 12:35:02 2018 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 1fOhOg-000749-36 for geb-bug-gnu-emacs@m.gmane.org; Fri, 01 Jun 2018 12:35:02 +0200 Original-Received: from localhost ([::1]:54677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOhQn-0007oc-2L for geb-bug-gnu-emacs@m.gmane.org; Fri, 01 Jun 2018 06:37:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOhQf-0007oV-NZ for bug-gnu-emacs@gnu.org; Fri, 01 Jun 2018 06:37:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOhQd-0001i4-1L for bug-gnu-emacs@gnu.org; Fri, 01 Jun 2018 06:37:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48938) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOhQc-0001hq-TZ for bug-gnu-emacs@gnu.org; Fri, 01 Jun 2018 06:37:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fOhQc-0000MS-G9 for bug-gnu-emacs@gnu.org; Fri, 01 Jun 2018 06:37:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Guath Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 01 Jun 2018 10:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31656 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 31656-submit@debbugs.gnu.org id=B31656.15278493941350 (code B ref 31656); Fri, 01 Jun 2018 10:37:02 +0000 Original-Received: (at 31656) by debbugs.gnu.org; 1 Jun 2018 10:36:34 +0000 Original-Received: from localhost ([127.0.0.1]:56835 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fOhQ9-0000Lh-N7 for submit@debbugs.gnu.org; Fri, 01 Jun 2018 06:36:34 -0400 Original-Received: from [85.112.160.81] (port=43276 helo=mail.automata.se) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fOhQ6-0000LR-Iz for 31656@debbugs.gnu.org; Fri, 01 Jun 2018 06:36:31 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by mail.automata.se (Postfix) with ESMTP id 708BA3A123 for <31656@debbugs.gnu.org>; Fri, 1 Jun 2018 12:36:24 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at lux2.netcamp.se Original-Received: from mail.automata.se ([127.0.0.1]) by localhost (lux2.netcamp.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iWQlsP_rPBOG for <31656@debbugs.gnu.org>; Fri, 1 Jun 2018 12:36:18 +0200 (CEST) Original-Received: from mail-wr0-f181.google.com (mail-wr0-f181.google.com [209.85.128.181]) by mail.automata.se (Postfix) with ESMTPSA id 159603A125 for <31656@debbugs.gnu.org>; Fri, 1 Jun 2018 12:36:17 +0200 (CEST) Original-Received: by mail-wr0-f181.google.com with SMTP id k16-v6so8628682wro.0 for <31656@debbugs.gnu.org>; Fri, 01 Jun 2018 03:36:17 -0700 (PDT) X-Gm-Message-State: ALKqPweJ1G995HzvCXTKDskf2Z3HPUDnM/RDF9IQqCDdf8OzhiWgiRCJ +J8/bqokScpeLgAo8ZHH/GZbOuh3D2VCZz8FExo= X-Google-Smtp-Source: ADUXVKKWYzFroiCWfVIHI+DTRsyXTvnSrnnHsD0lSkGUGMJ6facsxFM8WW8RcU5772rxgISVu65U+h0LOLE7qdNSeOE= X-Received: by 2002:adf:891a:: with SMTP id s26-v6mr7736700wrs.276.1527849376570; Fri, 01 Jun 2018 03:36:16 -0700 (PDT) In-Reply-To: <87bmcuc0bo.fsf@gmail.com> X-Gmail-Original-Message-ID: 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:146814 Archived-At: --0000000000005c65be056d922733 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable The very idea of shadowing the global `fill-column' in the first place breaks the Principle Of Least Astonishment and introduces annoyance and extra work for the user when trying to understand why the explicit setting of `fill-column' is not respected. If it is to be done anyway, it needs to be well motivated and also executed in a correct way. So, I guess my basic question is what value `emacs-lisp-docstring-fill-column' tries to add? It's obviously not aiming to introduce a general shadowing for elisp files only, since that mechanism is already present due to `fill-column' being buffer local. Rather, according to its docs, it tries to add selective shadowing for elisp-files in doc strings only. Fair enough, that is an edge case where a shadowing mechanism could be motivated. But instead it implements some kind of unpredictable shadowing - I don't even understand in what exact circumstances the shadowing takes place. If we were to just update its docs, what should it be updated to? To me this entire functionality should either be removed or fixed so that its behavior reflects its current docs. In its current state it just malformats elisp files in unexpected ways. Or am I missing something? On Fri, Jun 1, 2018 at 11:39 AM Noam Postavsky wrote: > Eli Zaretskii writes: > > >> From: Stefan Guath > >> Date: Wed, 30 May 2018 14:50:01 +0200 > >> > >> `emacs-lisp-docstring-fill-column' shadows `fill-column' in too many > cases in emacs-lisp-mode. The > >> documentation of `emacs-lisp-docstring-fill-column' states: "Value of > =E2=80=98fill-column=E2=80=99 to use when filling a > >> docstring". But it incorrectly seems to be used in a lot more cases > than just in a docstring (the only case that > >> I've found where =E2=80=98fill-column=E2=80=99 is actually respected i= s within > comments). A work-around is to set > >> `emacs-lisp-docstring-fill-column' to nil, but it would be nice to hav= e > it working properly instead. > >> > >> I might be missing something, but think the incorrect behavior is to b= e > found in `lisp-fill-paragraph' that is > >> invoked by `fill-paragraph' through `fill-paragraph-function'. It seem= s > like `lisp-fill-paragraph' unconditionally > >> sets `fill-column' to `emacs-lisp-docstring-fill-column' without > checking whether point is within a doc string > >> first. The only requirements for enable shadowing currently seems to b= e > "(and (integerp > >> emacs-lisp-docstring-fill-column) (derived-mode-p 'emacs-lisp-mode))", > which doesn't seems sufficient. > > > > AFAICT, this behavior was in Emacs since about forever (since 1995, t > > be precise). So maybe we just need to adjust the doc string to > > reflect the reality? > > > > Or are there real-life use cases where this behavior is grossly > > inappropriate? > > I don't think it makes sense to apply normal plain text filling rules to > code. Maybe it doesn't come up much because people don't usually call > M-q on code, and usually lines of code are kept short enough that they > wouldn't get filled anyway. But picking a random example from rgrep > ^.\{100,\}$ on the Emacs code base: > > (defun feedmail-default-date-generator (maybe-file) > "Default function for generating Date: header contents." > (feedmail-say-debug ">in-> feedmail-default-date-generator") > (when maybe-file > (feedmail-say-debug (concat "4 cre " (feedmail-rfc822-date (nth 4 > (file-attributes maybe-file))))) > (feedmail-say-debug (concat "5 mod " (feedmail-rfc822-date (nth 5 > (file-attributes maybe-file))))) > (feedmail-say-debug (concat "6 sta " (feedmail-rfc822-date (nth 6 > (file-attributes maybe-file)))))) > (let ((date-time)) > (if (and (not feedmail-queue-use-send-time-for-date) maybe-file) > (setq date-time (nth 5 (file-attributes maybe-file)))) > (feedmail-rfc822-date date-time)) > ) > > Running M-q on every line turns it into this nonsense: > > (defun feedmail-default-date-generator (maybe-file) > "Default function for generating Date: header contents." > (feedmail-say-debug ">in-> feedmail-default-date-generator") > (when maybe-file > (feedmail-say-debug (concat "4 > cre " (feedmail-rfc822-date (nth 4 (file-attributes > maybe-file))))) > (feedmail-say-debug (concat "5 > mod " (feedmail-rfc822-date (nth 5 (file-attributes > maybe-file))))) > (feedmail-say-debug (concat "6 > sta " (feedmail-rfc822-date (nth 6 (file-attributes > maybe-file)))))) > (let ((date-time)) > (if (and (not feedmail-queue-use-send-time-for-date) > maybe-file) > (setq date-time (nth 5 (file-attributes maybe-file)))) > (feedmail-rfc822-date date-time)) ) > --0000000000005c65be056d922733 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
The very idea of shadowing the global `fill-column= 9; in the first=20 place breaks the Principle Of Least Astonishment and introduces=20 annoyance and extra work for the user when trying to understand why the=20 explicit setting of `fill-column' is not respected. If it is to be done= =20 anyway, it needs to be well motivated and also executed in a correct=20 way.

So, I guess my basic question is what=20 value `emacs-lisp-docstring-fill-column' tries to add? It's obvious= ly not aiming to introduce a general shadowing for elisp files only, since = that mechanism is already present due to `fill-column' being buffer loc= al. Rather, according to=20 its docs, it tries to add selective shadowing for elisp-files in doc=20 strings only. Fair enough, that is an edge case where a shadowing=20 mechanism could be motivated. But instead it implements some kind of unpred= ictable shadowing - I don't even understand in what exact circumstances= the shadowing takes place. If we were to just update its docs, what should= it be updated to?

To me this entire functiona= lity should either be removed or fixed so that its behavior reflects its cu= rrent docs. In its current state it just malformats elisp files in unexpect= ed ways. Or am I missing something?


On Fri, Jun 1, 2018 at 11:39 AM Noam= Postavsky <npostavs@gmail.com= > wrote:
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Stefan Guath <stefan@automata.se>
>> Date: Wed, 30 May 2018 14:50:01 +0200
>>
>> `emacs-lisp-docstring-fill-column' shadows `fill-column' i= n too many cases in emacs-lisp-mode. The
>> documentation of `emacs-lisp-docstring-fill-column' states: &q= uot;Value of =E2=80=98fill-column=E2=80=99 to use when filling a
>> docstring". But it incorrectly seems to be used in a lot more= cases than just in a docstring (the only case that
>> I've found where =E2=80=98fill-column=E2=80=99 is actually res= pected is within comments). A work-around is to set
>> `emacs-lisp-docstring-fill-column' to nil, but it would be nic= e to have it working properly instead.
>>
>> I might be missing something, but think the incorrect behavior is = to be found in `lisp-fill-paragraph' that is
>> invoked by `fill-paragraph' through `fill-paragraph-function&#= 39;. It seems like `lisp-fill-paragraph' unconditionally
>> sets `fill-column' to `emacs-lisp-docstring-fill-column' w= ithout checking whether point is within a doc string
>> first. The only requirements for enable shadowing currently seems = to be "(and (integerp
>> emacs-lisp-docstring-fill-column) (derived-mode-p 'emacs-lisp-= mode))", which doesn't seems sufficient.
>
> AFAICT, this behavior was in Emacs since about forever (since 1995, t<= br> > be precise).=C2=A0 So maybe we just need to adjust the doc string to > reflect the reality?
>
> Or are there real-life use cases where this behavior is grossly
> inappropriate?

I don't think it makes sense to apply normal plain text filling rules t= o
code.=C2=A0 Maybe it doesn't come up much because people don't usua= lly call
M-q on code, and usually lines of code are kept short enough that they
wouldn't get filled anyway.=C2=A0 But picking a random example from rgr= ep
^.\{100,\}$ on the Emacs code base:

(defun feedmail-default-date-generator (maybe-file)
=C2=A0 "Default function for generating Date: header contents." =C2=A0 (feedmail-say-debug ">in-> feedmail-default-date-generato= r")
=C2=A0 (when maybe-file
=C2=A0 =C2=A0 (feedmail-say-debug (concat "4 cre " (feedmail-rfc8= 22-date (nth 4 (file-attributes maybe-file)))))
=C2=A0 =C2=A0 (feedmail-say-debug (concat "5 mod " (feedmail-rfc8= 22-date (nth 5 (file-attributes maybe-file)))))
=C2=A0 =C2=A0 (feedmail-say-debug (concat "6 sta " (feedmail-rfc8= 22-date (nth 6 (file-attributes maybe-file))))))
=C2=A0 (let ((date-time))
=C2=A0 =C2=A0 (if (and (not feedmail-queue-use-send-time-for-date) maybe-fi= le)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq date-time (nth 5 (file-attributes maybe-f= ile))))
=C2=A0 =C2=A0 (feedmail-rfc822-date date-time))
=C2=A0 )

Running M-q on every line turns it into this nonsense:

(defun feedmail-default-date-generator (maybe-file)
=C2=A0 "Default function for generating Date: header contents." =C2=A0 (feedmail-say-debug ">in-> feedmail-default-date-generato= r")
=C2=A0 (when maybe-file
=C2=A0 =C2=A0 (feedmail-say-debug (concat "4
=C2=A0 =C2=A0 cre " (feedmail-rfc822-date (nth 4 (file-attributes
=C2=A0 =C2=A0 maybe-file)))))
=C2=A0 =C2=A0 (feedmail-say-debug (concat "5
=C2=A0 =C2=A0 mod " (feedmail-rfc822-date (nth 5 (file-attributes
=C2=A0 =C2=A0 maybe-file)))))
=C2=A0 =C2=A0 (feedmail-say-debug (concat "6
=C2=A0 =C2=A0 sta " (feedmail-rfc822-date (nth 6 (file-attributes
=C2=A0 =C2=A0 maybe-file))))))
=C2=A0 (let ((date-time))
=C2=A0 =C2=A0 (if (and (not feedmail-queue-use-send-time-for-date)
=C2=A0 =C2=A0 maybe-file)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq date-time (nth 5 (file-attributes maybe-f= ile))))
=C2=A0 =C2=A0 (feedmail-rfc822-date date-time)) )
--0000000000005c65be056d922733--