From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#354: "Added (how many lines, bytes?!) to file.txt" Date: Sun, 02 Apr 2017 12:10:36 -0400 Message-ID: <87zifyx01v.fsf@users.sourceforge.net> References: <54F01AE2.8050406@cs.ucla.edu> <87y4njzckz.fsf@gmail.com> <87fuig7jxo.fsf@users.sourceforge.net> <83h92vc0op.fsf@gnu.org> <87mvc021mr.fsf@users.sourceforge.net> <83zig04q2n.fsf@gnu.org> <87shlrxy2e.fsf@users.sourceforge.net> <871stb1gil.fsf@linux-m68k.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1491149418 26884 195.159.176.226 (2 Apr 2017 16:10:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 2 Apr 2017 16:10:18 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cc: 354@debbugs.gnu.org, eggert@cs.ucla.edu, kb1vqh@gmail.com To: Andreas Schwab Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 02 18:10:13 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cui4y-00069F-5N for geb-bug-gnu-emacs@m.gmane.org; Sun, 02 Apr 2017 18:10:12 +0200 Original-Received: from localhost ([::1]:55632 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cui50-00070t-M8 for geb-bug-gnu-emacs@m.gmane.org; Sun, 02 Apr 2017 12:10:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37041) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cui4t-0006xA-Ea for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2017 12:10:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cui4o-0001bH-DD for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2017 12:10:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:59472) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cui4o-0001au-8r for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2017 12:10:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cui4n-0007m1-V4 for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2017 12:10:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 02 Apr 2017 16:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 354 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 354-submit@debbugs.gnu.org id=B354.149114936229830 (code B ref 354); Sun, 02 Apr 2017 16:10:01 +0000 Original-Received: (at 354) by debbugs.gnu.org; 2 Apr 2017 16:09:22 +0000 Original-Received: from localhost ([127.0.0.1]:57671 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cui4A-0007l3-Dg for submit@debbugs.gnu.org; Sun, 02 Apr 2017 12:09:22 -0400 Original-Received: from mail-it0-f46.google.com ([209.85.214.46]:36018) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cui48-0007ko-Ep for 354@debbugs.gnu.org; Sun, 02 Apr 2017 12:09:20 -0400 Original-Received: by mail-it0-f46.google.com with SMTP id e75so35398545itd.1 for <354@debbugs.gnu.org>; Sun, 02 Apr 2017 09:09:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=mI5q6fGFkwzfnyWFCUjavxfYlfqZwr9LudfjBy0pT5U=; b=a6JmDpaE/Xd/UYrwiMH3l+tVs4Xc6mY0B4tv4bvi95fX7nk2OAMRYfE5MvSv8lQmpj 0gFYOzwFGapAQb/HCB6Lg35ar9eY9A0H3xZ6o2L/ko+HkDAct5JdhDlk01ZcvFrR9fIh oAnqUaLb9k1EB77Y+voDHKORmuPGL+Bc0KhH7I785hgnTPQMytICcrgTLAOj1DexGTOh 0Fa9nwwzElJl/Q/enQBSKV68GOzNeBw6Kz6hQkz+iBsaicCl3VXXQeddI4JGf3vtMJrN Zga10f5Kp51PjJdFqfpaLvE1s9HnsB8fSL/cwDLLcj6Y2MHfHyaDJCPO3b1UhoU1BB7p qNxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=mI5q6fGFkwzfnyWFCUjavxfYlfqZwr9LudfjBy0pT5U=; b=b9+HuSVOsbZ3lyFdIy9izdKIoutg5Ml5Iva0NZfqYL8ix3YXKJ9nGd3LMu4OLifWo2 34BKN6U4P30kw5kU0B/YBWyDT3AjXPotUaeu14LnPlkk9e7+zaKMDHIQA8wGISrKY4hf luvgGaRKkotoyoGuz/z7YhZiB1ne10gosy1R/4ZhmElQg/ETbGU28MzwlwlYFvngmwh8 I1WCUN5PaoH/ayvtpCmnkSZtaDr6MuhGvjRfR4OLM5gnDO2cx35bMi1H09OAZplbRn3S hc0UUZHdH89blEVfAurcf4KGb10xpk2l9YslPlFDAeHWkQsTwP3fsfd7NMqmZemrJlS8 JEew== X-Gm-Message-State: AFeK/H2GOVhXqC4gSY3HDYJGbADJj7I3fq3HyYItOMOB+ZQrQ3XK48rbopgJ8pIZg/7pDQ== X-Received: by 10.36.4.88 with SMTP id 85mr6429049itb.92.1491149354915; Sun, 02 Apr 2017 09:09:14 -0700 (PDT) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id f63sm4498142ita.26.2017.04.02.09.09.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 02 Apr 2017 09:09:14 -0700 (PDT) In-Reply-To: <871stb1gil.fsf@linux-m68k.org> (Andreas Schwab's message of "Sun, 02 Apr 2017 08:16:02 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:131220 Archived-At: --=-=-= Content-Type: text/plain Andreas Schwab writes: > > Missing a close paren. Oops. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v3-0001-src-xdisp.c-vmessage-message-Clarify-commentary.patch Content-Description: patch >From d085d1fd7283fe29f656c49f619e33eb2f47829d Mon Sep 17 00:00:00 2001 From: Noam Postavsky 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 --=-=-= Content-Type: text/plain Eli Zaretskii 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v3-0001-Output-number-of-characters-added-to-file-Bug-354.patch Content-Description: patch >From 4f08c9eb93dec1aa923a647214d4a613f3408964 Mon Sep 17 00:00:00 2001 From: Jeff Clough 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 * 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))) 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; } -- 2.11.1 --=-=-=--