]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/progmodes/ruby-mode.el (ruby-mode-set-encoding):
authorBozhidar Batsov <bozhidar@batsov.com>
Thu, 14 Nov 2013 12:39:41 +0000 (14:39 +0200)
committerBozhidar Batsov <bozhidar@batsov.com>
Thu, 14 Nov 2013 12:39:41 +0000 (14:39 +0200)
Fix and simplify encoding comment update logic.

lisp/ChangeLog
lisp/progmodes/ruby-mode.el

index e0b700a14ba9898e45f9d15524036186015f02b7..c9d767e5b7dccfe1cc46006e290736096999c823 100644 (file)
@@ -2,6 +2,7 @@
 
        * progmodes/ruby-mode.el (ruby-mode-set-encoding):
        Add the ability to always insert an utf-8 encoding comment.
+       Fix and simplify coding comment update logic.
 
 2013-11-14  Michael Albinus  <michael.albinus@gmx.de>
 
index 8051a7594103a1ba8697dcb2fa4ff35feb27117d..e5a2de931d2fd1347af8f59894e38d22346aa936 100644 (file)
@@ -683,15 +683,11 @@ The style of the comment is controlled by `ruby-encoding-magic-comment-style'."
       (let ((coding-system (ruby--detect-encoding)))
         (when coding-system
           (if (looking-at "^#!") (beginning-of-line 2))
-          (cond ((looking-at "\\s *#.*-\*-\\s *\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)\\s *\\(;\\|-\*-\\)")
+          (cond ((looking-at "\\s *#\\s *.*\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)")
+                 ;; update existing encoding comment if necessary
                  (unless (string= (match-string 2) coding-system)
                    (goto-char (match-beginning 2))
                    (delete-region (point) (match-end 2))
-                   (and (looking-at "-\*-")
-                        (let ((n (skip-chars-backward " ")))
-                          (cond ((= n 0) (insert "  ") (backward-char))
-                                ((= n -1) (insert " "))
-                                ((forward-char)))))
                    (insert coding-system)))
                 ((looking-at "\\s *#.*coding\\s *[:=]"))
                 (t (when ruby-insert-encoding-magic-comment