Revert "Output number of characters added to file (Bug#354)"
The extra message text turned out to be quite annoying in practice, and is generally more trouble than it's worth. Also revert several related changes. Partially revert "Handle `write-region' messages in Tramp properly" Revert "New var write-region-verbose, default nil" Revert "* src/fileio.c (write_region): Don't say "1 characters". (Bug#26796)" Revert "Minor tuneup of write-region change" Revert "Adjust write-region so file name is at the beginning again" Revert "Fix handling of non-integer START param to write-region" Revert "Output number of characters added to file (Bug#354)" * doc/emacs/files.texi (Misc File Ops): * etc/NEWS: * lisp/epa-file.el (epa-file-write-region): * lisp/gnus/mm-util.el (mm-append-to-file): * lisp/jka-compr.el (jka-compr-write-region): * lisp/net/ange-ftp.el (ange-ftp-write-region): * lisp/net/tramp-adb.el (tramp-adb-handle-write-region): * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-write-region): * lisp/net/tramp-sh.el (tramp-sh-handle-write-region): * lisp/net/tramp-smb.el (tramp-smb-handle-write-region): * lisp/net/tramp.el (tramp-handle-write-region-message): * src/fileio.c (write_region, syms_of_fileio): * test/lisp/net/tramp-tests.el (tramp-test10-write-region): Remove extra characters from file writing messages.
This commit is contained in:
parent
5e2cf8c804
commit
daaec72a82
13 changed files with 21 additions and 131 deletions
|
|
@ -1656,12 +1656,9 @@ 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}. When called interactively,
|
||||
these commands print a message in the echo area giving the name
|
||||
of the file affected; if the variable @code{write-region-verbose} is
|
||||
non-nil the message also reports the number of characters written.
|
||||
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}. 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
|
||||
|
|
|
|||
5
etc/NEWS
5
etc/NEWS
|
|
@ -93,11 +93,6 @@ 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 also
|
||||
output the number of characters added in addition to the name of the
|
||||
file affected, if the new variable 'write-region-verbose' is non-nil.
|
||||
|
||||
** The variable 'emacs-version' no longer includes the build number.
|
||||
This is now stored separately in a new variable, 'emacs-build-number'.
|
||||
|
||||
|
|
|
|||
|
|
@ -290,10 +290,7 @@ If no one is selected, symmetric encryption will be performed. "
|
|||
(if (or (eq visit t)
|
||||
(eq visit nil)
|
||||
(stringp visit))
|
||||
(message "Wrote `%s' (%d characters)" buffer-file-name
|
||||
(cond ((null start) (buffer-size))
|
||||
((stringp start) (length start))
|
||||
(t (- end start)))))))
|
||||
(message "Wrote %s" buffer-file-name))))
|
||||
(put 'write-region 'epa-file 'epa-file-write-region)
|
||||
|
||||
(defun epa-file-select-keys ()
|
||||
|
|
|
|||
|
|
@ -736,7 +736,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' (%d characters)" filename (- end start))))
|
||||
(message "Appended to %s" filename)))
|
||||
|
||||
(defun mm-write-region (start end filename &optional append visit lockname
|
||||
coding-system inhibit)
|
||||
|
|
|
|||
|
|
@ -357,10 +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' (%d characters)" visit-file
|
||||
(cond ((null start) (buffer-size))
|
||||
((stringp start) (length start))
|
||||
(t (- end start)))))
|
||||
(message "Wrote %s" visit-file))
|
||||
|
||||
;; ensure `last-coding-system-used' has an appropriate value
|
||||
(setq last-coding-system-used coding-system-used)
|
||||
|
|
|
|||
|
|
@ -3284,10 +3284,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' (%d characters)" abbr
|
||||
(cond ((null start) (buffer-size))
|
||||
((stringp start) (length start))
|
||||
(t (- end start))))
|
||||
(ange-ftp-message "Wrote %s" abbr)
|
||||
(ange-ftp-add-file-entry filename))
|
||||
(ange-ftp-real-write-region start end filename append visit))))
|
||||
|
||||
|
|
|
|||
|
|
@ -652,8 +652,6 @@ But handle the case, if the \"test\" command is not available."
|
|||
(when (or (eq visit t) (stringp visit))
|
||||
(set-visited-file-modtime))
|
||||
|
||||
(tramp-handle-write-region-message v start end filename append visit)
|
||||
|
||||
(unless (equal curbuf (current-buffer))
|
||||
(tramp-error
|
||||
v 'file-error
|
||||
|
|
|
|||
|
|
@ -1224,7 +1224,8 @@ file-notify events."
|
|||
(file-attributes filename))))
|
||||
|
||||
;; The end.
|
||||
(tramp-handle-write-region-message v start end filename append visit)
|
||||
(when (or (eq visit t) (null visit) (stringp visit))
|
||||
(tramp-message v 0 "Wrote %s" filename))
|
||||
(run-hooks 'tramp-handle-write-region-hook)))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3412,7 +3412,8 @@ the result will be a local, non-Tramp, file name."
|
|||
;; Set the ownership.
|
||||
(when need-chown
|
||||
(tramp-set-file-uid-gid filename uid gid))
|
||||
(tramp-handle-write-region-message v start end filename append visit)
|
||||
(when (or (eq visit t) (null visit) (stringp visit))
|
||||
(tramp-message v 0 "Wrote %s" filename))
|
||||
(run-hooks 'tramp-handle-write-region-hook)))))
|
||||
|
||||
(defvar tramp-vc-registered-file-names nil
|
||||
|
|
|
|||
|
|
@ -1521,8 +1521,7 @@ errors for shares like \"C$/\", which are common in Microsoft Windows."
|
|||
v 'file-error
|
||||
"Buffer has changed from `%s' to `%s'" curbuf (current-buffer)))
|
||||
(when (eq visit t)
|
||||
(set-visited-file-modtime))
|
||||
(tramp-handle-write-region-message v start end filename append visit))))
|
||||
(set-visited-file-modtime)))))
|
||||
|
||||
|
||||
;; Internal file name functions.
|
||||
|
|
|
|||
|
|
@ -2753,27 +2753,6 @@ User is always nil."
|
|||
(defvar tramp-handle-write-region-hook nil
|
||||
"Normal hook to be run at the end of `tramp-*-handle-write-region'.")
|
||||
|
||||
(defsubst tramp-handle-write-region-message
|
||||
(vec start end filename &optional append visit)
|
||||
"Message to be written for `tramp-*-handle-write-region'"
|
||||
;; We shall also don't write when autosaving. How to check?
|
||||
(when (and (null noninteractive)
|
||||
(or (eq visit t) (null visit) (stringp visit)))
|
||||
(let ((nchars (cond ((null start) (buffer-size))
|
||||
((stringp start) (length start))
|
||||
(t (- end start)))))
|
||||
(tramp-message
|
||||
vec 0 "%s `%s'%s"
|
||||
(cond
|
||||
((numberp append) "Updated")
|
||||
(append "Added to")
|
||||
(t "Wrote"))
|
||||
filename
|
||||
(cond
|
||||
((null (bound-and-true-p write-region-verbose)) "")
|
||||
((= nchars 1) " (1 character)")
|
||||
(t (format " (%d characters)" nchars)))))))
|
||||
|
||||
(defun tramp-handle-directory-file-name (directory)
|
||||
"Like `directory-file-name' for Tramp files."
|
||||
;; If localname component of filename is "/", leave it unchanged.
|
||||
|
|
|
|||
33
src/fileio.c
33
src/fileio.c
|
|
@ -5150,29 +5150,13 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
|
|||
}
|
||||
|
||||
if (!auto_saving && !noninteractive)
|
||||
{
|
||||
EMACS_INT nchars = (STRINGP (start) ? SCHARS (start)
|
||||
: XINT (end) - XINT (start));
|
||||
AUTO_STRING (format,
|
||||
(NUMBERP (append)
|
||||
? (NILP (Vwrite_region_verbose)
|
||||
? "Updated `%s'"
|
||||
: nchars == 1
|
||||
? "Updated `%s' (1 character)"
|
||||
: "Updated `%s' (%d characters)")
|
||||
message_with_string ((NUMBERP (append)
|
||||
? "Updated %s"
|
||||
: ! NILP (append)
|
||||
? (NILP (Vwrite_region_verbose)
|
||||
? "Added to `%s'"
|
||||
: nchars == 1
|
||||
? "Added to `%s' (1 character)"
|
||||
: "Added to `%s' (%d characters)")
|
||||
: (NILP (Vwrite_region_verbose)
|
||||
? "Wrote `%s'"
|
||||
: nchars == 1
|
||||
? "Wrote `%s' (1 character)"
|
||||
: "Wrote `%s' (%d characters)")));
|
||||
CALLN (Fmessage, format, visit_file, make_number (nchars));
|
||||
}
|
||||
? "Added to %s"
|
||||
: "Wrote %s"),
|
||||
visit_file, 1);
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
|
|
@ -6142,11 +6126,6 @@ These are the annotations made by other annotation functions
|
|||
that were already called. See also `write-region-annotate-functions'. */);
|
||||
Vwrite_region_annotations_so_far = Qnil;
|
||||
|
||||
DEFVAR_LISP ("write-region-verbose",
|
||||
Vwrite_region_verbose,
|
||||
doc: /* If non-nil, be more verbose when writing a region. */);
|
||||
Vwrite_region_verbose = Qnil;
|
||||
|
||||
DEFVAR_LISP ("inhibit-file-name-handlers", Vinhibit_file_name_handlers,
|
||||
doc: /* A list of file name handlers that temporarily should not be used.
|
||||
This applies only to the operation `inhibit-file-name-operation'. */);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@
|
|||
|
||||
(require 'dired)
|
||||
(require 'ert)
|
||||
(require 'ert-x)
|
||||
(require 'tramp)
|
||||
(require 'vc)
|
||||
(require 'vc-bzr)
|
||||
|
|
@ -81,9 +80,6 @@
|
|||
(when (getenv "NIX_STORE")
|
||||
(add-to-list 'tramp-remote-path 'tramp-own-remote-path))
|
||||
|
||||
(defvar tramp--test-messages nil
|
||||
"Captured messages from *Messages* buffer.")
|
||||
|
||||
(defvar tramp--test-expensive-test
|
||||
(null
|
||||
(string-equal (getenv "SELECTOR") "(quote (not (tag :expensive-test)))"))
|
||||
|
|
@ -1745,77 +1741,31 @@ This checks also `file-name-as-directory', `file-name-directory',
|
|||
(skip-unless (tramp--test-enabled))
|
||||
|
||||
(dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil)))
|
||||
(let* ((tmp-name (tramp--test-make-temp-name nil quoted))
|
||||
(text-quoting-style 'grave)
|
||||
(write-region-verbose
|
||||
(and (null noninteractive) (boundp 'write-region-verbose)))
|
||||
(tramp-message-show-message
|
||||
(or tramp-message-show-message write-region-verbose)))
|
||||
(let ((tmp-name (tramp--test-make-temp-name nil quoted)))
|
||||
(unwind-protect
|
||||
(ert-with-message-capture tramp--test-messages
|
||||
;; Write buffer.
|
||||
(setq tramp--test-messages "")
|
||||
(progn
|
||||
(with-temp-buffer
|
||||
(insert "foo")
|
||||
(write-region nil nil tmp-name))
|
||||
(when write-region-verbose
|
||||
(should
|
||||
(string-match
|
||||
(format "Wrote `%s' (3 characters)" tmp-name)
|
||||
tramp--test-messages)))
|
||||
(with-temp-buffer
|
||||
(insert-file-contents tmp-name)
|
||||
(should (string-equal (buffer-string) "foo")))
|
||||
|
||||
;; Append.
|
||||
(setq tramp--test-messages "")
|
||||
(with-temp-buffer
|
||||
(insert "bla")
|
||||
(write-region nil nil tmp-name 'append))
|
||||
(when write-region-verbose
|
||||
(should
|
||||
(string-match
|
||||
(format "Added to `%s' (3 characters)" tmp-name)
|
||||
tramp--test-messages)))
|
||||
(with-temp-buffer
|
||||
(insert-file-contents tmp-name)
|
||||
(should (string-equal (buffer-string) "foobla")))
|
||||
|
||||
(setq tramp--test-messages "")
|
||||
(with-temp-buffer
|
||||
(insert "baz")
|
||||
(write-region nil nil tmp-name 3))
|
||||
(when write-region-verbose
|
||||
(should
|
||||
(string-match
|
||||
(format "Updated `%s' (3 characters)" tmp-name)
|
||||
tramp--test-messages)))
|
||||
(with-temp-buffer
|
||||
(insert-file-contents tmp-name)
|
||||
(should (string-equal (buffer-string) "foobaz")))
|
||||
|
||||
;; Write string.
|
||||
(setq tramp--test-messages "")
|
||||
(write-region "foo" nil tmp-name)
|
||||
(when write-region-verbose
|
||||
(should
|
||||
(string-match
|
||||
(format "Wrote `%s' (3 characters)" tmp-name)
|
||||
tramp--test-messages)))
|
||||
(with-temp-buffer
|
||||
(insert-file-contents tmp-name)
|
||||
(should (string-equal (buffer-string) "foo")))
|
||||
|
||||
;; Write partly.
|
||||
(setq tramp--test-messages "")
|
||||
(with-temp-buffer
|
||||
(insert "123456789")
|
||||
(write-region 3 5 tmp-name))
|
||||
(when write-region-verbose
|
||||
(should
|
||||
(string-match
|
||||
(format "Wrote `%s' (2 characters)" tmp-name)
|
||||
tramp--test-messages)))
|
||||
(with-temp-buffer
|
||||
(insert-file-contents tmp-name)
|
||||
(should (string-equal (buffer-string) "34"))))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue