diff options
| -rw-r--r-- | lisp/ChangeLog | 1 | ||||
| -rw-r--r-- | lisp/progmodes/ruby-mode.el | 8 |
2 files changed, 3 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e0b700a14ba..c9d767e5b7d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | * progmodes/ruby-mode.el (ruby-mode-set-encoding): | 3 | * progmodes/ruby-mode.el (ruby-mode-set-encoding): |
| 4 | Add the ability to always insert an utf-8 encoding comment. | 4 | Add the ability to always insert an utf-8 encoding comment. |
| 5 | Fix and simplify coding comment update logic. | ||
| 5 | 6 | ||
| 6 | 2013-11-14 Michael Albinus <michael.albinus@gmx.de> | 7 | 2013-11-14 Michael Albinus <michael.albinus@gmx.de> |
| 7 | 8 | ||
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 8051a759410..e5a2de931d2 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el | |||
| @@ -683,15 +683,11 @@ The style of the comment is controlled by `ruby-encoding-magic-comment-style'." | |||
| 683 | (let ((coding-system (ruby--detect-encoding))) | 683 | (let ((coding-system (ruby--detect-encoding))) |
| 684 | (when coding-system | 684 | (when coding-system |
| 685 | (if (looking-at "^#!") (beginning-of-line 2)) | 685 | (if (looking-at "^#!") (beginning-of-line 2)) |
| 686 | (cond ((looking-at "\\s *#.*-\*-\\s *\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)\\s *\\(;\\|-\*-\\)") | 686 | (cond ((looking-at "\\s *#\\s *.*\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)") |
| 687 | ;; update existing encoding comment if necessary | ||
| 687 | (unless (string= (match-string 2) coding-system) | 688 | (unless (string= (match-string 2) coding-system) |
| 688 | (goto-char (match-beginning 2)) | 689 | (goto-char (match-beginning 2)) |
| 689 | (delete-region (point) (match-end 2)) | 690 | (delete-region (point) (match-end 2)) |
| 690 | (and (looking-at "-\*-") | ||
| 691 | (let ((n (skip-chars-backward " "))) | ||
| 692 | (cond ((= n 0) (insert " ") (backward-char)) | ||
| 693 | ((= n -1) (insert " ")) | ||
| 694 | ((forward-char))))) | ||
| 695 | (insert coding-system))) | 691 | (insert coding-system))) |
| 696 | ((looking-at "\\s *#.*coding\\s *[:=]")) | 692 | ((looking-at "\\s *#.*coding\\s *[:=]")) |
| 697 | (t (when ruby-insert-encoding-magic-comment | 693 | (t (when ruby-insert-encoding-magic-comment |