all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: 26796@debbugs.gnu.org
Cc: larsi@gnus.org, npostavs@users.sourceforge.net
Subject: bug#26796: 26.0.50; (2 characters) is usually wrong
Date: Sat, 6 May 2017 18:11:51 -0700	[thread overview]
Message-ID: <df1c831c-c0c5-7a39-3d2c-14428c7f7d4d@cs.ucla.edu> (raw)
In-Reply-To: <m3zieqz54s.fsf@stories>

[-- Attachment #1: Type: text/plain, Size: 229 bytes --]

Appending " (NNNN characters)" to the "Wrote FOO" messages appears to be 
unpopular and at times confusing. At least it should be off by default, so I 
installed the attached. It'd be fine with me if we removed them entirely.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-New-var-write-region-verbose-default-nil.patch --]
[-- Type: text/x-diff; name="0001-New-var-write-region-verbose-default-nil.patch", Size: 4475 bytes --]

From 33c96bacd656cffeedf32038686c0ea99b7c411b Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 6 May 2017 18:00:23 -0700
Subject: [PATCH] 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 @@ Misc File Ops
 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'.  */);
-- 
2.7.4


      parent reply	other threads:[~2017-05-07  1:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-06  9:49 bug#26796: 26.0.50; (2 characters) is usually wrong Lars Ingebrigtsen
2017-05-06 10:32 ` Eli Zaretskii
2017-05-06 10:38   ` Lars Ingebrigtsen
2017-05-06 10:45   ` Lars Ingebrigtsen
2017-05-06 11:06     ` Eli Zaretskii
2017-05-06 12:16 ` npostavs
2017-05-06 14:19   ` Eli Zaretskii
2017-05-06 17:21     ` npostavs
2017-05-08  5:02     ` Mark Oteiza
2017-05-08 14:33       ` Eli Zaretskii
2017-05-08 15:59         ` Glenn Morris
2017-05-08 16:07           ` Eli Zaretskii
2017-05-09  0:41             ` Mark Oteiza
2017-05-09  4:39           ` npostavs
2017-05-07  1:11 ` Paul Eggert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=df1c831c-c0c5-7a39-3d2c-14428c7f7d4d@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=26796@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=npostavs@users.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.