aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBozhidar Batsov2013-11-08 18:01:55 +0200
committerBozhidar Batsov2013-11-08 18:01:55 +0200
commit71731c03382ba72c08d8a8d15ee074b4d3c97e66 (patch)
treee22310a1c5c5ee5620cc116019d52e1fb081bf74
parentda3b328da0db9f396bcf8dc9a5ce1653c91be17d (diff)
downloademacs-71731c03382ba72c08d8a8d15ee074b4d3c97e66.tar.gz
emacs-71731c03382ba72c08d8a8d15ee074b4d3c97e66.zip
* 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.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/progmodes/ruby-mode.el23
2 files changed, 28 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 08265c8ef04..4e76cc6c846 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12013-11-08 Bozhidar Batsov <bozhidar@batsov.com>
2
3 * progmodes/ruby-mode.el (ruby-mode-set-encoding): Use
4 `ruby-encoding-magic-comment-style' to control the
5 style of the auto-inserted encoding comment.
6
12013-11-08 Dmitry Gutov <dgutov@yandex.ru> 72013-11-08 Dmitry Gutov <dgutov@yandex.ru>
2 8
3 * progmodes/ruby-mode.el (ruby-smie--indent-to-stmt): Use 9 * progmodes/ruby-mode.el (ruby-smie--indent-to-stmt): Use
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 9c733d68f2b..1602848c712 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -261,6 +261,20 @@ explicitly declared in magic comment."
261 "Insert a magic Emacs 'coding' comment upon save if this is non-nil." 261 "Insert a magic Emacs 'coding' comment upon save if this is non-nil."
262 :type 'boolean :group 'ruby) 262 :type 'boolean :group 'ruby)
263 263
264(defcustom ruby-encoding-magic-comment-style 'ruby
265 "The style of the magic encoding comment to use."
266 :type '(choice
267 (const :tag "Emacs Style" emacs)
268 (const :tag "Ruby Style" ruby)
269 (const :tag "Custom Style" custom))
270 :group 'ruby)
271
272(defcustom ruby-custom-encoding-magic-comment-template "# coding: %s"
273 "The encoding comment template to be used when
274`ruby-encoding-magic-comment-style' is set to `custom'."
275 :type 'string
276 :group 'ruby)
277
264(defcustom ruby-use-encoding-map t 278(defcustom ruby-use-encoding-map t
265 "Use `ruby-encoding-map' to set encoding magic comment if this is non-nil." 279 "Use `ruby-encoding-map' to set encoding magic comment if this is non-nil."
266 :type 'boolean :group 'ruby) 280 :type 'boolean :group 'ruby)
@@ -639,7 +653,14 @@ explicitly declared in magic comment."
639 (insert coding-system))) 653 (insert coding-system)))
640 ((looking-at "\\s *#.*coding\\s *[:=]")) 654 ((looking-at "\\s *#.*coding\\s *[:=]"))
641 (t (when ruby-insert-encoding-magic-comment 655 (t (when ruby-insert-encoding-magic-comment
642 (insert "# -*- coding: " coding-system " -*-\n")))) 656 (let ((encoding-magic-comment-template
657 (case ruby-encoding-magic-comment-style
658 ('ruby "# coding: %s")
659 ('emacs "# -*- coding: %s -*-")
660 ('custom ruby-custom-encoding-magic-comment-template))))
661 (insert
662 (format encoding-magic-comment-template coding-system)
663 "\n")))))
643 (when (buffer-modified-p) 664 (when (buffer-modified-p)
644 (basic-save-buffer-1))))))) 665 (basic-save-buffer-1)))))))
645 666