Subject: bug#67462: 30.0.50; prog-fill-reindent-defun does not respect buffer-local fill-paragraph-function

From: Dmitry Gutov <[email-masked]>
Date: Sun, 26 Nov 2023 23:23:04 +0200

On 26/11/2023 23:08, Jens Schmidt via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
> diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
> index 37c54a90f42..1bb2b678d94 100644
> --- a/lisp/progmodes/prog-mode.el
> +++ b/lisp/progmodes/prog-mode.el
> @@ -163,7 +163,8 @@ prog-fill-reindent-defun
>                   (treesit-parser-list)
>                   (treesit-node-match-p
>                    (treesit-node-at (point)) 'text t))))
> -      (if (or treesit-text-node
> +      (if (or (local-variable-p 'fill-paragraph-function)
> +              treesit-text-node
>                 (nth 8 (syntax-ppss))
>                 (re-search-forward "\\s-*\\s<" (line-end-position) t))
>             (fill-paragraph argument (region-active-p))

I'm not sure this is going to work well because c-mode (for example) 
also has a buffer-local value of fill-paragraph-function.

makefile-mode does look special in this regard. Perhaps it's one of 
those modes that don't really use indentation in the same way as an 
average "prog mode" does.

Maybe makefile-mode-map should simply rebind "M-q" back to 'fill-paragraph'.