aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2017-05-06 18:00:23 -0700
committerPaul Eggert2017-05-06 18:05:25 -0700
commitc311b8b15e91dd07e2d23d8d21ebb53d0b5f2204 (patch)
tree3e3166a62f6d8e920d7bbe422b8ffdf99dc7fa21
parent7f3d63908cd05fb34347d942e435c2964cd8b249 (diff)
downloademacs-c311b8b15e91dd07e2d23d8d21ebb53d0b5f2204.tar.gz
emacs-c311b8b15e91dd07e2d23d8d21ebb53d0b5f2204.zip
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.
-rw-r--r--doc/emacs/files.texi7
-rw-r--r--etc/NEWS6
-rw-r--r--src/fileio.c34
3 files changed, 30 insertions, 17 deletions
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index bc977b72c17..d36fe6541ed 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
1657copies the contents of the region into the specified file. @kbd{M-x 1657copies the contents of the region into the specified file. @kbd{M-x
1658append-to-file} adds the text of the region to the end of the 1658append-to-file} adds the text of the region to the end of the
1659specified file. @xref{Accumulating Text}. When called interactively, 1659specified file. @xref{Accumulating Text}. When called interactively,
1660these commands will print a message in the echo area giving the name 1660these commands print a message in the echo area giving the name
1661of the file affected as well as the number of characters which were 1661of the file affected; if the variable @code{write-region-verbose} is
1662added. The variable @code{write-region-inhibit-fsync} applies to 1662non-nil the message also reports the number of characters written.
1663The variable @code{write-region-inhibit-fsync} applies to
1663these commands, as well as saving files; see @ref{Customize Save}. 1664these commands, as well as saving files; see @ref{Customize Save}.
1664 1665
1665@findex set-file-modes 1666@findex set-file-modes
diff --git a/etc/NEWS b/etc/NEWS
index 2918c6ebeed..1f1f4b4b4b9 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -94,9 +94,9 @@ required capabilities are found in terminfo. See the FAQ node
94* Changes in Emacs 26.1 94* Changes in Emacs 26.1
95 95
96+++ 96+++
97** The functions write-region, append-to-file, and the like now output 97** The functions write-region, append-to-file, and the like now also
98the number of characters added in addition to the name of the file 98output the number of characters added in addition to the name of the
99affected. 99file affected, if the new variable 'write-region-verbose' is non-nil.
100 100
101** The variable 'emacs-version' no longer includes the build number. 101** The variable 'emacs-version' no longer includes the build number.
102This is now stored separately in a new variable, 'emacs-build-number'. 102This is now stored separately in a new variable, 'emacs-build-number'.
diff --git a/src/fileio.c b/src/fileio.c
index ad5ab618b02..6138bfc68bb 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5153,17 +5153,24 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
5153 { 5153 {
5154 EMACS_INT nchars = (STRINGP (start) ? SCHARS (start) 5154 EMACS_INT nchars = (STRINGP (start) ? SCHARS (start)
5155 : XINT (end) - XINT (start)); 5155 : XINT (end) - XINT (start));
5156 AUTO_STRING (format, NUMBERP (append) 5156 AUTO_STRING (format,
5157 ? (nchars != 1 5157 (NUMBERP (append)
5158 ? "Updated `%s' (%d characters)" 5158 ? (NILP (Vwrite_region_verbose)
5159 : "Updated `%s' (%d character)") 5159 ? "Updated `%s'"
5160 : ! NILP (append) 5160 : nchars == 1
5161 ? (nchars != 1 5161 ? "Updated `%s' (1 character)"
5162 ? "Added to `%s' (%d characters)" 5162 : "Updated `%s' (%d characters)")
5163 : "Added to `%s' (%d character)") 5163 : ! NILP (append)
5164 : (nchars != 1 5164 ? (NILP (Vwrite_region_verbose)
5165 ? "Wrote `%s' (%d characters)" 5165 ? "Added to `%s'"
5166 : "Wrote `%s' (%d character)")); 5166 : nchars == 1
5167 ? "Added to `%s' (1 character)"
5168 : "Added to `%s' (%d characters)")
5169 : (NILP (Vwrite_region_verbose)
5170 ? "Wrote `%s'"
5171 : nchars == 1
5172 ? "Wrote `%s' (1 character)"
5173 : "Wrote `%s' (%d characters)")));
5167 CALLN (Fmessage, format, visit_file, make_number (nchars)); 5174 CALLN (Fmessage, format, visit_file, make_number (nchars));
5168 } 5175 }
5169 return Qnil; 5176 return Qnil;
@@ -6135,6 +6142,11 @@ These are the annotations made by other annotation functions
6135that were already called. See also `write-region-annotate-functions'. */); 6142that were already called. See also `write-region-annotate-functions'. */);
6136 Vwrite_region_annotations_so_far = Qnil; 6143 Vwrite_region_annotations_so_far = Qnil;
6137 6144
6145 DEFVAR_LISP ("write-region-verbose",
6146 Vwrite_region_verbose,
6147 doc: /* If non-nil, be more verbose when writing a region. */);
6148 Vwrite_region_verbose = Qnil;
6149
6138 DEFVAR_LISP ("inhibit-file-name-handlers", Vinhibit_file_name_handlers, 6150 DEFVAR_LISP ("inhibit-file-name-handlers", Vinhibit_file_name_handlers,
6139 doc: /* A list of file name handlers that temporarily should not be used. 6151 doc: /* A list of file name handlers that temporarily should not be used.
6140This applies only to the operation `inhibit-file-name-operation'. */); 6152This applies only to the operation `inhibit-file-name-operation'. */);