emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r114533: Revert 114527


From: Dmitry Gutov
Subject: [Emacs-diffs] trunk r114533: Revert 114527
Date: Sat, 05 Oct 2013 17:23:01 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 114533
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Gutov <address@hidden>
branch nick: trunk
timestamp: Sat 2013-10-05 20:21:22 +0300
message:
  Revert 114527
  
  `last-coding-system-used' is unreliable: it can be modified by other functions
  in `after-save-hook'.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/progmodes/ruby-mode.el    
rubymode.el-20091113204419-o5vbwnq5f7feedwu-8804
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-10-05 02:45:24 +0000
+++ b/lisp/ChangeLog    2013-10-05 17:21:22 +0000
@@ -3,14 +3,6 @@
        * progmodes/octave.el (octave-send-region): Call
        compilation-forget-errors.
 
-2013-10-05  Dmitry Gutov  <address@hidden>
-
-       * progmodes/ruby-mode.el (ruby-mode): Add `ruby-mode-set-encoding'
-       to `after-save-hook' instead of `before-save-hook', because then
-       we know exactly what encoding was used to write the file.
-       (ruby-mode-set-encoding): Use `last-coding-system-used' instead of
-       guessing.  Call `basic-save-buffer-1' after modifying the buffer.
-
 2013-10-04  Xue Fuqiao  <address@hidden>
 
        * vc/vc-svn.el (vc-svn-find-admin-dir):

=== modified file 'lisp/progmodes/ruby-mode.el'
--- a/lisp/progmodes/ruby-mode.el       2013-10-05 02:26:39 +0000
+++ b/lisp/progmodes/ruby-mode.el       2013-10-05 17:21:22 +0000
@@ -450,13 +450,19 @@
     (when (re-search-forward "[^\0-\177]" nil t)
       (goto-char (point-min))
       (let ((coding-system
-             (or (coding-system-get last-coding-system-used 'mime-charset)
-                 (coding-system-change-eol-conversion ast-coding-system-used
-                                                      nil))))
+             (or coding-system-for-write
+                 buffer-file-coding-system)))
+        (if coding-system
+            (setq coding-system
+                  (or (coding-system-get coding-system 'mime-charset)
+                      (coding-system-change-eol-conversion coding-system 
nil))))
         (setq coding-system
-              (symbol-name (or (and ruby-use-encoding-map
-                                    (cdr (assq coding-system 
ruby-encoding-map)))
-                               coding-system)))
+              (if coding-system
+                  (symbol-name
+                   (or (and ruby-use-encoding-map
+                            (cdr (assq coding-system ruby-encoding-map)))
+                       coding-system))
+                "ascii-8bit"))
         (if (looking-at "^#!") (beginning-of-line 2))
         (cond ((looking-at "\\s *#.*-\*-\\s *\\(en\\)?coding\\s *:\\s 
*\\([-a-z0-9_]*\\)\\s *\\(;\\|-\*-\\)")
                (unless (string= (match-string 2) coding-system)
@@ -470,9 +476,7 @@
                  (insert coding-system)))
               ((looking-at "\\s *#.*coding\\s *[:=]"))
               (t (when ruby-insert-encoding-magic-comment
-                   (insert "# -*- coding: " coding-system " -*-\n"))))
-        (when (buffer-modified-p)
-          (basic-save-buffer-1))))))
+                   (insert "# -*- coding: " coding-system " -*-\n"))))))))
 
 (defun ruby-current-indentation ()
   "Return the indentation level of current line."
@@ -1930,7 +1934,11 @@
   (set (make-local-variable 'end-of-defun-function)
        'ruby-end-of-defun)
 
-  (add-hook 'after-save-hook 'ruby-mode-set-encoding nil 'local)
+  (add-hook
+   (cond ((boundp 'before-save-hook) 'before-save-hook)
+         ((boundp 'write-contents-functions) 'write-contents-functions)
+         ((boundp 'write-contents-hooks) 'write-contents-hooks))
+   'ruby-mode-set-encoding nil 'local)
 
   (set (make-local-variable 'electric-indent-chars)
        (append '(?\{ ?\}) electric-indent-chars))


reply via email to

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