summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-07 19:03:03 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-07 19:03:03 +0000
commit449822c76c20983317d3cb59b9ee54554998392d (patch)
treee02fac94230781ceb85c6c90b43dc80f03b9fef6 /misc
parent1ecf20cda2b86bf3a5b72f176b7957ead5338e3c (diff)
* 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
Diffstat (limited to 'misc')
-rw-r--r--misc/ruby-additional.el13
-rw-r--r--misc/ruby-mode.el6
2 files changed, 14 insertions, 5 deletions
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