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

From: Jens Schmidt <[email-masked]>
Date: Mon, 27 Nov 2023 20:46:18 +0100

Jens Schmidt <[email-masked]> writes:

> Dmitry Gutov <[email-masked]> writes:
>
>> 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.
>
> Uh.  Good point.

Actually, I have to correct myself here: `c-mode', even though deriving
from `prog-mode', goes at lengths to not use the derived binding of M-q,
but rather binds it directly:

  ;; It doesn't suffice to put `c-fill-paragraph' on
  ;; `fill-paragraph-function' since `c-fill-paragraph' must be called
  ;; before any fill prefix adaption is done.  E.g. `filladapt-mode'
  ;; replaces `fill-paragraph' and does the adaption before calling
  ;; `fill-paragraph-function', and we have to mask comments etc
  ;; before that.  Also, `c-fill-paragraph' chains on to
  ;; `fill-paragraph' and the value on `fill-paragraph-function' to
  ;; do the actual filling work.
  (substitute-key-definition 'fill-paragraph 'c-fill-paragraph
			     c-mode-base-map global-map)

So `prog-fill-reindent-defun' wouldn't be bound in `c-mode' buffers,
anyway.  The same seems to hold for `awk-mode', `c++-mode' and probably
other modes in that family.