* bug#354: "Added (how many lines, bytes?!) to file.txt"
@ 2008-06-03 18:37 jidanni
2008-06-03 21:07 ` Stefan Monnier
` (3 more replies)
0 siblings, 4 replies; 20+ messages in thread
From: jidanni @ 2008-06-03 18:37 UTC (permalink / raw)
To: bug-gnu-emacs
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.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2008-06-03 18:37 bug#354: "Added (how many lines, bytes?!) to file.txt" jidanni
@ 2008-06-03 21:07 ` Stefan Monnier
2008-06-06 4:02 ` Kevin Rodgers
` (2 subsequent siblings)
3 siblings, 0 replies; 20+ messages in thread
From: Stefan Monnier @ 2008-06-03 21:07 UTC (permalink / raw)
To: 354
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
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2008-06-03 18:37 bug#354: "Added (how many lines, bytes?!) to file.txt" jidanni
2008-06-03 21:07 ` Stefan Monnier
@ 2008-06-06 4:02 ` Kevin Rodgers
2008-06-06 14:56 ` Drew Adams
2015-02-27 7:21 ` Paul Eggert
2017-04-10 2:17 ` npostavs
3 siblings, 1 reply; 20+ messages in thread
From: Kevin Rodgers @ 2008-06-06 4:02 UTC (permalink / raw)
To: bug-gnu-emacs
jidanni@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
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2008-06-06 4:02 ` Kevin Rodgers
@ 2008-06-06 14:56 ` Drew Adams
0 siblings, 0 replies; 20+ messages in thread
From: Drew Adams @ 2008-06-06 14:56 UTC (permalink / raw)
To: 'Kevin Rodgers', 354, bug-gnu-emacs
> 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).
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2008-06-03 18:37 bug#354: "Added (how many lines, bytes?!) to file.txt" jidanni
2008-06-03 21:07 ` Stefan Monnier
2008-06-06 4:02 ` Kevin Rodgers
@ 2015-02-27 7:21 ` Paul Eggert
2015-02-27 13:52 ` Jeff Clough
2017-04-10 2:17 ` npostavs
3 siblings, 1 reply; 20+ messages in thread
From: Paul Eggert @ 2015-02-27 7:21 UTC (permalink / raw)
To: Jeff Clough; +Cc: 354
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.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2015-02-27 7:21 ` Paul Eggert
@ 2015-02-27 13:52 ` Jeff Clough
2017-03-14 0:58 ` npostavs
0 siblings, 1 reply; 20+ messages in thread
From: Jeff Clough @ 2015-02-27 13:52 UTC (permalink / raw)
To: Paul Eggert; +Cc: 354
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.
\f
* 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)))
\f
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@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@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
^ permalink raw reply related [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2015-02-27 13:52 ` Jeff Clough
@ 2017-03-14 0:58 ` npostavs
2017-03-14 15:55 ` Eli Zaretskii
0 siblings, 1 reply; 20+ messages in thread
From: npostavs @ 2017-03-14 0:58 UTC (permalink / raw)
To: Jeff Clough; +Cc: 354, Paul Eggert
[-- Attachment #1: Type: text/plain, Size: 371 bytes --]
tags 354 patch
quit
Jeff Clough <kb1vqh@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).
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 6318 bytes --]
From fd1c97f4d9f417d4ded4ec40b52daac70f15137c Mon Sep 17 00:00:00 2001
From: Jeff Clough <kb1vqh@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
\f
* 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)))
\f
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
^ permalink raw reply related [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2017-03-14 0:58 ` npostavs
@ 2017-03-14 15:55 ` Eli Zaretskii
2017-04-01 4:27 ` npostavs
0 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2017-03-14 15:55 UTC (permalink / raw)
To: npostavs; +Cc: 354, kb1vqh, eggert
> From: npostavs@users.sourceforge.net
> Date: Mon, 13 Mar 2017 20:58:59 -0400
> Cc: 354@debbugs.gnu.org, Paul Eggert <eggert@cs.ucla.edu>
>
> Jeff Clough <kb1vqh@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.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2017-03-14 15:55 ` Eli Zaretskii
@ 2017-04-01 4:27 ` npostavs
2017-04-01 6:09 ` Eli Zaretskii
0 siblings, 1 reply; 20+ messages in thread
From: npostavs @ 2017-04-01 4:27 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 354, kb1vqh, eggert
Eli Zaretskii <eliz@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);
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2017-04-01 4:27 ` npostavs
@ 2017-04-01 6:09 ` Eli Zaretskii
2017-04-02 3:55 ` npostavs
0 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2017-04-01 6:09 UTC (permalink / raw)
To: npostavs; +Cc: 354, kb1vqh, eggert
> From: npostavs@users.sourceforge.net
> Cc: 354@debbugs.gnu.org, kb1vqh@gmail.com, eggert@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.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2017-04-01 6:09 ` Eli Zaretskii
@ 2017-04-02 3:55 ` npostavs
2017-04-02 6:16 ` Andreas Schwab
` (2 more replies)
0 siblings, 3 replies; 20+ messages in thread
From: npostavs @ 2017-04-02 3:55 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 354, kb1vqh, eggert
[-- Attachment #1: Type: text/plain, Size: 287 bytes --]
Eli Zaretskii <eliz@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?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1524 bytes --]
From 156859858e03baeddeb554c8df220171adaf6bf1 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@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
[-- Attachment #3: Type: text/plain, Size: 412 bytes --]
>>
>> 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: patch --]
[-- Type: text/x-diff, Size: 6326 bytes --]
From d077e66f21621aa0ac04fb148146836322f052d6 Mon Sep 17 00:00:00 2001
From: Jeff Clough <kb1vqh@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
\f
* 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)))
\f
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;
}
\f
--
2.11.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2017-04-02 3:55 ` npostavs
@ 2017-04-02 6:16 ` Andreas Schwab
2017-04-02 16:10 ` npostavs
2017-04-02 15:52 ` Eli Zaretskii
2017-04-02 18:24 ` Paul Eggert
2 siblings, 1 reply; 20+ messages in thread
From: Andreas Schwab @ 2017-04-02 6:16 UTC (permalink / raw)
To: npostavs; +Cc: 354, eggert, kb1vqh
On Apr 01 2017, npostavs@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@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2017-04-02 3:55 ` npostavs
2017-04-02 6:16 ` Andreas Schwab
@ 2017-04-02 15:52 ` Eli Zaretskii
2017-04-02 18:24 ` Paul Eggert
2 siblings, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2017-04-02 15:52 UTC (permalink / raw)
To: npostavs; +Cc: 354, kb1vqh, eggert
> From: npostavs@users.sourceforge.net
> Cc: 354@debbugs.gnu.org, kb1vqh@gmail.com, eggert@cs.ucla.edu
> Date: Sat, 01 Apr 2017 23:55:53 -0400
>
> Eli Zaretskii <eliz@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.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2017-04-02 6:16 ` Andreas Schwab
@ 2017-04-02 16:10 ` npostavs
0 siblings, 0 replies; 20+ messages in thread
From: npostavs @ 2017-04-02 16:10 UTC (permalink / raw)
To: Andreas Schwab; +Cc: 354, eggert, kb1vqh
[-- Attachment #1: Type: text/plain, Size: 83 bytes --]
Andreas Schwab <schwab@linux-m68k.org> writes:
>
> Missing a close paren.
Oops.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1528 bytes --]
From d085d1fd7283fe29f656c49f619e33eb2f47829d Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@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
[-- Attachment #3: Type: text/plain, Size: 269 bytes --]
Eli Zaretskii <eliz@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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: patch --]
[-- Type: text/x-diff, Size: 6338 bytes --]
From 4f08c9eb93dec1aa923a647214d4a613f3408964 Mon Sep 17 00:00:00 2001
From: Jeff Clough <kb1vqh@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
\f
* 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)))
\f
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;
}
\f
--
2.11.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2017-04-02 3:55 ` npostavs
2017-04-02 6:16 ` Andreas Schwab
2017-04-02 15:52 ` Eli Zaretskii
@ 2017-04-02 18:24 ` Paul Eggert
2017-04-02 18:40 ` npostavs
2 siblings, 1 reply; 20+ messages in thread
From: Paul Eggert @ 2017-04-02 18:24 UTC (permalink / raw)
To: npostavs, Eli Zaretskii; +Cc: 354, kb1vqh
On 04/01/2017 08:55 PM, npostavs@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.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2017-04-02 18:24 ` Paul Eggert
@ 2017-04-02 18:40 ` npostavs
2017-04-02 18:44 ` Paul Eggert
0 siblings, 1 reply; 20+ messages in thread
From: npostavs @ 2017-04-02 18:40 UTC (permalink / raw)
To: Paul Eggert; +Cc: 354, kb1vqh
Paul Eggert <eggert@cs.ucla.edu> writes:
> On 04/01/2017 08:55 PM, npostavs@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.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2017-04-02 18:40 ` npostavs
@ 2017-04-02 18:44 ` Paul Eggert
2017-04-02 19:09 ` npostavs
0 siblings, 1 reply; 20+ messages in thread
From: Paul Eggert @ 2017-04-02 18:44 UTC (permalink / raw)
To: npostavs; +Cc: 354, kb1vqh
On 04/02/2017 11:40 AM, npostavs@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.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2017-04-02 18:44 ` Paul Eggert
@ 2017-04-02 19:09 ` npostavs
2017-04-07 2:27 ` npostavs
0 siblings, 1 reply; 20+ messages in thread
From: npostavs @ 2017-04-02 19:09 UTC (permalink / raw)
To: Paul Eggert; +Cc: 354, kb1vqh
Paul Eggert <eggert@cs.ucla.edu> writes:
> On 04/02/2017 11:40 AM, npostavs@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);
}
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2017-04-02 19:09 ` npostavs
@ 2017-04-07 2:27 ` npostavs
0 siblings, 0 replies; 20+ messages in thread
From: npostavs @ 2017-04-07 2:27 UTC (permalink / raw)
To: Paul Eggert; +Cc: 354, kb1vqh
tags 354 fixed
close 354 26.1
quit
npostavs@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)
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#354: "Added (how many lines, bytes?!) to file.txt"
2008-06-03 18:37 bug#354: "Added (how many lines, bytes?!) to file.txt" jidanni
` (2 preceding siblings ...)
2015-02-27 7:21 ` Paul Eggert
@ 2017-04-10 2:17 ` npostavs
3 siblings, 0 replies; 20+ messages in thread
From: npostavs @ 2017-04-10 2:17 UTC (permalink / raw)
To: jidanni; +Cc: 354
jidanni@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.
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2017-04-10 2:17 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-03 18:37 bug#354: "Added (how many lines, bytes?!) to file.txt" jidanni
2008-06-03 21:07 ` Stefan Monnier
2008-06-06 4:02 ` Kevin Rodgers
2008-06-06 14:56 ` Drew Adams
2015-02-27 7:21 ` Paul Eggert
2015-02-27 13:52 ` Jeff Clough
2017-03-14 0:58 ` npostavs
2017-03-14 15:55 ` Eli Zaretskii
2017-04-01 4:27 ` npostavs
2017-04-01 6:09 ` Eli Zaretskii
2017-04-02 3:55 ` npostavs
2017-04-02 6:16 ` Andreas Schwab
2017-04-02 16:10 ` npostavs
2017-04-02 15:52 ` Eli Zaretskii
2017-04-02 18:24 ` Paul Eggert
2017-04-02 18:40 ` npostavs
2017-04-02 18:44 ` Paul Eggert
2017-04-02 19:09 ` npostavs
2017-04-07 2:27 ` npostavs
2017-04-10 2:17 ` npostavs
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.