From: npostavs@users.sourceforge.net
To: Eli Zaretskii <eliz@gnu.org>
Cc: 354@debbugs.gnu.org, kb1vqh@gmail.com, eggert@cs.ucla.edu
Subject: bug#354: "Added (how many lines, bytes?!) to file.txt"
Date: Sat, 01 Apr 2017 23:55:53 -0400 [thread overview]
Message-ID: <87shlrxy2e.fsf@users.sourceforge.net> (raw)
In-Reply-To: <83zig04q2n.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 01 Apr 2017 09:09:04 +0300")
[-- 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
next prev parent reply other threads:[~2017-04-02 3:55 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87shlrxy2e.fsf@users.sourceforge.net \
--to=npostavs@users.sourceforge.net \
--cc=354@debbugs.gnu.org \
--cc=eggert@cs.ucla.edu \
--cc=eliz@gnu.org \
--cc=kb1vqh@gmail.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).