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.

Full log


View this message in rfc822 format

From: Jeff Clough <kb1vqh <at> gmail.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 354 <at> debbugs.gnu.org
Subject: bug#354: "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





This bug report was last modified 8 years and 11 days ago.

Previous Next


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