emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master c311b8b: New var write-region-verbose, default nil


From: Paul Eggert
Subject: [Emacs-diffs] master c311b8b: New var write-region-verbose, default nil
Date: Sat, 6 May 2017 21:05:31 -0400 (EDT)

branch: master
commit c311b8b15e91dd07e2d23d8d21ebb53d0b5f2204
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    New var write-region-verbose, default nil
    
    By popular demand, write-region char counts are now off by default
    (Bug#26796).
    * src/fileio.c (write-region-verbose): New Lisp var.
    (write_region): Output char count only if the var is non-nil.
    * doc/emacs/files.texi (Misc File Ops), etc/NEWS: Document this.
---
 doc/emacs/files.texi |  7 ++++---
 etc/NEWS             |  6 +++---
 src/fileio.c         | 34 +++++++++++++++++++++++-----------
 3 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index bc977b7..d36fe65 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -1657,9 +1657,10 @@ similar to the @kbd{M-x find-file-literally} command
 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}.  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 print a message in the echo area giving the name
+of the file affected; if the variable @code{write-region-verbose} is
+non-nil the message also reports the number of characters written.
+The variable @code{write-region-inhibit-fsync} applies to
 these commands, as well as saving files; see @ref{Customize Save}.
 
 @findex set-file-modes
diff --git a/etc/NEWS b/etc/NEWS
index 2918c6e..1f1f4b4 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -94,9 +94,9 @@ 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 functions write-region, append-to-file, and the like now also
+output the number of characters added in addition to the name of the
+file affected, if the new variable 'write-region-verbose' is non-nil.
 
 ** 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/src/fileio.c b/src/fileio.c
index ad5ab61..6138bfc 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5153,17 +5153,24 @@ write_region (Lisp_Object start, Lisp_Object end, 
Lisp_Object filename,
     {
       EMACS_INT nchars = (STRINGP (start) ? SCHARS (start)
                          : XINT (end) - XINT (start));
-      AUTO_STRING (format, NUMBERP (append)
-                   ? (nchars != 1
-                     ? "Updated `%s' (%d characters)"
-                     : "Updated `%s' (%d character)")
-                   : ! NILP (append)
-                  ? (nchars != 1
-                     ? "Added to `%s' (%d characters)"
-                     : "Added to `%s' (%d character)")
-                   : (nchars != 1
-                     ? "Wrote `%s' (%d characters)"
-                     : "Wrote `%s' (%d character)"));
+      AUTO_STRING (format,
+                  (NUMBERP (append)
+                   ? (NILP (Vwrite_region_verbose)
+                      ? "Updated `%s'"
+                      : nchars == 1
+                      ? "Updated `%s' (1 character)"
+                      : "Updated `%s' (%d characters)")
+                   : ! NILP (append)
+                   ? (NILP (Vwrite_region_verbose)
+                      ? "Added to `%s'"
+                      : nchars == 1
+                      ? "Added to `%s' (1 character)"
+                      : "Added to `%s' (%d characters)")
+                   : (NILP (Vwrite_region_verbose)
+                      ? "Wrote `%s'"
+                      : nchars == 1
+                      ? "Wrote `%s' (1 character)"
+                      : "Wrote `%s' (%d characters)")));
       CALLN (Fmessage, format, visit_file, make_number (nchars));
     }
   return Qnil;
@@ -6135,6 +6142,11 @@ These are the annotations made by other annotation 
functions
 that were already called.  See also `write-region-annotate-functions'.  */);
   Vwrite_region_annotations_so_far = Qnil;
 
+  DEFVAR_LISP ("write-region-verbose",
+              Vwrite_region_verbose,
+              doc: /* If non-nil, be more verbose when writing a region.  */);
+  Vwrite_region_verbose = Qnil;
+
   DEFVAR_LISP ("inhibit-file-name-handlers", Vinhibit_file_name_handlers,
               doc: /* A list of file name handlers that temporarily should not 
be used.
 This applies only to the operation `inhibit-file-name-operation'.  */);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]