emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master daaec72: Revert "Output number of characters added


From: Noam Postavsky
Subject: [Emacs-diffs] master daaec72: Revert "Output number of characters added to file (Bug#354)"
Date: Tue, 9 May 2017 00:35:51 -0400 (EDT)

branch: master
commit daaec72a82e76f916e639acb51a8ad602433e8a9
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    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.
---
 doc/emacs/files.texi         |  9 +++-----
 etc/NEWS                     |  5 ----
 lisp/epa-file.el             |  5 +---
 lisp/gnus/mm-util.el         |  2 +-
 lisp/jka-compr.el            |  5 +---
 lisp/net/ange-ftp.el         |  5 +---
 lisp/net/tramp-adb.el        |  2 --
 lisp/net/tramp-gvfs.el       |  3 ++-
 lisp/net/tramp-sh.el         |  3 ++-
 lisp/net/tramp-smb.el        |  3 +--
 lisp/net/tramp.el            | 21 -----------------
 src/fileio.c                 | 35 ++++++----------------------
 test/lisp/net/tramp-tests.el | 54 ++------------------------------------------
 13 files changed, 21 insertions(+), 131 deletions(-)

diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index d36fe65..5e6afa5 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -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
address@hidden 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 1f1f4b4..4c0f4d2 100644
--- a/etc/NEWS
+++ b/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'.
 
diff --git a/lisp/epa-file.el b/lisp/epa-file.el
index 64e00e0..c97acb8 100644
--- a/lisp/epa-file.el
+++ b/lisp/epa-file.el
@@ -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 ()
diff --git a/lisp/gnus/mm-util.el b/lisp/gnus/mm-util.el
index f4e79e5..89f397e 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'."
                     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)
diff --git a/lisp/jka-compr.el b/lisp/jka-compr.el
index e4f7348..26a7cf5 100644
--- a/lisp/jka-compr.el
+++ b/lisp/jka-compr.el
@@ -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)
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el
index 7b8b3fc..ecb60e5 100644
--- a/lisp/net/ange-ftp.el
+++ b/lisp/net/ange-ftp.el
@@ -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))))
 
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 8bbdca7..2825532 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -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
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 55fddf3..cf3906a 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -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)))
 
 
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index adadf96..e61b0ce 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -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
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index 4b288e1..12eb367 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -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.
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 4a1900c..071114a 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -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.
diff --git a/src/fileio.c b/src/fileio.c
index 6138bfc..acbf76e 100644
--- a/src/fileio.c
+++ b/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)")
-                   : ! 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));
-    }
+    message_with_string ((NUMBERP (append)
+                         ? "Updated %s"
+                         : ! NILP (append)
+                         ? "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'.  */);
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 742bdfd..8db5497 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -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"))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]