unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 31656@debbugs.gnu.org, Stefan Guath <stefan@automata.se>
Subject: bug#31656: 26.1; `fill-paragraph' malformats in emacs-lisp-mode
Date: Fri, 01 Jun 2018 05:39:39 -0400	[thread overview]
Message-ID: <87bmcuc0bo.fsf@gmail.com> (raw)
In-Reply-To: <83sh66g8wb.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 01 Jun 2018 12:20:52 +0300")

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' in too many cases in emacs-lisp-mode. The
>> documentation of `emacs-lisp-docstring-fill-column' states: "Value of ‘fill-column’ 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 ‘fill-column’ is actually respected is within comments). A work-around is to set
>> `emacs-lisp-docstring-fill-column' to nil, but it would be nice 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'. It seems 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 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
> 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)) )





  reply	other threads:[~2018-06-01  9:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-30 12:50 bug#31656: 26.1; `fill-paragraph' malformats in emacs-lisp-mode Stefan Guath
2018-06-01  9:20 ` Eli Zaretskii
2018-06-01  9:39   ` Noam Postavsky [this message]
2018-06-01 10:36     ` Stefan Guath
2018-06-01 12:52       ` Eli Zaretskii
2018-06-01 14:34         ` Stefan Guath
2018-06-01 15:10           ` Eli Zaretskii
2018-06-01 12:43     ` Eli Zaretskii
2018-06-02  1:45       ` Noam Postavsky
2018-06-02  6:41         ` Eli Zaretskii
2018-06-02 13:07           ` Noam Postavsky
2018-06-02 13:25             ` martin rudalics
2018-06-02 13:34               ` Noam Postavsky
2018-06-02 14:09             ` Eli Zaretskii
2018-06-03 12:51               ` Stefan Guath
2020-08-22 15:23             ` Lars Ingebrigtsen
2022-04-13  3:06               ` Lars Ingebrigtsen

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=87bmcuc0bo.fsf@gmail.com \
    --to=npostavs@gmail.com \
    --cc=31656@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=stefan@automata.se \
    /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).