Subject: bug#354: "Added (how many lines, bytes?!) to file.txt"

From: Eli Zaretskii <[email-masked]>
Date: Tue, 14 Mar 2017 17:55:50 +0200

> From: [email-masked]
> Date: Mon, 13 Mar 2017 20:58:59 -0400
> Cc: [email-masked], Paul Eggert <[email-masked]>
> 
> Jeff Clough <[email-masked]> writes:
> 
> > Updated patch at the end of this message.
> 
> Looks like this patch was forgotten.  It still applies cleanly apart
> from the NEWS and ChangeLog changes, so I'll push to master in a week or
> so if there are no objections.

LGTM, with one comment:

> diff --git a/src/fileio.c b/src/fileio.c
> index acbf76e0d8..bc99ee236c 100644
> --- a/src/fileio.c
> +++ b/src/fileio.c
> @@ -5150,12 +5150,13 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
>      }
>  
>    if (!auto_saving && !noninteractive)
> -    message_with_string ((NUMBERP (append)
> -			  ? "Updated %s"
> -			  : ! NILP (append)
> -			  ? "Added to %s"
> -			  : "Wrote %s"),
> -			 visit_file, 1);
> +    message ((NUMBERP (append)
> +              ? "Updated %"pI"d characters of %s"
> +              : ! NILP (append)
> +              ? "Added %"pI"d characters to %s"
> +              : "Wrote %"pI"d characters to %s"),
> +             XINT (end) - XINT (start),
> +             SDATA (ENCODE_SYSTEM (visit_file)));

It is incorrect to use ENCODE_SYSTEM here: the file name should be
output with no changes.  That's because 'message' normally displays in
the echo area, where the file name should appear unencoded.  What is
needed here is to pass to 'message' an encoded file name in
non-interactive case, and the original one in the interactive case.