From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jeff Clough Newsgroups: gmane.emacs.bugs Subject: bug#354: "Added (how many lines, bytes?!) to file.txt" Date: Fri, 27 Feb 2015 08:52:12 -0500 Message-ID: <87y4njzckz.fsf@gmail.com> References: <54F01AE2.8050406@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1425056334 32597 80.91.229.3 (27 Feb 2015 16:58:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 27 Feb 2015 16:58:54 +0000 (UTC) Cc: 354@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Feb 27 17:58:44 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YROFO-0000xT-Gz for geb-bug-gnu-emacs@m.gmane.org; Fri, 27 Feb 2015 17:58:42 +0100 Original-Received: from localhost ([::1]:37460 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YROFN-0001VL-VY for geb-bug-gnu-emacs@m.gmane.org; Fri, 27 Feb 2015 11:58:41 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41597) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YROEn-0000Vd-27 for bug-gnu-emacs@gnu.org; Fri, 27 Feb 2015 11:58:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YROEk-0003MI-9L for bug-gnu-emacs@gnu.org; Fri, 27 Feb 2015 11:58:05 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:56546) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YROEk-0003M6-6e for bug-gnu-emacs@gnu.org; Fri, 27 Feb 2015 11:58:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YROEj-0007Mu-Ns for bug-gnu-emacs@gnu.org; Fri, 27 Feb 2015 11:58:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jeff Clough Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 27 Feb 2015 16:58: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: Original-Received: via spool by 354-submit@debbugs.gnu.org id=B354.142505627928314 (code B ref 354); Fri, 27 Feb 2015 16:58:01 +0000 Original-Received: (at 354) by debbugs.gnu.org; 27 Feb 2015 16:57:59 +0000 Original-Received: from localhost ([127.0.0.1]:60144 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YROEf-0007Mb-Sm for submit@debbugs.gnu.org; Fri, 27 Feb 2015 11:57:58 -0500 Original-Received: from mail-qc0-f182.google.com ([209.85.216.182]:44420) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YRLL4-0002vt-Di for 354@debbugs.gnu.org; Fri, 27 Feb 2015 08:52:23 -0500 Original-Received: by qcvs11 with SMTP id s11so13859817qcv.11 for <354@debbugs.gnu.org>; Fri, 27 Feb 2015 05:52:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=ksC26xxHdcY6nnBSHR7ykQzwIN+yNs18TW23GUJBxxI=; b=XfROAiwRXnybKjnVHC/aa0Yx0CHEmEsrLEbOlUxH97uya9wbBRemFQ+nJHSYIBzqnc cjvk8srZVmETGR1kWiNg59Ayz3XtPWE6KBvD2eExBDyhZwjOLdM88f0P6mB/0rWbcfAF wSisDfcN6zCsuFypNIZFumx0LjHNRVXqca+8YIAvJ2jEI4cVLPK3uq483cc6FOffqohL /+qv3LvRDKJIn7Sqvcrl0+tS6uwKsy4kL3+IuAS8f7QkwHPDy+ewAFTCtbm71K8XVfpk HDufoscZ/6k0RlMasalsGzibgaep5YpH0AgTxQF58hwm1+V3p9LwCqUAjsDhCX4/6NdK 38DA== X-Received: by 10.229.114.74 with SMTP id d10mr29424825qcq.5.1425045136736; Fri, 27 Feb 2015 05:52:16 -0800 (PST) Original-Received: from jeff-Inspiron-3537 (cpe-74-69-219-28.maine.res.rr.com. [74.69.219.28]) by mx.google.com with ESMTPSA id b14sm2631896qaq.46.2015.02.27.05.52.13 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 27 Feb 2015 05:52:15 -0800 (PST) In-Reply-To: <54F01AE2.8050406@cs.ucla.edu> (Paul Eggert's message of "Thu, 26 Feb 2015 23:21:06 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.90 (gnu/linux) X-Mailman-Approved-At: Fri, 27 Feb 2015 11:57:57 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:99874 Archived-At: 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. * 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))) 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 + + * 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 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