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: Sat, 01 Apr 2017 23:55:53 -0400 Message-ID: <87shlrxy2e.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> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1491105326 8817 195.159.176.226 (2 Apr 2017 03:55:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 2 Apr 2017 03:55:26 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cc: 354@debbugs.gnu.org, kb1vqh@gmail.com, eggert@cs.ucla.edu To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 02 05:55:20 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 1cuWbm-0000vJ-45 for geb-bug-gnu-emacs@m.gmane.org; Sun, 02 Apr 2017 05:55:18 +0200 Original-Received: from localhost ([::1]:53570 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuWbo-0006le-Vs for geb-bug-gnu-emacs@m.gmane.org; Sat, 01 Apr 2017 23:55:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuWbb-0006lU-A7 for bug-gnu-emacs@gnu.org; Sat, 01 Apr 2017 23:55:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cuWbW-0000ay-9m for bug-gnu-emacs@gnu.org; Sat, 01 Apr 2017 23:55:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58074) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cuWbW-0000as-5u for bug-gnu-emacs@gnu.org; Sat, 01 Apr 2017 23:55:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cuWbV-0002LQ-WD for bug-gnu-emacs@gnu.org; Sat, 01 Apr 2017 23:55:02 -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 03:55: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.14911052788980 (code B ref 354); Sun, 02 Apr 2017 03:55:01 +0000 Original-Received: (at 354) by debbugs.gnu.org; 2 Apr 2017 03:54:38 +0000 Original-Received: from localhost ([127.0.0.1]:56273 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuWb8-0002Km-Fn for submit@debbugs.gnu.org; Sat, 01 Apr 2017 23:54:38 -0400 Original-Received: from mail-io0-f177.google.com ([209.85.223.177]:35445) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuWb6-0002KX-Ia for 354@debbugs.gnu.org; Sat, 01 Apr 2017 23:54:37 -0400 Original-Received: by mail-io0-f177.google.com with SMTP id z13so59252697iof.2 for <354@debbugs.gnu.org>; Sat, 01 Apr 2017 20:54:36 -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=77S1rN5CkzGNtz04pdaQTBXw8fsVgfGvxJbfRhly7XU=; b=roikDBjbxpUl1eUisuF2Anj+6VRt5iC+9zk3KYKugzUqomIBI3mVvCSJtxnWwX8vEn zA1mU2exsJX1kEzOUDGMqq2PqF4RLevmf2GUV3SQMKIhrkcTfozGbu4rMku/Q5mmAg20 GIyo0Qy95pMPj1wF49AzteTMcTTikE3OzP8v+r6a5ZwlRk2Zg4okPRLg9482RVtOtZFY jsAmlOQ74aQlYpHzcrQBnZrkExySJQ3ohQbhQlbulW/72kyzg90G/BUF/FFLmY13L0YZ LeviycFSHJrXGErtiKnzSVQIAK3zdt61RO1VwxKwaLBe2ZyAGhfaAbONflEO8eSdiJ3u 5K8w== 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=77S1rN5CkzGNtz04pdaQTBXw8fsVgfGvxJbfRhly7XU=; b=FWnamnPqjNnwq1JA4hs2qU05H9VoJTi79WcEC7bLbwFbMW0hc64GDd1qmSprzMPJEQ /ujMXQvkFJH2AAdgUrECgLxorpgdAy77lmZ4pgwNcLknxa8G8dadLRZVGo+qmE+7BhF9 uLPRcsaTuql56o3fTeSEZiewPMo7tTdX+HGjc355qXVha4UDZ1SdJ1lAGDtio/XNGltd yEOl4WjsPHoO0MJ/NuglB5NWA2fCOlETXS4SNAcvfcJMHnIdvtpuDEMdaLQG70JENODs eZvcSXvib5wMiYLVBPQLyNH5QBJHy264jpUN9+THpc1UXZMj9EUNRBxXYGaDtp45CofJ hQWQ== X-Gm-Message-State: AFeK/H3OjkxdDEbNramkjywtsXDmdHIAPpifulR4lwcoxyJRRxTN4VOIOqUbjMsDCGAe5g== X-Received: by 10.107.8.39 with SMTP id 39mr10468958ioi.189.1491105271050; Sat, 01 Apr 2017 20:54:31 -0700 (PDT) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id k63sm5720465ioi.19.2017.04.01.20.54.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Apr 2017 20:54:29 -0700 (PDT) In-Reply-To: <83zig04q2n.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 01 Apr 2017 09:09:04 +0300") 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:131199 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii 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? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-src-xdisp.c-vmessage-message-Clarify-commentary.patch Content-Description: patch >From 156859858e03baeddeb554c8df220171adaf6bf1 Mon Sep 17 00:00:00 2001 From: Noam Postavsky 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 --=-=-= Content-Type: text/plain >> >> 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v2-0001-Output-number-of-characters-added-to-file-Bug-354.patch Content-Description: patch >From d077e66f21621aa0ac04fb148146836322f052d6 Mon Sep 17 00:00:00 2001 From: Jeff Clough 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 * 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))) 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; } -- 2.11.1 --=-=-=--