diff options
| author | Jeff Clough | 2015-02-27 08:52:12 -0500 |
|---|---|---|
| committer | Noam Postavsky | 2017-04-06 22:23:27 -0400 |
| commit | cd0a7951fb762570c4b9c2cdbb43c94cb68910d4 (patch) | |
| tree | 6870503167bab052b76a22473119286859bdade1 | |
| parent | 4b3db0daa658a9b834284be8c3131b6177a28f38 (diff) | |
| download | emacs-cd0a7951fb762570c4b9c2cdbb43c94cb68910d4.tar.gz emacs-cd0a7951fb762570c4b9c2cdbb43c94cb68910d4.zip | |
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.
| -rw-r--r-- | doc/emacs/files.texi | 8 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/epa-file.el | 2 | ||||
| -rw-r--r-- | lisp/gnus/mm-util.el | 2 | ||||
| -rw-r--r-- | lisp/jka-compr.el | 2 | ||||
| -rw-r--r-- | lisp/net/ange-ftp.el | 2 | ||||
| -rw-r--r-- | lisp/net/tramp-gvfs.el | 2 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 3 | ||||
| -rw-r--r-- | src/fileio.c | 17 |
9 files changed, 27 insertions, 16 deletions
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 0b730e27d30..ed17f66ca2c 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi | |||
| @@ -1641,9 +1641,11 @@ similar to the @kbd{M-x find-file-literally} command | |||
| 1641 | @kbd{M-x write-region} is the inverse of @kbd{M-x insert-file}; it | 1641 | @kbd{M-x write-region} is the inverse of @kbd{M-x insert-file}; it |
| 1642 | copies the contents of the region into the specified file. @kbd{M-x | 1642 | copies the contents of the region into the specified file. @kbd{M-x |
| 1643 | append-to-file} adds the text of the region to the end of the | 1643 | append-to-file} adds the text of the region to the end of the |
| 1644 | specified file. @xref{Accumulating Text}. The variable | 1644 | specified file. @xref{Accumulating Text}. When called interactively, |
| 1645 | @code{write-region-inhibit-fsync} applies to these commands, as well | 1645 | these commands will print a message in the echo area giving the name |
| 1646 | as saving files; see @ref{Customize Save}. | 1646 | of the file affected as well as the number of characters which were |
| 1647 | added. The variable @code{write-region-inhibit-fsync} applies to | ||
| 1648 | these commands, as well as saving files; see @ref{Customize Save}. | ||
| 1647 | 1649 | ||
| 1648 | @findex set-file-modes | 1650 | @findex set-file-modes |
| 1649 | @cindex file modes | 1651 | @cindex file modes |
| @@ -90,6 +90,11 @@ required capabilities are found in terminfo. See the FAQ node | |||
| 90 | 90 | ||
| 91 | * Changes in Emacs 26.1 | 91 | * Changes in Emacs 26.1 |
| 92 | 92 | ||
| 93 | +++ | ||
| 94 | ** The functions write-region, append-to-file, and the like now output | ||
| 95 | the number of characters added in addition to the name of the file | ||
| 96 | affected. | ||
| 97 | |||
| 93 | ** The variable 'emacs-version' no longer includes the build number. | 98 | ** The variable 'emacs-version' no longer includes the build number. |
| 94 | This is now stored separately in a new variable, 'emacs-build-number'. | 99 | This is now stored separately in a new variable, 'emacs-build-number'. |
| 95 | 100 | ||
diff --git a/lisp/epa-file.el b/lisp/epa-file.el index c97acb837aa..72ffb58c308 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el | |||
| @@ -290,7 +290,7 @@ If no one is selected, symmetric encryption will be performed. " | |||
| 290 | (if (or (eq visit t) | 290 | (if (or (eq visit t) |
| 291 | (eq visit nil) | 291 | (eq visit nil) |
| 292 | (stringp visit)) | 292 | (stringp visit)) |
| 293 | (message "Wrote %s" buffer-file-name)))) | 293 | (message "Wrote %d characters to `%s'" (- end start) buffer-file-name)))) |
| 294 | (put 'write-region 'epa-file 'epa-file-write-region) | 294 | (put 'write-region 'epa-file 'epa-file-write-region) |
| 295 | 295 | ||
| 296 | (defun epa-file-select-keys () | 296 | (defun epa-file-select-keys () |
diff --git a/lisp/gnus/mm-util.el b/lisp/gnus/mm-util.el index 89f397e3ed0..f0dc803eddc 100644 --- a/lisp/gnus/mm-util.el +++ b/lisp/gnus/mm-util.el | |||
| @@ -736,7 +736,7 @@ If INHIBIT is non-nil, inhibit `mm-inhibit-file-name-handlers'." | |||
| 736 | inhibit-file-name-handlers) | 736 | inhibit-file-name-handlers) |
| 737 | inhibit-file-name-handlers))) | 737 | inhibit-file-name-handlers))) |
| 738 | (write-region start end filename t 'no-message) | 738 | (write-region start end filename t 'no-message) |
| 739 | (message "Appended to %s" filename))) | 739 | (message "Appended %d characters to `%s'" (- end start) filename))) |
| 740 | 740 | ||
| 741 | (defun mm-write-region (start end filename &optional append visit lockname | 741 | (defun mm-write-region (start end filename &optional append visit lockname |
| 742 | coding-system inhibit) | 742 | coding-system inhibit) |
diff --git a/lisp/jka-compr.el b/lisp/jka-compr.el index 26a7cf506fd..55440a709c7 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 `/'." | |||
| 357 | (and (or (eq visit t) | 357 | (and (or (eq visit t) |
| 358 | (eq visit nil) | 358 | (eq visit nil) |
| 359 | (stringp visit)) | 359 | (stringp visit)) |
| 360 | (message "Wrote %s" visit-file)) | 360 | (message "Wrote %d characters to `%s'" (- end start) visit-file)) |
| 361 | 361 | ||
| 362 | ;; ensure `last-coding-system-used' has an appropriate value | 362 | ;; ensure `last-coding-system-used' has an appropriate value |
| 363 | (setq last-coding-system-used coding-system-used) | 363 | (setq last-coding-system-used coding-system-used) |
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el index cafdb3ecb06..aecb9e1ecbe 100644 --- a/lisp/net/ange-ftp.el +++ b/lisp/net/ange-ftp.el | |||
| @@ -3284,7 +3284,7 @@ system TYPE.") | |||
| 3284 | (set-buffer-modified-p nil))) | 3284 | (set-buffer-modified-p nil))) |
| 3285 | ;; ensure `last-coding-system-used' has an appropriate value | 3285 | ;; ensure `last-coding-system-used' has an appropriate value |
| 3286 | (setq last-coding-system-used coding-system-used) | 3286 | (setq last-coding-system-used coding-system-used) |
| 3287 | (ange-ftp-message "Wrote %s" abbr) | 3287 | (ange-ftp-message "Wrote %d characters to `%s'" (- end start) abbr) |
| 3288 | (ange-ftp-add-file-entry filename)) | 3288 | (ange-ftp-add-file-entry filename)) |
| 3289 | (ange-ftp-real-write-region start end filename append visit)))) | 3289 | (ange-ftp-real-write-region start end filename append visit)))) |
| 3290 | 3290 | ||
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index 59d8771cf1d..8ab34af85b7 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el | |||
| @@ -1223,7 +1223,7 @@ file-notify events." | |||
| 1223 | 1223 | ||
| 1224 | ;; The end. | 1224 | ;; The end. |
| 1225 | (when (or (eq visit t) (null visit) (stringp visit)) | 1225 | (when (or (eq visit t) (null visit) (stringp visit)) |
| 1226 | (tramp-message v 0 "Wrote %s" filename)) | 1226 | (tramp-message v 0 "Wrote %d characters to `%s'" (- end start) filename)) |
| 1227 | (run-hooks 'tramp-handle-write-region-hook))) | 1227 | (run-hooks 'tramp-handle-write-region-hook))) |
| 1228 | 1228 | ||
| 1229 | 1229 | ||
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 997716227bc..f78f54154fd 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -3411,7 +3411,8 @@ the result will be a local, non-Tramp, file name." | |||
| 3411 | (when need-chown | 3411 | (when need-chown |
| 3412 | (tramp-set-file-uid-gid filename uid gid)) | 3412 | (tramp-set-file-uid-gid filename uid gid)) |
| 3413 | (when (or (eq visit t) (null visit) (stringp visit)) | 3413 | (when (or (eq visit t) (null visit) (stringp visit)) |
| 3414 | (tramp-message v 0 "Wrote %s" filename)) | 3414 | (tramp-message v 0 "Wrote %d characters to `%s'" |
| 3415 | (- end start) filename)) | ||
| 3415 | (run-hooks 'tramp-handle-write-region-hook))))) | 3416 | (run-hooks 'tramp-handle-write-region-hook))))) |
| 3416 | 3417 | ||
| 3417 | (defvar tramp-vc-registered-file-names nil | 3418 | (defvar tramp-vc-registered-file-names nil |
diff --git a/src/fileio.c b/src/fileio.c index acbf76e0d81..0fc52294011 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -5150,13 +5150,16 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename, | |||
| 5150 | } | 5150 | } |
| 5151 | 5151 | ||
| 5152 | if (!auto_saving && !noninteractive) | 5152 | if (!auto_saving && !noninteractive) |
| 5153 | message_with_string ((NUMBERP (append) | 5153 | { |
| 5154 | ? "Updated %s" | 5154 | AUTO_STRING (format, NUMBERP (append) |
| 5155 | : ! NILP (append) | 5155 | ? "Updated %d characters of `%s'" |
| 5156 | ? "Added to %s" | 5156 | : ! NILP (append) |
| 5157 | : "Wrote %s"), | 5157 | ? "Added %d characters to `%s'" |
| 5158 | visit_file, 1); | 5158 | : "Wrote %d characters to `%s'"); |
| 5159 | 5159 | CALLN (Fmessage, format, | |
| 5160 | make_number (XINT (end) - XINT (start)), | ||
| 5161 | visit_file); | ||
| 5162 | } | ||
| 5160 | return Qnil; | 5163 | return Qnil; |
| 5161 | } | 5164 | } |
| 5162 | 5165 | ||