emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r114651: * lisp/progmodes/ruby-mode.el (ruby-mode):


From: Dmitry Gutov
Subject: [Emacs-diffs] trunk r114651: * lisp/progmodes/ruby-mode.el (ruby-mode): Add `ruby-mode-set-encoding'
Date: Sun, 13 Oct 2013 21:35:36 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 114651
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Gutov <address@hidden>
branch nick: trunk
timestamp: Mon 2013-10-14 00:35:31 +0300
message:
  * lisp/progmodes/ruby-mode.el (ruby-mode): Add `ruby-mode-set-encoding'
  to `after-save-hook' instead of `before-save-hook'.
  (ruby-mode-set-encoding): Use the value of coding system used to
  write the file.  Call `basic-save-buffer-1' after modifying the
  buffer.
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-13 19:54:46 +0000
+++ b/lisp/ChangeLog    2013-10-13 21:35:31 +0000
@@ -1,3 +1,11 @@
+2013-10-13  Dmitry Gutov  <address@hidden>
+
+       * progmodes/ruby-mode.el (ruby-mode): Add `ruby-mode-set-encoding'
+       to `after-save-hook' instead of `before-save-hook'.
+       (ruby-mode-set-encoding): Use the value of coding system used to
+       write the file.  Call `basic-save-buffer-1' after modifying the
+       buffer.
+
 2013-10-13  Alan Mackenzie  <address@hidden>
 
        Fix indentation/fontification of Java enum with

=== modified file 'lisp/progmodes/ruby-mode.el'
--- a/lisp/progmodes/ruby-mode.el       2013-10-12 20:40:50 +0000
+++ b/lisp/progmodes/ruby-mode.el       2013-10-13 21:35:31 +0000
@@ -529,7 +529,7 @@
     (when (re-search-forward "[^\0-\177]" nil t)
       (goto-char (point-min))
       (let ((coding-system
-             (or coding-system-for-write
+             (or save-buffer-coding-system
                  buffer-file-coding-system)))
         (if coding-system
             (setq coding-system
@@ -555,7 +555,9 @@
                  (insert coding-system)))
               ((looking-at "\\s *#.*coding\\s *[:=]"))
               (t (when ruby-insert-encoding-magic-comment
-                   (insert "# -*- coding: " coding-system " -*-\n"))))))))
+                   (insert "# -*- coding: " coding-system " -*-\n"))))
+        (when (buffer-modified-p)
+          (basic-save-buffer-1))))))
 
 (defun ruby-current-indentation ()
   "Return the indentation level of current line."
@@ -2017,11 +2019,7 @@
   (set (make-local-variable 'end-of-defun-function)
        'ruby-end-of-defun)
 
-  (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)
+  (add-hook 'after-save-hook '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]