GNU bug report logs - #354
"Added (how many lines, bytes?!) to file.txt"

Previous Next

Package: emacs;

Reported by: jidanni <at> jidanni.org

Date: Tue, 3 Jun 2008 20:30:07 UTC

Severity: wishlist

Tags: wontfix

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 354 in the body.
You can then email your comments to 354 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#354; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to jidanni <at> jidanni.org:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: jidanni <at> jidanni.org
To: bug-gnu-emacs <at> gnu.org
Subject: "Added (how many lines, bytes?!) to file.txt"
Date: Wed, 04 Jun 2008 02:37:52 +0800
Gentlemen, (I sound like Prince's "Partyman" song)
I noticed all append-to-file says is
"Added to /var/neurdsbeurg.txt".

The problem is often the user thinks "good, thanks", when days later
he discovers few or no lines got added, that's right, even 0 bytes
will produce the same message. You see often we are not fully aware of
the extent of our regions, colored or not, especially when extending
off the screen.

Therefore I propose you change that message to say instead how many
line or bytes or characters or both or all three were copied over.

All this of course also applies to write-region.





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#354; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #10 received at 354 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: 354 <at> debbugs.gnu.org
Subject: Re: bug#354: "Added (how many lines, bytes?!) to file.txt"
Date: Tue, 03 Jun 2008 17:07:53 -0400
severity 354 wishitem
thanks

> Gentlemen, (I sound like Prince's "Partyman" song)
> I noticed all append-to-file says is
> "Added to /var/neurdsbeurg.txt".

> The problem is often the user thinks "good, thanks", when days later
> he discovers few or no lines got added, that's right, even 0 bytes
> will produce the same message. You see often we are not fully aware of
> the extent of our regions, colored or not, especially when extending
> off the screen.

> Therefore I propose you change that message to say instead how many
> line or bytes or characters or both or all three were copied over.

That sounds like a good idea.  I think you may even be able to provide
a patch for it.  The relevant code is at the very end of the
Fwrite_region function in emacs/src/fileio.c.


        Stefan






Severity set to `wishlist' from `normal' Request was from Stefan Monnier <monnier <at> iro.umontreal.ca> to control <at> emacsbugs.donarmstrong.com. (Wed, 04 Jun 2008 00:15:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#354; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Kevin Rodgers <kevin.d.rodgers <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #17 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Kevin Rodgers <kevin.d.rodgers <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#354: "Added (how many lines, bytes?!) to file.txt"
Date: Thu, 05 Jun 2008 22:02:08 -0600
jidanni <at> jidanni.org wrote:
> Gentlemen, (I sound like Prince's "Partyman" song)
> I noticed all append-to-file says is
> "Added to /var/neurdsbeurg.txt".
> 
> The problem is often the user thinks "good, thanks", when days later
> he discovers few or no lines got added, that's right, even 0 bytes
> will produce the same message. You see often we are not fully aware of
> the extent of our regions, colored or not, especially when extending
> off the screen.
> 
> Therefore I propose you change that message to say instead how many
> line or bytes or characters or both or all three were copied over.

Since append-to-file takes buffer positions as arguments, I think
the most relevant unit to report would be characters.

> All this of course also applies to write-region.

-- 
Kevin Rodgers
Denver, Colorado, USA






Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#354; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "Drew Adams" <drew.adams <at> oracle.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #22 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Drew Adams" <drew.adams <at> oracle.com>
To: "'Kevin Rodgers'" <kevin.d.rodgers <at> gmail.com>,
        <354 <at> debbugs.gnu.org>, <bug-gnu-emacs <at> gnu.org>
Subject: RE: bug#354: "Added (how many lines, bytes?!) to file.txt"
Date: Fri, 6 Jun 2008 07:56:14 -0700
> Since append-to-file takes buffer positions as arguments, I think
> the most relevant unit to report would be characters.

Definitely.

Both could be mentioned, however: (2614 chars, 104 lines).






Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#354; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "Drew Adams" <drew.adams <at> oracle.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#354; Package emacs. (Fri, 27 Feb 2015 07:22:01 GMT) Full text and rfc822 format available.

Message #30 received at 354 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Jeff Clough <kb1vqh <at> gmail.com>
Cc: 354 <at> debbugs.gnu.org
Subject: Re: "Added (how many lines, bytes?!) to file.txt"
Date: Thu, 26 Feb 2015 23:21:06 -0800
Following up to:

http://lists.gnu.org/archive/html/emacs-devel/2015-02/msg01364.html

Jeff Clough wrote:
> 1. git checkout master
> 2. git pull
> 3. git checkout -b wishlist-354 (is this overkill for a small change?)

No, it's what I do.

> 4. Changed write-region in "fileio.c"
> 5. Tested my change (is building in place advised?)

It's what I do.  Some people prefer building in another directory.

> 6. Created "wishlist354log.txt" with my commit message
> 7. git commit -a -F /path/to/wishlist354log.txt

For now, you need a ChangeLog entry in src/ChangeLog too; it's essentially a 
copy of the commit message.  On my list of things to do is simplifying this.

> 8. git format-patch -1 (is using this advised?)

Yes, it's good.

> Changed write-region to show characters added in message

This should be a proper ChangeLog message, e.g., by adding a 2nd line "* 
fileio.c (write_region): description".

> +    message ((NUMBERP (append)
> +	      ? "Updated %d characters of %s"
> +	      : ! NILP (append)
> +	      ? "Added %d characters to %s"
> +	      : "Wrote %d characters to %s"),
> +	     (int) (XINT (end) - XINT (start)),
> +	     SDATA (ENCODE_SYSTEM (visit_file)));

This won't work on platforms where EMACS_INT is wider than int.  Use the pI 
macro instead, and don't cast to 'int'.

Also, you need to change the documentation of this stuff in 
doc/emacs/files.texi, and add a news item in etc/NEWS.  Plus, you need to change 
epa-file-write-region, jka-compr-write-region, etc. to be compatible.  And 
there's probably more stuff.  I suggest running this shell command:

grep -nH -re 'Wrote ' $(git ls-files)

and checking every matching line.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#354; Package emacs. (Fri, 27 Feb 2015 16:58:01 GMT) Full text and rfc822 format available.

Message #33 received at 354 <at> debbugs.gnu.org (full text, mbox):

From: Jeff Clough <kb1vqh <at> gmail.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 354 <at> debbugs.gnu.org
Subject: Re: "Added (how many lines, bytes?!) to file.txt"
Date: Fri, 27 Feb 2015 08:52:12 -0500
Updated patch at the end of this message.

Thank you very much for your help on this, Paul. The changes needed
proved somewhat more pervasive than I'd first thought, but that's always
the case, isn't. :)

I *believe* I got them all, searching for "Wrote " and every synonym I
could think of. I also updated the documentation for write-region and
append-to-file (to which the docs of the other functions all seem to
refer), created a ChangeLog entry, and updated NEWS. On this last, I was
uncertain where to place the entry, but think (hope?) I got it right.

Also, I understand that there's some copyright assignment paperwork I
need to fill out and sign for non-trivial changes. I will start that
process now, but hope this change can be accepted in the interim.

Finally, is it still advisable to make a single patch for a small change
such as this, even when it affects so many files?

Thanks again.

Jeff

[PATCH] Changed write-region and the like to show characters added in
 message

	* fileio.c (write_region):
	* epa-file.el (epa-file-write-region):
	* jka-compr.el (jka-compr-write-region):
	* ange-ftp.el (ange-ftp-write-region):
	* tramp-gvfs.el (tramp-gvfs-handle-write-region):
	* tramp-sh.el (tramp-sh-handle-write-region):
	* mm-util.el (mm-append-to-file): Functions now output
	characters written in addition to file name.
	* files.texi: Added documentation to write-region and
	append-to-file describing their output.

Fixes: debbugs:354
---
 doc/emacs/files.texi   |  2 +-
 etc/NEWS               |  3 +++
 lisp/epa-file.el       |  2 +-
 lisp/gnus/mm-util.el   |  2 +-
 lisp/jka-compr.el      |  2 +-
 lisp/net/ange-ftp.el   |  2 +-
 lisp/net/tramp-gvfs.el |  2 +-
 lisp/net/tramp-sh.el   |  2 +-
 src/ChangeLog          | 13 +++++++++++++
 src/fileio.c           | 13 +++++++------
 10 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index b12b28f..7ed44de 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -1621,7 +1621,7 @@ similar to the @kbd{M-x find-file-literally} command
   @kbd{M-x write-region} is the inverse of @kbd{M-x insert-file}; it
 copies the contents of the region into the specified file.  @kbd{M-x
 append-to-file} adds the text of the region to the end of the
-specified file.  @xref{Accumulating Text}.  The variable
+specified file.  When called interactively, these commands will print a message in the echo area giving the name of the file affected as well as the number of characters which were added.  @xref{Accumulating Text}.  The variable
 @code{write-region-inhibit-fsync} applies to these commands, as well
 as saving files; see @ref{Customize Save}.
 
diff --git a/etc/NEWS b/etc/NEWS
index 3f88d3d..bd569a8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -66,6 +66,9 @@ so if you want to use it, you can always take a copy from an older Emacs.
 
 * Changes in Emacs 25.1
 
++++
+** The functions write-region, append-to-file, and the like now output the number of characters added in addition to the name of the file affected.
+
 ** New command `comment-line' bound to `C-x C-;'.
 
 ** New function `custom-prompt-customize-unsaved-options' checks for
diff --git a/lisp/epa-file.el b/lisp/epa-file.el
index db8613a..4cce256 100644
--- a/lisp/epa-file.el
+++ b/lisp/epa-file.el
@@ -286,7 +286,7 @@ If no one is selected, symmetric encryption will be performed.  "
     (if (or (eq visit t)
 	    (eq visit nil)
 	    (stringp visit))
-	(message "Wrote %s" buffer-file-name))))
+	(message "Wrote %d characters to %s" (- end start) buffer-file-name))))
 (put 'write-region 'epa-file 'epa-file-write-region)
 
 (defun epa-file-select-keys ()
diff --git a/lisp/gnus/mm-util.el b/lisp/gnus/mm-util.el
index 0b75901..13cc9f5 100644
--- a/lisp/gnus/mm-util.el
+++ b/lisp/gnus/mm-util.el
@@ -1352,7 +1352,7 @@ If INHIBIT is non-nil, inhibit `mm-inhibit-file-name-handlers'."
 		     inhibit-file-name-handlers)
 	   inhibit-file-name-handlers)))
     (write-region start end filename t 'no-message)
-    (message "Appended to %s" filename)))
+    (message "Appended %d characters to %s" (- end start) filename)))
 
 (defun mm-write-region (start end filename &optional append visit lockname
 			      coding-system inhibit)
diff --git a/lisp/jka-compr.el b/lisp/jka-compr.el
index fced4ee..5530b86 100644
--- a/lisp/jka-compr.el
+++ b/lisp/jka-compr.el
@@ -357,7 +357,7 @@ There should be no more than seven characters after the final `/'."
 	  (and (or (eq visit t)
 		   (eq visit nil)
 		   (stringp visit))
-	       (message "Wrote %s" visit-file))
+	       (message "Wrote %d characters to %s" (- end start) visit-file))
 
 	  ;; ensure `last-coding-system-used' has an appropriate value
 	  (setq last-coding-system-used coding-system-used)
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el
index 52153ad..588778d 100644
--- a/lisp/net/ange-ftp.el
+++ b/lisp/net/ange-ftp.el
@@ -3285,7 +3285,7 @@ system TYPE.")
 		(set-buffer-modified-p nil)))
 	  ;; ensure `last-coding-system-used' has an appropriate value
 	  (setq last-coding-system-used coding-system-used)
-	  (ange-ftp-message "Wrote %s" abbr)
+	  (ange-ftp-message "Wrote %d characters to %s" (- end start) abbr)
 	  (ange-ftp-add-file-entry filename))
       (ange-ftp-real-write-region start end filename append visit))))
 
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 1ea52eb..a4f8d0a 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -1105,7 +1105,7 @@ is no information where to trace the message.")
 
     ;; The end.
     (when (or (eq visit t) (null visit) (stringp visit))
-      (tramp-message v 0 "Wrote %s" filename))
+      (tramp-message v 0 "Wrote %d characters to %s" (- end start) filename))
     (run-hooks 'tramp-handle-write-region-hook)))
 
 
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index f3fdb63..e385cfa 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -3429,7 +3429,7 @@ the result will be a local, non-Tramp, file name."
         (when need-chown
           (tramp-set-file-uid-gid filename uid gid))
 	(when (or (eq visit t) (null visit) (stringp visit))
-	  (tramp-message v 0 "Wrote %s" filename))
+	  (tramp-message v 0 "Wrote %d characters to %s" (- end start) filename))
 	(run-hooks 'tramp-handle-write-region-hook)))))
 
 (defvar tramp-vc-registered-file-names nil
diff --git a/src/ChangeLog b/src/ChangeLog
index 61bb32164..d476ac8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,16 @@
+2015-02-27  Jeff Clough  <kb1vqh <at> gmail.com>
+
+	* fileio.c (write_region):
+	* epa-file.el (epa-file-write-region):
+	* jka-compr.el (jka-compr-write-region):
+	* ange-ftp.el (ange-ftp-write-region):
+	* tramp-gvfs.el (tramp-gvfs-handle-write-region):
+	* tramp-sh.el (tramp-sh-handle-write-region):
+	* mm-util.el (mm-append-to-file): Functions now output
+	characters written in addition to file name.
+	* files.texi: Added documentation to write-region and
+	append-to-file describing their output.
+
 2015-02-27  Mark Laws  <mdl <at> 60hz.org>
 
 	Support daemon mode on MS-Windows (bug#19688)
diff --git a/src/fileio.c b/src/fileio.c
index 43ab456..da526c6 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5000,12 +5000,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)));
 
   return Qnil;
 }
-- 
1.9.1





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#354; Package emacs. (Tue, 14 Mar 2017 00:58:02 GMT) Full text and rfc822 format available.

Message #36 received at 354 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Jeff Clough <kb1vqh <at> gmail.com>
Cc: 354 <at> debbugs.gnu.org, Paul Eggert <eggert <at> cs.ucla.edu>
Subject: Re: bug#354: "Added (how many lines, bytes?!) to file.txt"
Date: Mon, 13 Mar 2017 20:58:59 -0400
[Message part 1 (text/plain, inline)]
tags 354 patch
quit

Jeff Clough <kb1vqh <at> gmail.com> 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.

Reformatted with git format-patch (I made a few whitespace changes to
the patch as well).

[0001-Output-number-of-characters-added-to-file-Bug-354.patch (text/x-diff, inline)]
From fd1c97f4d9f417d4ded4ec40b52daac70f15137c Mon Sep 17 00:00:00 2001
From: Jeff Clough <kb1vqh <at> gmail.com>
Date: Fri, 27 Feb 2015 08:52:12 -0500
Subject: [PATCH] Output number of characters added to file (Bug#354)

* fileio.c (write_region):
* epa-file.el (epa-file-write-region):
* jka-compr.el (jka-compr-write-region):
* ange-ftp.el (ange-ftp-write-region):
* tramp-gvfs.el (tramp-gvfs-handle-write-region):
* tramp-sh.el (tramp-sh-handle-write-region):
* mm-util.el (mm-append-to-file): Functions now output
characters written in addition to file name.
* files.texi: Added documentation to write-region and
append-to-file describing their output.
---
 doc/emacs/files.texi   |  8 +++++---
 etc/NEWS               |  5 +++++
 lisp/epa-file.el       |  2 +-
 lisp/gnus/mm-util.el   |  2 +-
 lisp/jka-compr.el      |  2 +-
 lisp/net/ange-ftp.el   |  2 +-
 lisp/net/tramp-gvfs.el |  2 +-
 lisp/net/tramp-sh.el   |  3 ++-
 src/fileio.c           | 13 +++++++------
 9 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index 2b09c69945..d3116730ee 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -1639,9 +1639,11 @@ Misc File Ops
   @kbd{M-x write-region} is the inverse of @kbd{M-x insert-file}; it
 copies the contents of the region into the specified file.  @kbd{M-x
 append-to-file} adds the text of the region to the end of the
-specified file.  @xref{Accumulating Text}.  The variable
-@code{write-region-inhibit-fsync} applies to these commands, as well
-as saving files; see @ref{Customize Save}.
+specified file.  @xref{Accumulating Text}.  When called interactively,
+these commands will print a message in the echo area giving the name
+of the file affected as well as the number of characters which were
+added.  The variable @code{write-region-inhibit-fsync} applies to
+these commands, as well as saving files; see @ref{Customize Save}.
 
 @findex set-file-modes
 @cindex file modes
diff --git a/etc/NEWS b/etc/NEWS
index fde18ed391..d83572958b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -91,6 +91,11 @@ required capabilities are found in terminfo.  See the FAQ node
 
 * Changes in Emacs 26.1
 
++++
+** The functions write-region, append-to-file, and the like now output
+the number of characters added in addition to the name of the file
+affected.
+
 ** The variable 'emacs-version' no longer includes the build number.
 This is now stored separately in a new variable, 'emacs-build-number'.
 
diff --git a/lisp/epa-file.el b/lisp/epa-file.el
index c97acb837a..bc97992b5f 100644
--- a/lisp/epa-file.el
+++ b/lisp/epa-file.el
@@ -290,7 +290,7 @@ epa-file-write-region
     (if (or (eq visit t)
 	    (eq visit nil)
 	    (stringp visit))
-	(message "Wrote %s" buffer-file-name))))
+	(message "Wrote %d characters to %s" (- end start) buffer-file-name))))
 (put 'write-region 'epa-file 'epa-file-write-region)
 
 (defun epa-file-select-keys ()
diff --git a/lisp/gnus/mm-util.el b/lisp/gnus/mm-util.el
index 89f397e3ed..5a58ed15b9 100644
--- a/lisp/gnus/mm-util.el
+++ b/lisp/gnus/mm-util.el
@@ -736,7 +736,7 @@ mm-append-to-file
 		     inhibit-file-name-handlers)
 	   inhibit-file-name-handlers)))
     (write-region start end filename t 'no-message)
-    (message "Appended to %s" filename)))
+    (message "Appended %d characters to %s" (- end start) filename)))
 
 (defun mm-write-region (start end filename &optional append visit lockname
 			      coding-system inhibit)
diff --git a/lisp/jka-compr.el b/lisp/jka-compr.el
index 26a7cf506f..0be349f0fd 100644
--- a/lisp/jka-compr.el
+++ b/lisp/jka-compr.el
@@ -357,7 +357,7 @@ jka-compr-write-region
 	  (and (or (eq visit t)
 		   (eq visit nil)
 		   (stringp visit))
-	       (message "Wrote %s" visit-file))
+	       (message "Wrote %d characters to %s" (- end start) visit-file))
 
 	  ;; ensure `last-coding-system-used' has an appropriate value
 	  (setq last-coding-system-used coding-system-used)
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el
index cafdb3ecb0..54ffa3551f 100644
--- a/lisp/net/ange-ftp.el
+++ b/lisp/net/ange-ftp.el
@@ -3284,7 +3284,7 @@ ange-ftp-write-region
 		(set-buffer-modified-p nil)))
 	  ;; ensure `last-coding-system-used' has an appropriate value
 	  (setq last-coding-system-used coding-system-used)
-	  (ange-ftp-message "Wrote %s" abbr)
+	  (ange-ftp-message "Wrote %d characters to %s" (- end start) abbr)
 	  (ange-ftp-add-file-entry filename))
       (ange-ftp-real-write-region start end filename append visit))))
 
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index dd42d9c983..0a952dcca1 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -1224,7 +1224,7 @@ tramp-gvfs-handle-write-region
 
     ;; The end.
     (when (or (eq visit t) (null visit) (stringp visit))
-      (tramp-message v 0 "Wrote %s" filename))
+      (tramp-message v 0 "Wrote %d characters to %s" (- end start) filename))
     (run-hooks 'tramp-handle-write-region-hook)))
 
 
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 6cd52ae4e0..d1ef1448bb 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -3414,7 +3414,8 @@ tramp-sh-handle-write-region
         (when need-chown
           (tramp-set-file-uid-gid filename uid gid))
 	(when (or (eq visit t) (null visit) (stringp visit))
-	  (tramp-message v 0 "Wrote %s" filename))
+          (tramp-message v 0 "Wrote %d characters to %s"
+                         (- end start) filename))
 	(run-hooks 'tramp-handle-write-region-hook)))))
 
 (defvar tramp-vc-registered-file-names nil
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)));
 
   return Qnil;
 }
-- 
2.11.1


Added tag(s) patch. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Tue, 14 Mar 2017 00:58:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#354; Package emacs. (Tue, 14 Mar 2017 15:57:02 GMT) Full text and rfc822 format available.

Message #41 received at 354 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: npostavs <at> users.sourceforge.net
Cc: 354 <at> debbugs.gnu.org, kb1vqh <at> gmail.com, eggert <at> cs.ucla.edu
Subject: Re: bug#354: "Added (how many lines, bytes?!) to file.txt"
Date: Tue, 14 Mar 2017 17:55:50 +0200
> From: npostavs <at> users.sourceforge.net
> Date: Mon, 13 Mar 2017 20:58:59 -0400
> Cc: 354 <at> debbugs.gnu.org, Paul Eggert <eggert <at> cs.ucla.edu>
> 
> Jeff Clough <kb1vqh <at> gmail.com> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#354; Package emacs. (Sat, 01 Apr 2017 04:27:01 GMT) Full text and rfc822 format available.

Message #44 received at 354 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 354 <at> debbugs.gnu.org, kb1vqh <at> gmail.com, eggert <at> cs.ucla.edu
Subject: Re: bug#354: "Added (how many lines, bytes?!) to file.txt"
Date: Sat, 01 Apr 2017 00:27:40 -0400
Eli Zaretskii <eliz <at> gnu.org> writes:

>> --- 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.

Actually, we don't print anything in the non-interactive case, so there
is no need to worry about that.  But I guess the problem here is this
comment on vmessage:

   The message must be safe ASCII and the format must not contain ` or
   '.  If your message and format do not fit into this category,
   convert your arguments to Lisp objects and use Fmessage instead.  */

This applies to message as well, correct?  (I suppose it must, since
message does nothing but call vmessage.)  So we need to use Fmessage to
be able to print the file name.  Like this?

  if (!auto_saving && !noninteractive)
    Fmessage (build_string ("%s %d characters of %s"),
              build_string (NUMBERP (append) ? "Updated"
                            : ! NILP (append) ? "Added"
                            : "Wrote"),
              make_number (XINT (end) - XINT (start)),
              visit_file);





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#354; Package emacs. (Sat, 01 Apr 2017 06:10:01 GMT) Full text and rfc822 format available.

Message #47 received at 354 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: npostavs <at> users.sourceforge.net
Cc: 354 <at> debbugs.gnu.org, kb1vqh <at> gmail.com, eggert <at> cs.ucla.edu
Subject: Re: bug#354: "Added (how many lines, bytes?!) to file.txt"
Date: Sat, 01 Apr 2017 09:09:04 +0300
> From: npostavs <at> users.sourceforge.net
> Cc: 354 <at> debbugs.gnu.org,  kb1vqh <at> gmail.com,  eggert <at> cs.ucla.edu
> Date: Sat, 01 Apr 2017 00:27:40 -0400
> 
> >> +    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.
> 
> Actually, we don't print anything in the non-interactive case, so there
> is no need to worry about that.  But I guess the problem here is this
> comment on vmessage:
> 
>    The message must be safe ASCII and the format must not contain ` or
>    '.  If your message and format do not fit into this category,
>    convert your arguments to Lisp objects and use Fmessage instead.  */
> 
> This applies to message as well, correct?

Yes, but only because of the non-interactive case.  If that is not an
issue, you could simply pass the SDATA of the original string, because
we simply insert that into an echo-area buffer.

It might be a good idea to have a similar comment to 'message'.

> So we need to use Fmessage to be able to print the file name.  Like
> this?
> 
>   if (!auto_saving && !noninteractive)
>     Fmessage (build_string ("%s %d characters of %s"),
>               build_string (NUMBERP (append) ? "Updated"
>                             : ! NILP (append) ? "Added"
>                             : "Wrote"),
>               make_number (XINT (end) - XINT (start)),
>               visit_file);

Yes, this is also okay.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#354; Package emacs. (Sun, 02 Apr 2017 03:55:01 GMT) Full text and rfc822 format available.

Message #50 received at 354 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 354 <at> debbugs.gnu.org, kb1vqh <at> gmail.com, eggert <at> cs.ucla.edu
Subject: Re: bug#354: "Added (how many lines, bytes?!) to file.txt"
Date: Sat, 01 Apr 2017 23:55:53 -0400
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

> Yes, but only because of the non-interactive case.  If that is not an
> issue, you could simply pass the SDATA of the original string, because
> we simply insert that into an echo-area buffer.

The `' thing applies in the interactive case right?

[0001-src-xdisp.c-vmessage-message-Clarify-commentary.patch (text/x-diff, inline)]
From 156859858e03baeddeb554c8df220171adaf6bf1 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sat, 1 Apr 2017 17:54:26 -0400
Subject: [PATCH] * src/xdisp.c (vmessage, message): Clarify commentary.

---
 src/xdisp.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index 9ecfb86401..8ff291affb 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10470,9 +10470,12 @@ message_with_string (const char *m, Lisp_Object string, bool log)
 /* Dump an informative message to the minibuf.  If M is 0, clear out
    any existing message, and let the mini-buffer text show through.
 
-   The message must be safe ASCII and the format must not contain ` or
-   '.  If your message and format do not fit into this category,
-   convert your arguments to Lisp objects and use Fmessage instead.  */
+   The message must be safe ASCII (because when Emacs is
+   non-interactive the message is sent straight to stderr without
+   encoding first) and the format must not contain ` or ' (because
+   this function does not account for `text-quoting-style'.  If your
+   message and format do not fit into this category, convert your
+   arguments to Lisp objects and use Fmessage instead.  */
 
 static void ATTRIBUTE_FORMAT_PRINTF (1, 0)
 vmessage (const char *m, va_list ap)
@@ -10530,6 +10533,7 @@ vmessage (const char *m, va_list ap)
     }
 }
 
+/* See vmessage for restrictions on the text of the message.  */
 void
 message (const char *m, ...)
 {
-- 
2.11.1

[Message part 3 (text/plain, inline)]
>> 
>>   if (!auto_saving && !noninteractive)
>>     Fmessage (build_string ("%s %d characters of %s"),
>>               build_string (NUMBERP (append) ? "Updated"
>>                             : ! NILP (append) ? "Added"
>>                             : "Wrote"),
>>               make_number (XINT (end) - XINT (start)),
>>               visit_file);
>
> Yes, this is also okay.

Except I forgot the CALLN.

[v2-0001-Output-number-of-characters-added-to-file-Bug-354.patch (text/x-diff, inline)]
From d077e66f21621aa0ac04fb148146836322f052d6 Mon Sep 17 00:00:00 2001
From: Jeff Clough <kb1vqh <at> gmail.com>
Date: Fri, 27 Feb 2015 08:52:12 -0500
Subject: [PATCH v2] Output number of characters added to file (Bug#354)

* fileio.c (write_region):
* epa-file.el (epa-file-write-region):
* jka-compr.el (jka-compr-write-region):
* ange-ftp.el (ange-ftp-write-region):
* tramp-gvfs.el (tramp-gvfs-handle-write-region):
* tramp-sh.el (tramp-sh-handle-write-region):
* mm-util.el (mm-append-to-file): Functions now output
characters written in addition to file name.
* files.texi: Added documentation to write-region and
append-to-file describing their output.
---
 doc/emacs/files.texi   |  8 +++++---
 etc/NEWS               |  5 +++++
 lisp/epa-file.el       |  2 +-
 lisp/gnus/mm-util.el   |  2 +-
 lisp/jka-compr.el      |  2 +-
 lisp/net/ange-ftp.el   |  2 +-
 lisp/net/tramp-gvfs.el |  2 +-
 lisp/net/tramp-sh.el   |  3 ++-
 src/fileio.c           | 14 +++++++-------
 9 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index 0b730e27d3..ed17f66ca2 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -1641,9 +1641,11 @@ Misc File Ops
   @kbd{M-x write-region} is the inverse of @kbd{M-x insert-file}; it
 copies the contents of the region into the specified file.  @kbd{M-x
 append-to-file} adds the text of the region to the end of the
-specified file.  @xref{Accumulating Text}.  The variable
-@code{write-region-inhibit-fsync} applies to these commands, as well
-as saving files; see @ref{Customize Save}.
+specified file.  @xref{Accumulating Text}.  When called interactively,
+these commands will print a message in the echo area giving the name
+of the file affected as well as the number of characters which were
+added.  The variable @code{write-region-inhibit-fsync} applies to
+these commands, as well as saving files; see @ref{Customize Save}.
 
 @findex set-file-modes
 @cindex file modes
diff --git a/etc/NEWS b/etc/NEWS
index f3ec3fe904..4e4da7d470 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -90,6 +90,11 @@ required capabilities are found in terminfo.  See the FAQ node
 
 * Changes in Emacs 26.1
 
++++
+** The functions write-region, append-to-file, and the like now output
+the number of characters added in addition to the name of the file
+affected.
+
 ** The variable 'emacs-version' no longer includes the build number.
 This is now stored separately in a new variable, 'emacs-build-number'.
 
diff --git a/lisp/epa-file.el b/lisp/epa-file.el
index c97acb837a..bc97992b5f 100644
--- a/lisp/epa-file.el
+++ b/lisp/epa-file.el
@@ -290,7 +290,7 @@ epa-file-write-region
     (if (or (eq visit t)
 	    (eq visit nil)
 	    (stringp visit))
-	(message "Wrote %s" buffer-file-name))))
+	(message "Wrote %d characters to %s" (- end start) buffer-file-name))))
 (put 'write-region 'epa-file 'epa-file-write-region)
 
 (defun epa-file-select-keys ()
diff --git a/lisp/gnus/mm-util.el b/lisp/gnus/mm-util.el
index 89f397e3ed..5a58ed15b9 100644
--- a/lisp/gnus/mm-util.el
+++ b/lisp/gnus/mm-util.el
@@ -736,7 +736,7 @@ mm-append-to-file
 		     inhibit-file-name-handlers)
 	   inhibit-file-name-handlers)))
     (write-region start end filename t 'no-message)
-    (message "Appended to %s" filename)))
+    (message "Appended %d characters to %s" (- end start) filename)))
 
 (defun mm-write-region (start end filename &optional append visit lockname
 			      coding-system inhibit)
diff --git a/lisp/jka-compr.el b/lisp/jka-compr.el
index 26a7cf506f..0be349f0fd 100644
--- a/lisp/jka-compr.el
+++ b/lisp/jka-compr.el
@@ -357,7 +357,7 @@ jka-compr-write-region
 	  (and (or (eq visit t)
 		   (eq visit nil)
 		   (stringp visit))
-	       (message "Wrote %s" visit-file))
+	       (message "Wrote %d characters to %s" (- end start) visit-file))
 
 	  ;; ensure `last-coding-system-used' has an appropriate value
 	  (setq last-coding-system-used coding-system-used)
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el
index cafdb3ecb0..54ffa3551f 100644
--- a/lisp/net/ange-ftp.el
+++ b/lisp/net/ange-ftp.el
@@ -3284,7 +3284,7 @@ ange-ftp-write-region
 		(set-buffer-modified-p nil)))
 	  ;; ensure `last-coding-system-used' has an appropriate value
 	  (setq last-coding-system-used coding-system-used)
-	  (ange-ftp-message "Wrote %s" abbr)
+	  (ange-ftp-message "Wrote %d characters to %s" (- end start) abbr)
 	  (ange-ftp-add-file-entry filename))
       (ange-ftp-real-write-region start end filename append visit))))
 
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 59d8771cf1..eb0b832c0c 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -1223,7 +1223,7 @@ tramp-gvfs-handle-write-region
 
     ;; The end.
     (when (or (eq visit t) (null visit) (stringp visit))
-      (tramp-message v 0 "Wrote %s" filename))
+      (tramp-message v 0 "Wrote %d characters to %s" (- end start) filename))
     (run-hooks 'tramp-handle-write-region-hook)))
 
 
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index e4a48b7f8e..4db88ebd89 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -3411,7 +3411,8 @@ tramp-sh-handle-write-region
         (when need-chown
           (tramp-set-file-uid-gid filename uid gid))
 	(when (or (eq visit t) (null visit) (stringp visit))
-	  (tramp-message v 0 "Wrote %s" filename))
+          (tramp-message v 0 "Wrote %d characters to %s"
+                         (- end start) filename))
 	(run-hooks 'tramp-handle-write-region-hook)))))
 
 (defvar tramp-vc-registered-file-names nil
diff --git a/src/fileio.c b/src/fileio.c
index acbf76e0d8..893d13192b 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5150,13 +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);
-
+    CALLN (Fmessage,
+           (build_string ("%s %d characters of `%s'"),
+            build_string (NUMBERP (append) ? "Updated"
+                          : ! NILP (append) ? "Added"
+                          : "Wrote"),
+            make_number (XINT (end) - XINT (start)),
+            visit_file));
   return Qnil;
 }
 
-- 
2.11.1


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#354; Package emacs. (Sun, 02 Apr 2017 06:17:02 GMT) Full text and rfc822 format available.

Message #53 received at 354 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: npostavs <at> users.sourceforge.net
Cc: 354 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, eggert <at> cs.ucla.edu,
 kb1vqh <at> gmail.com
Subject: Re: bug#354: "Added (how many lines, bytes?!) to file.txt"
Date: Sun, 02 Apr 2017 08:16:02 +0200
On Apr 01 2017, npostavs <at> users.sourceforge.net wrote:

> diff --git a/src/xdisp.c b/src/xdisp.c
> index 9ecfb86401..8ff291affb 100644
> --- a/src/xdisp.c
> +++ b/src/xdisp.c
> @@ -10470,9 +10470,12 @@ message_with_string (const char *m, Lisp_Object string, bool log)
>  /* Dump an informative message to the minibuf.  If M is 0, clear out
>     any existing message, and let the mini-buffer text show through.
>  
> -   The message must be safe ASCII and the format must not contain ` or
> -   '.  If your message and format do not fit into this category,
> -   convert your arguments to Lisp objects and use Fmessage instead.  */
> +   The message must be safe ASCII (because when Emacs is
> +   non-interactive the message is sent straight to stderr without
> +   encoding first) and the format must not contain ` or ' (because
> +   this function does not account for `text-quoting-style'.  If your
> +   message and format do not fit into this category, convert your
> +   arguments to Lisp objects and use Fmessage instead.  */

Missing a close paren.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#354; Package emacs. (Sun, 02 Apr 2017 15:53:03 GMT) Full text and rfc822 format available.

Message #56 received at 354 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: npostavs <at> users.sourceforge.net
Cc: 354 <at> debbugs.gnu.org, kb1vqh <at> gmail.com, eggert <at> cs.ucla.edu
Subject: Re: bug#354: "Added (how many lines, bytes?!) to file.txt"
Date: Sun, 02 Apr 2017 18:52:31 +0300
> From: npostavs <at> users.sourceforge.net
> Cc: 354 <at> debbugs.gnu.org,  kb1vqh <at> gmail.com,  eggert <at> cs.ucla.edu
> Date: Sat, 01 Apr 2017 23:55:53 -0400
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > Yes, but only because of the non-interactive case.  If that is not an
> > issue, you could simply pass the SDATA of the original string, because
> > we simply insert that into an echo-area buffer.
> 
> The `' thing applies in the interactive case right?

Yes.

> diff --git a/lisp/epa-file.el b/lisp/epa-file.el
> index c97acb837a..bc97992b5f 100644
> --- a/lisp/epa-file.el
> +++ b/lisp/epa-file.el
> @@ -290,7 +290,7 @@ epa-file-write-region
>      (if (or (eq visit t)
>  	    (eq visit nil)
>  	    (stringp visit))
> -	(message "Wrote %s" buffer-file-name))))
> +	(message "Wrote %d characters to %s" (- end start) buffer-file-name))))

Shouldn't this and others use `' as well?

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#354; Package emacs. (Sun, 02 Apr 2017 16:10:01 GMT) Full text and rfc822 format available.

Message #59 received at 354 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 354 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, eggert <at> cs.ucla.edu,
 kb1vqh <at> gmail.com
Subject: Re: bug#354: "Added (how many lines, bytes?!) to file.txt"
Date: Sun, 02 Apr 2017 12:10:36 -0400
[Message part 1 (text/plain, inline)]
Andreas Schwab <schwab <at> linux-m68k.org> writes:

>
> Missing a close paren.

Oops.

[v3-0001-src-xdisp.c-vmessage-message-Clarify-commentary.patch (text/x-diff, inline)]
From d085d1fd7283fe29f656c49f619e33eb2f47829d Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sat, 1 Apr 2017 17:54:26 -0400
Subject: [PATCH v3] * src/xdisp.c (vmessage, message): Clarify commentary.

---
 src/xdisp.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index 9ecfb86401..c6f8566523 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10470,9 +10470,12 @@ message_with_string (const char *m, Lisp_Object string, bool log)
 /* Dump an informative message to the minibuf.  If M is 0, clear out
    any existing message, and let the mini-buffer text show through.
 
-   The message must be safe ASCII and the format must not contain ` or
-   '.  If your message and format do not fit into this category,
-   convert your arguments to Lisp objects and use Fmessage instead.  */
+   The message must be safe ASCII (because when Emacs is
+   non-interactive the message is sent straight to stderr without
+   encoding first) and the format must not contain ` or ' (because
+   this function does not account for `text-quoting-style').  If your
+   message and format do not fit into this category, convert your
+   arguments to Lisp objects and use Fmessage instead.  */
 
 static void ATTRIBUTE_FORMAT_PRINTF (1, 0)
 vmessage (const char *m, va_list ap)
@@ -10530,6 +10533,7 @@ vmessage (const char *m, va_list ap)
     }
 }
 
+/* See vmessage for restrictions on the text of the message.  */
 void
 message (const char *m, ...)
 {
-- 
2.11.1

[Message part 3 (text/plain, inline)]

Eli Zaretskii <eliz <at> gnu.org> writes:

>> -	(message "Wrote %s" buffer-file-name))))
>> +	(message "Wrote %d characters to %s" (- end start) buffer-file-name))))
>
> Shouldn't this and others use `' as well?

Yeah, I think so.  I forgot to look at the others before.

[v3-0001-Output-number-of-characters-added-to-file-Bug-354.patch (text/x-diff, inline)]
From 4f08c9eb93dec1aa923a647214d4a613f3408964 Mon Sep 17 00:00:00 2001
From: Jeff Clough <kb1vqh <at> gmail.com>
Date: Fri, 27 Feb 2015 08:52:12 -0500
Subject: [PATCH v3] Output number of characters added to file (Bug#354)

* fileio.c (write_region):
* epa-file.el (epa-file-write-region):
* jka-compr.el (jka-compr-write-region):
* ange-ftp.el (ange-ftp-write-region):
* tramp-gvfs.el (tramp-gvfs-handle-write-region):
* tramp-sh.el (tramp-sh-handle-write-region):
* mm-util.el (mm-append-to-file): Functions now output
characters written in addition to file name.
* files.texi: Added documentation to write-region and
append-to-file describing their output.
---
 doc/emacs/files.texi   |  8 +++++---
 etc/NEWS               |  5 +++++
 lisp/epa-file.el       |  2 +-
 lisp/gnus/mm-util.el   |  2 +-
 lisp/jka-compr.el      |  2 +-
 lisp/net/ange-ftp.el   |  2 +-
 lisp/net/tramp-gvfs.el |  2 +-
 lisp/net/tramp-sh.el   |  3 ++-
 src/fileio.c           | 14 +++++++-------
 9 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index 0b730e27d3..ed17f66ca2 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -1641,9 +1641,11 @@ Misc File Ops
   @kbd{M-x write-region} is the inverse of @kbd{M-x insert-file}; it
 copies the contents of the region into the specified file.  @kbd{M-x
 append-to-file} adds the text of the region to the end of the
-specified file.  @xref{Accumulating Text}.  The variable
-@code{write-region-inhibit-fsync} applies to these commands, as well
-as saving files; see @ref{Customize Save}.
+specified file.  @xref{Accumulating Text}.  When called interactively,
+these commands will print a message in the echo area giving the name
+of the file affected as well as the number of characters which were
+added.  The variable @code{write-region-inhibit-fsync} applies to
+these commands, as well as saving files; see @ref{Customize Save}.
 
 @findex set-file-modes
 @cindex file modes
diff --git a/etc/NEWS b/etc/NEWS
index f3ec3fe904..4e4da7d470 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -90,6 +90,11 @@ required capabilities are found in terminfo.  See the FAQ node
 
 * Changes in Emacs 26.1
 
++++
+** The functions write-region, append-to-file, and the like now output
+the number of characters added in addition to the name of the file
+affected.
+
 ** The variable 'emacs-version' no longer includes the build number.
 This is now stored separately in a new variable, 'emacs-build-number'.
 
diff --git a/lisp/epa-file.el b/lisp/epa-file.el
index c97acb837a..72ffb58c30 100644
--- a/lisp/epa-file.el
+++ b/lisp/epa-file.el
@@ -290,7 +290,7 @@ epa-file-write-region
     (if (or (eq visit t)
 	    (eq visit nil)
 	    (stringp visit))
-	(message "Wrote %s" buffer-file-name))))
+	(message "Wrote %d characters to `%s'" (- end start) buffer-file-name))))
 (put 'write-region 'epa-file 'epa-file-write-region)
 
 (defun epa-file-select-keys ()
diff --git a/lisp/gnus/mm-util.el b/lisp/gnus/mm-util.el
index 89f397e3ed..f0dc803edd 100644
--- a/lisp/gnus/mm-util.el
+++ b/lisp/gnus/mm-util.el
@@ -736,7 +736,7 @@ mm-append-to-file
 		     inhibit-file-name-handlers)
 	   inhibit-file-name-handlers)))
     (write-region start end filename t 'no-message)
-    (message "Appended to %s" filename)))
+    (message "Appended %d characters to `%s'" (- end start) filename)))
 
 (defun mm-write-region (start end filename &optional append visit lockname
 			      coding-system inhibit)
diff --git a/lisp/jka-compr.el b/lisp/jka-compr.el
index 26a7cf506f..55440a709c 100644
--- a/lisp/jka-compr.el
+++ b/lisp/jka-compr.el
@@ -357,7 +357,7 @@ jka-compr-write-region
 	  (and (or (eq visit t)
 		   (eq visit nil)
 		   (stringp visit))
-	       (message "Wrote %s" visit-file))
+	       (message "Wrote %d characters to `%s'" (- end start) visit-file))
 
 	  ;; ensure `last-coding-system-used' has an appropriate value
 	  (setq last-coding-system-used coding-system-used)
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el
index cafdb3ecb0..aecb9e1ecb 100644
--- a/lisp/net/ange-ftp.el
+++ b/lisp/net/ange-ftp.el
@@ -3284,7 +3284,7 @@ ange-ftp-write-region
 		(set-buffer-modified-p nil)))
 	  ;; ensure `last-coding-system-used' has an appropriate value
 	  (setq last-coding-system-used coding-system-used)
-	  (ange-ftp-message "Wrote %s" abbr)
+	  (ange-ftp-message "Wrote %d characters to `%s'" (- end start) abbr)
 	  (ange-ftp-add-file-entry filename))
       (ange-ftp-real-write-region start end filename append visit))))
 
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 59d8771cf1..8ab34af85b 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -1223,7 +1223,7 @@ tramp-gvfs-handle-write-region
 
     ;; The end.
     (when (or (eq visit t) (null visit) (stringp visit))
-      (tramp-message v 0 "Wrote %s" filename))
+      (tramp-message v 0 "Wrote %d characters to `%s'" (- end start) filename))
     (run-hooks 'tramp-handle-write-region-hook)))
 
 
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index e4a48b7f8e..68bed278ed 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -3411,7 +3411,8 @@ tramp-sh-handle-write-region
         (when need-chown
           (tramp-set-file-uid-gid filename uid gid))
 	(when (or (eq visit t) (null visit) (stringp visit))
-	  (tramp-message v 0 "Wrote %s" filename))
+          (tramp-message v 0 "Wrote %d characters to `%s'"
+                         (- end start) filename))
 	(run-hooks 'tramp-handle-write-region-hook)))))
 
 (defvar tramp-vc-registered-file-names nil
diff --git a/src/fileio.c b/src/fileio.c
index acbf76e0d8..893d13192b 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5150,13 +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);
-
+    CALLN (Fmessage,
+           (build_string ("%s %d characters of `%s'"),
+            build_string (NUMBERP (append) ? "Updated"
+                          : ! NILP (append) ? "Added"
+                          : "Wrote"),
+            make_number (XINT (end) - XINT (start)),
+            visit_file));
   return Qnil;
 }
 
-- 
2.11.1


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#354; Package emacs. (Sun, 02 Apr 2017 18:25:02 GMT) Full text and rfc822 format available.

Message #62 received at 354 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: npostavs <at> users.sourceforge.net, Eli Zaretskii <eliz <at> gnu.org>
Cc: 354 <at> debbugs.gnu.org, kb1vqh <at> gmail.com
Subject: Re: bug#354: "Added (how many lines, bytes?!) to file.txt"
Date: Sun, 2 Apr 2017 11:24:30 -0700
On 04/01/2017 08:55 PM, npostavs <at> users.sourceforge.net wrote:
> +           (build_string ("%s %d characters of `%s'"),
> +            build_string (NUMBERP (append) ? "Updated"
> +                          : ! NILP (append) ? "Added"
> +                          : "Wrote"),

This should use AUTO_STRING instead of build_string. Also, follow the 
old code and use just one string (a format) instead of two, as it's more 
important to use idiomatic English than to save a few bytes in the Emacs 
executable.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#354; Package emacs. (Sun, 02 Apr 2017 18:39:02 GMT) Full text and rfc822 format available.

Message #65 received at 354 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 354 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, kb1vqh <at> gmail.com
Subject: Re: bug#354: "Added (how many lines, bytes?!) to file.txt"
Date: Sun, 02 Apr 2017 14:40:06 -0400
Paul Eggert <eggert <at> cs.ucla.edu> writes:

> On 04/01/2017 08:55 PM, npostavs <at> users.sourceforge.net wrote:
>> +           (build_string ("%s %d characters of `%s'"),
>> +            build_string (NUMBERP (append) ? "Updated"
>> +                          : ! NILP (append) ? "Added"
>> +                          : "Wrote"),
>
> This should use AUTO_STRING instead of build_string.

Okay.  (there seems to be a lot of different ways to create a lisp
string object)

> Also, follow the
> old code and use just one string (a format) instead of two, as it's
> more important to use idiomatic English than to save a few bytes in
> the Emacs executable.

I find the code more readable when there is only one format string,
instead of a conditional choosing amongst three.  I'm not sure what you
mean about "idiomatic English" as both versions produce the same text.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#354; Package emacs. (Sun, 02 Apr 2017 18:45:02 GMT) Full text and rfc822 format available.

Message #68 received at 354 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: npostavs <at> users.sourceforge.net
Cc: 354 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, kb1vqh <at> gmail.com
Subject: Re: bug#354: "Added (how many lines, bytes?!) to file.txt"
Date: Sun, 2 Apr 2017 11:44:34 -0700
On 04/02/2017 11:40 AM, npostavs <at> users.sourceforge.net wrote:
> I'm not sure what you
> mean about "idiomatic English" as both versions produce the same text.

The old version says "Added to FOO" whereas the new says "Added N 
characters of `FOO'". The "to" is more idiomatic than the "of".

Part of the idea is to make Emacs more translatable in the future, if we 
should ever get around to doing that. It's typically easier to translate 
three English-language format strings that talk about three different 
things, than to try to translate three-way Lisp code that assumes 
English grammar when constructing a single format string. Admittedly 
Emacs often uses tricky code like this elsewhere; still, it's better to 
avoid adding more such tricks.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#354; Package emacs. (Sun, 02 Apr 2017 19:08:02 GMT) Full text and rfc822 format available.

Message #71 received at 354 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 354 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, kb1vqh <at> gmail.com
Subject: Re: bug#354: "Added (how many lines, bytes?!) to file.txt"
Date: Sun, 02 Apr 2017 15:09:07 -0400
Paul Eggert <eggert <at> cs.ucla.edu> writes:

> On 04/02/2017 11:40 AM, npostavs <at> users.sourceforge.net wrote:
>> I'm not sure what you
>> mean about "idiomatic English" as both versions produce the same text.
>
> The old version says "Added to FOO" whereas the new says "Added N
> characters of `FOO'". The "to" is more idiomatic than the "of".

Oh, huh.  Apparently I didn't actually read the original code.  I must
*really* not like the multi-format string style.  But yes, producing a
correct message is more important.  Here's the fixed code:

  if (!auto_saving && !noninteractive)
    {
      AUTO_STRING (format, NUMBERP (append)
                   ? "Updated %d characters of `%s'"
                   : ! NILP (append)
                   ? "Added %d characters to `%s'"
                   : "Wrote %d characters to `%s'");
      CALLN (Fmessage, format,
             make_number (XINT (end) - XINT (start)),
             visit_file);
    }




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#354; Package emacs. (Fri, 07 Apr 2017 02:27:02 GMT) Full text and rfc822 format available.

Message #74 received at 354 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 354 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, kb1vqh <at> gmail.com
Subject: Re: bug#354: "Added (how many lines, bytes?!) to file.txt"
Date: Thu, 06 Apr 2017 22:27:46 -0400
tags 354 fixed
close 354 26.1
quit

npostavs <at> users.sourceforge.net writes:

>  Here's the fixed code:

Pushed to master [1: cd0a7951fb].

1: 2017-04-06 22:23:27 -0400 cd0a7951fb762570c4b9c2cdbb43c94cb68910d4
  Output number of characters added to file (Bug#354)




Added tag(s) fixed. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Fri, 07 Apr 2017 02:27:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 26.1, send any further explanations to 354 <at> debbugs.gnu.org and jidanni <at> jidanni.org Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Fri, 07 Apr 2017 02:27:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#354; Package emacs. (Mon, 10 Apr 2017 02:17:02 GMT) Full text and rfc822 format available.

Message #81 received at 354 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: jidanni <at> jidanni.org
Cc: 354 <at> debbugs.gnu.org
Subject: Re: bug#354: "Added (how many lines, bytes?!) to file.txt"
Date: Sun, 09 Apr 2017 22:17:54 -0400
jidanni <at> jidanni.org writes:

> Gentlemen, (I sound like Prince's "Partyman" song)
> I noticed all append-to-file says is
> "Added to /var/neurdsbeurg.txt".
>
> The problem is often the user thinks "good, thanks", when days later
> he discovers few or no lines got added, that's right, even 0 bytes
> will produce the same message. You see often we are not fully aware of
> the extent of our regions, colored or not, especially when extending
> off the screen.
>
> Therefore I propose you change that message to say instead how many
> line or bytes or characters or both or all three were copied over.
>
> All this of course also applies to write-region.

While the proposed solution of adding information to the message seemed
good in theory, in practice it has turned out to be kind of annoying.
I'm not sure if this is worth adding yet another option that hardly
anyone will use.

Is the problem mainly about writing 0 bytes to a file, perhaps we can
just add a warning for that particular case?

At this point I'm considering just reverting the recent changes for
this, and marking the bug wontfix.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 08 May 2017 11:24:05 GMT) Full text and rfc822 format available.

bug unarchived. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Tue, 09 May 2017 04:38:02 GMT) Full text and rfc822 format available.

Added tag(s) wontfix; removed tag(s) fixed and patch. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Tue, 09 May 2017 04:38:02 GMT) Full text and rfc822 format available.

bug No longer marked as fixed in versions 26.1. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Tue, 09 May 2017 04:41:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 06 Jun 2017 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 325 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.