Subject: bug#13949: 24.4.1; `fill-paragraph' should not always put the buffer as modified

From: Eli Zaretskii <[email-masked]>
Date: Sun, 27 Mar 2016 17:56:26 +0300

> From: Óscar Fuentes <[email-masked]>
> Date: Sun, 27 Mar 2016 05:31:19 +0200
> Cc: Jaakov <[email-masked]>, [email-masked]
> 
> diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
> index 100e2a2..9e1f430 100644
> --- a/lisp/textmodes/fill.el
> +++ b/lisp/textmodes/fill.el
> @@ -804,6 +804,7 @@ fill-paragraph
>    (interactive (progn
>  		 (barf-if-buffer-read-only)
>  		 (list (if current-prefix-arg 'full) t)))
> +  (setq h (if (buffer-modified-p) "" (secure-hash 'md5 (current-buffer))))
>    (or
>     ;; 1. Fill the region if it is active when called interactively.
>     (and region transient-mark-mode mark-active
> @@ -862,7 +863,10 @@ fill-paragraph
>                       ;; fill-region.
>                       (fill-region beg end justify)
>                     (fill-region-as-paragraph beg end justify))))))
> -     fill-pfx)))
> +     fill-pfx))
> +  (when (and (not (string= h ""))
> +             (string= h (secure-hash 'md5 (current-buffer))))
> +    (set-buffer-modified-p nil)))

Thanks, but I'm not sure computing the hash is enough: the functions
involved in refilling can change text properties, so the test should
also account for that.