all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dmitry@gutov.dev>
To: Jens Schmidt <jschmidt4gnu@vodafonemail.de>,
	Eli Zaretskii <eliz@gnu.org>
Cc: 67462@debbugs.gnu.org
Subject: bug#67462: 30.0.50; prog-fill-reindent-defun does not respect buffer-local fill-paragraph-function
Date: Fri, 1 Dec 2023 01:56:40 +0200	[thread overview]
Message-ID: <8c6bd156-9ae4-2349-bc78-f2556142b890@gutov.dev> (raw)
In-Reply-To: <87fs0n0ybw.fsf@sappc2.fritz.box>

On 30/11/2023 22:40, Jens Schmidt wrote:
>> If so, perhaps we should offer a user option to let users choose which
>> method to use, because some might prefer the new behavior?
> I'd be fine with that, and also with making the new behavior the
> default.  A reference to that user option would also nicely complete the
> NEWS entry, which IMO currently is a bit weak in mentioning the possible
> consequences of the new feature.
> 
> Dmitry, what do you think?

I think we should try to see whether those custom functions are better, 
and in which cases.

makefile-mode is actually an odd case because while it inherits from 
prog-mode, it doesn't quite satisfy an informal definition of what 
should be prog modes: its value of indent-line-function is 
#'indent-to-left-margin, which looks more like a text mode.

As a consequence, prog-fill-reindent-defun usually does nothing good 
outside of strings and comments in makefile-mode. Since I'm guessing the 
idea of ceasing to derive from prog-mode right away is not going to fly, 
we can add exceptions like this (with a docstring update, of course):

diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index 37c54a90f42..1927de7de2c 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -165,7 +165,10 @@ prog-fill-reindent-defun
                   (treesit-node-at (point)) 'text t))))
        (if (or treesit-text-node
                (nth 8 (syntax-ppss))
-              (re-search-forward "\\s-*\\s<" (line-end-position) t))
+              (re-search-forward "\\s-*\\s<" (line-end-position) t)
+              (memq indent-line-function
+                    '(indent-relative
+                      indent-to-left-margin)))
            (fill-paragraph argument (region-active-p))
          (beginning-of-defun)
          (let ((start (point)))

or even just this:

diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index 37c54a90f42..0ff3701f8fc 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -165,7 +165,8 @@ prog-fill-reindent-defun
                   (treesit-node-at (point)) 'text t))))
        (if (or treesit-text-node
                (nth 8 (syntax-ppss))
-              (re-search-forward "\\s-*\\s<" (line-end-position) t))
+              (re-search-forward "\\s-*\\s<" (line-end-position) t)
+              (not beginning-of-defun-function))
            (fill-paragraph argument (region-active-p))
          (beginning-of-defun)
          (let ((start (point)))

because defun navigation is not set up there either.

fortran, octave and cfengine, however, could use rebinding or user 
options (I can't really form an opinion on which of the behaviors is 
more useful). cfengine doesn't set fill-paragraph-function either, so 
the required changes would be a little less trivial than for the others. 
But using the prog-mode's binding by default is probably better for 
consistency.





  reply	other threads:[~2023-11-30 23:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-26 21:08 bug#67462: 30.0.50; prog-fill-reindent-defun does not respect buffer-local fill-paragraph-function Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-26 21:23 ` Dmitry Gutov
2023-11-26 22:52   ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-27 12:16     ` Eli Zaretskii
2023-11-27 20:08       ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-27 20:40         ` Dmitry Gutov
2023-11-28 21:28           ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-27 20:55         ` Eli Zaretskii
2023-11-28 21:10           ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-28 21:41             ` Dmitry Gutov
2023-11-29 12:38             ` Eli Zaretskii
2023-11-29 21:28               ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-30  6:39                 ` Eli Zaretskii
2023-11-30 20:40                   ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-30 23:56                     ` Dmitry Gutov [this message]
2023-11-27 17:02     ` Juri Linkov
2023-11-27 19:46     ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-27 20:46       ` Dmitry Gutov
2023-11-27 12:05   ` Eli Zaretskii

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

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

  git send-email \
    --in-reply-to=8c6bd156-9ae4-2349-bc78-f2556142b890@gutov.dev \
    --to=dmitry@gutov.dev \
    --cc=67462@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=jschmidt4gnu@vodafonemail.de \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.