From 449822c76c20983317d3cb59b9ee54554998392d Mon Sep 17 00:00:00 2001 From: knu Date: Mon, 7 Oct 2013 19:03:03 +0000 Subject: [PATCH] * misc/ruby-additional.el (ruby-mode-set-encoding): Use `default-buffer-file-coding-system` if the :prefer-utf-8 property is not available. * misc/ruby-mode.el (ruby-mode-set-encoding): Ditto. * misc/ruby-additional.el (ruby-encoding-map): Override the default value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 +++++++++++ misc/ruby-additional.el | 13 ++++++++++--- misc/ruby-mode.el | 6 ++++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3240ba2c56..3dedf50cd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Tue Oct 8 03:57:34 2013 Akinori MUSHA + + * misc/ruby-additional.el (ruby-mode-set-encoding): Use + `default-buffer-file-coding-system` if the :prefer-utf-8 + property is not available. + + * misc/ruby-mode.el (ruby-mode-set-encoding): Ditto. + + * misc/ruby-additional.el (ruby-encoding-map): Override the + default value. + Tue Oct 8 03:19:19 2013 Akinori MUSHA * misc/ruby-additional.el (ruby-mode-set-encoding): Add support diff --git a/misc/ruby-additional.el b/misc/ruby-additional.el index e7abcbce21..1a80e34196 100644 --- a/misc/ruby-additional.el +++ b/misc/ruby-additional.el @@ -73,12 +73,17 @@ (or (ruby-brace-to-do-end) (ruby-do-end-to-brace))) - (defcustom ruby-encoding-map + (defconst ruby-default-encoding-map '((us-ascii . nil) ;; Do not put coding: us-ascii (utf-8 . nil) ;; Do not put coding: utf-8 (shift-jis . cp932) ;; Emacs charset name of Shift_JIS (shift_jis . cp932) ;; MIME charset name of Shift_JIS (japanese-cp932 . cp932)) ;; Emacs charset name of CP932 + ) + + (custom-set-default 'ruby-encoding-map ruby-default-encoding-map) + + (defcustom ruby-encoding-map ruby-default-encoding-map "Alist to map encoding name from Emacs to Ruby. Associating an encoding name with nil means it needs not be explicitly declared in magic comment." @@ -107,8 +112,10 @@ Emacs to Ruby." (let ((coding-type (coding-system-get coding-system :coding-type))) (cond ((eq coding-type 'undecided) (if nonascii - (if (coding-system-get coding-system :prefer-utf-8) - 'utf-8 'ascii-8bit))) + (or (and (coding-system-get coding-system :prefer-utf-8) + 'utf-8) + (coding-system-get default-buffer-file-coding-system :coding-type) + 'ascii-8bit))) ((memq coding-type '(utf-8 shift-jis)) coding-type)))))) (coding-system diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el index 344dcfafe8..4de0290706 100644 --- a/misc/ruby-mode.el +++ b/misc/ruby-mode.el @@ -355,8 +355,10 @@ Emacs to Ruby." (let ((coding-type (coding-system-get coding-system :coding-type))) (cond ((eq coding-type 'undecided) (if nonascii - (if (coding-system-get coding-system :prefer-utf-8) - 'utf-8 'ascii-8bit))) + (or (and (coding-system-get coding-system :prefer-utf-8) + 'utf-8) + (coding-system-get default-buffer-file-coding-system :coding-type) + 'ascii-8bit))) ((memq coding-type '(utf-8 shift-jis)) coding-type)))))) (coding-system