diff options
| author | Dmitry Gutov | 2013-10-14 00:35:31 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2013-10-14 00:35:31 +0300 |
| commit | a9ba094b81d899218e8762a66377b2fe71274d35 (patch) | |
| tree | 0ed1c3a278fb85ad25202cc66bdfb772f5e1b519 | |
| parent | 7a068717166757eacc702cb499dc803be0645211 (diff) | |
| download | emacs-a9ba094b81d899218e8762a66377b2fe71274d35.tar.gz emacs-a9ba094b81d899218e8762a66377b2fe71274d35.zip | |
* 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.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/progmodes/ruby-mode.el | 12 |
2 files changed, 13 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e3f32150ee6..d7eedf1dc65 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2013-10-13 Dmitry Gutov <dgutov@yandex.ru> | ||
| 2 | |||
| 3 | * progmodes/ruby-mode.el (ruby-mode): Add `ruby-mode-set-encoding' | ||
| 4 | to `after-save-hook' instead of `before-save-hook'. | ||
| 5 | (ruby-mode-set-encoding): Use the value of coding system used to | ||
| 6 | write the file. Call `basic-save-buffer-1' after modifying the | ||
| 7 | buffer. | ||
| 8 | |||
| 1 | 2013-10-13 Alan Mackenzie <acm@muc.de> | 9 | 2013-10-13 Alan Mackenzie <acm@muc.de> |
| 2 | 10 | ||
| 3 | Fix indentation/fontification of Java enum with | 11 | Fix indentation/fontification of Java enum with |
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index dfc93a21b40..a06121ed639 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el | |||
| @@ -529,7 +529,7 @@ Also ignores spaces after parenthesis when 'space." | |||
| 529 | (when (re-search-forward "[^\0-\177]" nil t) | 529 | (when (re-search-forward "[^\0-\177]" nil t) |
| 530 | (goto-char (point-min)) | 530 | (goto-char (point-min)) |
| 531 | (let ((coding-system | 531 | (let ((coding-system |
| 532 | (or coding-system-for-write | 532 | (or save-buffer-coding-system |
| 533 | buffer-file-coding-system))) | 533 | buffer-file-coding-system))) |
| 534 | (if coding-system | 534 | (if coding-system |
| 535 | (setq coding-system | 535 | (setq coding-system |
| @@ -555,7 +555,9 @@ Also ignores spaces after parenthesis when 'space." | |||
| 555 | (insert coding-system))) | 555 | (insert coding-system))) |
| 556 | ((looking-at "\\s *#.*coding\\s *[:=]")) | 556 | ((looking-at "\\s *#.*coding\\s *[:=]")) |
| 557 | (t (when ruby-insert-encoding-magic-comment | 557 | (t (when ruby-insert-encoding-magic-comment |
| 558 | (insert "# -*- coding: " coding-system " -*-\n")))))))) | 558 | (insert "# -*- coding: " coding-system " -*-\n")))) |
| 559 | (when (buffer-modified-p) | ||
| 560 | (basic-save-buffer-1)))))) | ||
| 559 | 561 | ||
| 560 | (defun ruby-current-indentation () | 562 | (defun ruby-current-indentation () |
| 561 | "Return the indentation level of current line." | 563 | "Return the indentation level of current line." |
| @@ -2017,11 +2019,7 @@ The variable `ruby-indent-level' controls the amount of indentation. | |||
| 2017 | (set (make-local-variable 'end-of-defun-function) | 2019 | (set (make-local-variable 'end-of-defun-function) |
| 2018 | 'ruby-end-of-defun) | 2020 | 'ruby-end-of-defun) |
| 2019 | 2021 | ||
| 2020 | (add-hook | 2022 | (add-hook 'after-save-hook 'ruby-mode-set-encoding nil 'local) |
| 2021 | (cond ((boundp 'before-save-hook) 'before-save-hook) | ||
| 2022 | ((boundp 'write-contents-functions) 'write-contents-functions) | ||
| 2023 | ((boundp 'write-contents-hooks) 'write-contents-hooks)) | ||
| 2024 | 'ruby-mode-set-encoding nil 'local) | ||
| 2025 | 2023 | ||
| 2026 | (set (make-local-variable 'electric-indent-chars) | 2024 | (set (make-local-variable 'electric-indent-chars) |
| 2027 | (append '(?\{ ?\}) electric-indent-chars)) | 2025 | (append '(?\{ ?\}) electric-indent-chars)) |