* lisp/progmodes/ruby-mode.el (ruby-mode-set-encoding): Use
`ruby-encoding-magic-comment-style' to control the style of the auto-inserted encoding comment.
This commit is contained in:
parent
da3b328da0
commit
71731c0338
2 changed files with 28 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2013-11-08 Bozhidar Batsov <bozhidar@batsov.com>
|
||||||
|
|
||||||
|
* progmodes/ruby-mode.el (ruby-mode-set-encoding): Use
|
||||||
|
`ruby-encoding-magic-comment-style' to control the
|
||||||
|
style of the auto-inserted encoding comment.
|
||||||
|
|
||||||
2013-11-08 Dmitry Gutov <dgutov@yandex.ru>
|
2013-11-08 Dmitry Gutov <dgutov@yandex.ru>
|
||||||
|
|
||||||
* progmodes/ruby-mode.el (ruby-smie--indent-to-stmt): Use
|
* progmodes/ruby-mode.el (ruby-smie--indent-to-stmt): Use
|
||||||
|
|
|
@ -261,6 +261,20 @@ explicitly declared in magic comment."
|
||||||
"Insert a magic Emacs 'coding' comment upon save if this is non-nil."
|
"Insert a magic Emacs 'coding' comment upon save if this is non-nil."
|
||||||
:type 'boolean :group 'ruby)
|
:type 'boolean :group 'ruby)
|
||||||
|
|
||||||
|
(defcustom ruby-encoding-magic-comment-style 'ruby
|
||||||
|
"The style of the magic encoding comment to use."
|
||||||
|
:type '(choice
|
||||||
|
(const :tag "Emacs Style" emacs)
|
||||||
|
(const :tag "Ruby Style" ruby)
|
||||||
|
(const :tag "Custom Style" custom))
|
||||||
|
:group 'ruby)
|
||||||
|
|
||||||
|
(defcustom ruby-custom-encoding-magic-comment-template "# coding: %s"
|
||||||
|
"The encoding comment template to be used when
|
||||||
|
`ruby-encoding-magic-comment-style' is set to `custom'."
|
||||||
|
:type 'string
|
||||||
|
:group 'ruby)
|
||||||
|
|
||||||
(defcustom ruby-use-encoding-map t
|
(defcustom ruby-use-encoding-map t
|
||||||
"Use `ruby-encoding-map' to set encoding magic comment if this is non-nil."
|
"Use `ruby-encoding-map' to set encoding magic comment if this is non-nil."
|
||||||
:type 'boolean :group 'ruby)
|
:type 'boolean :group 'ruby)
|
||||||
|
@ -639,7 +653,14 @@ explicitly declared in magic comment."
|
||||||
(insert coding-system)))
|
(insert coding-system)))
|
||||||
((looking-at "\\s *#.*coding\\s *[:=]"))
|
((looking-at "\\s *#.*coding\\s *[:=]"))
|
||||||
(t (when ruby-insert-encoding-magic-comment
|
(t (when ruby-insert-encoding-magic-comment
|
||||||
(insert "# -*- coding: " coding-system " -*-\n"))))
|
(let ((encoding-magic-comment-template
|
||||||
|
(case ruby-encoding-magic-comment-style
|
||||||
|
('ruby "# coding: %s")
|
||||||
|
('emacs "# -*- coding: %s -*-")
|
||||||
|
('custom ruby-custom-encoding-magic-comment-template))))
|
||||||
|
(insert
|
||||||
|
(format encoding-magic-comment-template coding-system)
|
||||||
|
"\n")))))
|
||||||
(when (buffer-modified-p)
|
(when (buffer-modified-p)
|
||||||
(basic-save-buffer-1)))))))
|
(basic-save-buffer-1)))))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue