diff options
| author | Bozhidar Batsov | 2013-11-14 14:39:41 +0200 |
|---|---|---|
| committer | Bozhidar Batsov | 2013-11-14 14:39:41 +0200 |
| commit | 99f5d0744ebf302d9ba56aae78da90504cb48772 (patch) | |
| tree | b287b72f17c2b2543b3e68437886b1e0e8d57589 /lisp/progmodes/ruby-mode.el | |
| parent | 9caa4907bb8c7bae5fec99cf2f05d30808f5eeab (diff) | |
| download | emacs-99f5d0744ebf302d9ba56aae78da90504cb48772.tar.gz emacs-99f5d0744ebf302d9ba56aae78da90504cb48772.zip | |
* lisp/progmodes/ruby-mode.el (ruby-mode-set-encoding):
Fix and simplify encoding comment update logic.
Diffstat (limited to 'lisp/progmodes/ruby-mode.el')
| -rw-r--r-- | lisp/progmodes/ruby-mode.el | 8 |
1 files changed, 2 insertions, 6 deletions
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 |