Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
99f5d074
Commit
99f5d074
authored
Nov 14, 2013
by
Bozhidar Batsov
Browse files
* lisp/progmodes/ruby-mode.el (ruby-mode-set-encoding):
Fix and simplify encoding comment update logic.
parent
9caa4907
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
6 deletions
+3
-6
lisp/ChangeLog
lisp/ChangeLog
+1
-0
lisp/progmodes/ruby-mode.el
lisp/progmodes/ruby-mode.el
+2
-6
No files found.
lisp/ChangeLog
View file @
99f5d074
...
...
@@ -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>
...
...
lisp/progmodes/ruby-mode.el
View file @
99f5d074
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment