aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/progmodes/ruby-mode.el28
2 files changed, 18 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0b617f8ed0f..e3ca8751535 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -3,14 +3,6 @@
3 * progmodes/octave.el (octave-send-region): Call 3 * progmodes/octave.el (octave-send-region): Call
4 compilation-forget-errors. 4 compilation-forget-errors.
5 5
62013-10-05 Dmitry Gutov <dgutov@yandex.ru>
7
8 * progmodes/ruby-mode.el (ruby-mode): Add `ruby-mode-set-encoding'
9 to `after-save-hook' instead of `before-save-hook', because then
10 we know exactly what encoding was used to write the file.
11 (ruby-mode-set-encoding): Use `last-coding-system-used' instead of
12 guessing. Call `basic-save-buffer-1' after modifying the buffer.
13
142013-10-04 Xue Fuqiao <xfq.free@gmail.com> 62013-10-04 Xue Fuqiao <xfq.free@gmail.com>
15 7
16 * vc/vc-svn.el (vc-svn-find-admin-dir): 8 * vc/vc-svn.el (vc-svn-find-admin-dir):
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 8abf8fedefb..95206c15390 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -450,13 +450,19 @@ Also ignores spaces after parenthesis when 'space."
450 (when (re-search-forward "[^\0-\177]" nil t) 450 (when (re-search-forward "[^\0-\177]" nil t)
451 (goto-char (point-min)) 451 (goto-char (point-min))
452 (let ((coding-system 452 (let ((coding-system
453 (or (coding-system-get last-coding-system-used 'mime-charset) 453 (or coding-system-for-write
454 (coding-system-change-eol-conversion ast-coding-system-used 454 buffer-file-coding-system)))
455 nil)))) 455 (if coding-system
456 (setq coding-system
457 (or (coding-system-get coding-system 'mime-charset)
458 (coding-system-change-eol-conversion coding-system nil))))
456 (setq coding-system 459 (setq coding-system
457 (symbol-name (or (and ruby-use-encoding-map 460 (if coding-system
458 (cdr (assq coding-system ruby-encoding-map))) 461 (symbol-name
459 coding-system))) 462 (or (and ruby-use-encoding-map
463 (cdr (assq coding-system ruby-encoding-map)))
464 coding-system))
465 "ascii-8bit"))
460 (if (looking-at "^#!") (beginning-of-line 2)) 466 (if (looking-at "^#!") (beginning-of-line 2))
461 (cond ((looking-at "\\s *#.*-\*-\\s *\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)\\s *\\(;\\|-\*-\\)") 467 (cond ((looking-at "\\s *#.*-\*-\\s *\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)\\s *\\(;\\|-\*-\\)")
462 (unless (string= (match-string 2) coding-system) 468 (unless (string= (match-string 2) coding-system)
@@ -470,9 +476,7 @@ Also ignores spaces after parenthesis when 'space."
470 (insert coding-system))) 476 (insert coding-system)))
471 ((looking-at "\\s *#.*coding\\s *[:=]")) 477 ((looking-at "\\s *#.*coding\\s *[:=]"))
472 (t (when ruby-insert-encoding-magic-comment 478 (t (when ruby-insert-encoding-magic-comment
473 (insert "# -*- coding: " coding-system " -*-\n")))) 479 (insert "# -*- coding: " coding-system " -*-\n"))))))))
474 (when (buffer-modified-p)
475 (basic-save-buffer-1))))))
476 480
477(defun ruby-current-indentation () 481(defun ruby-current-indentation ()
478 "Return the indentation level of current line." 482 "Return the indentation level of current line."
@@ -1930,7 +1934,11 @@ The variable `ruby-indent-level' controls the amount of indentation.
1930 (set (make-local-variable 'end-of-defun-function) 1934 (set (make-local-variable 'end-of-defun-function)
1931 'ruby-end-of-defun) 1935 'ruby-end-of-defun)
1932 1936
1933 (add-hook 'after-save-hook 'ruby-mode-set-encoding nil 'local) 1937 (add-hook
1938 (cond ((boundp 'before-save-hook) 'before-save-hook)
1939 ((boundp 'write-contents-functions) 'write-contents-functions)
1940 ((boundp 'write-contents-hooks) 'write-contents-hooks))
1941 'ruby-mode-set-encoding nil 'local)
1934 1942
1935 (set (make-local-variable 'electric-indent-chars) 1943 (set (make-local-variable 'electric-indent-chars)
1936 (append '(?\{ ?\}) electric-indent-chars)) 1944 (append '(?\{ ?\}) electric-indent-chars))