mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* misc/ruby-mode.el (ruby-encoding-map): added shift-jis for older
versions. * misc/ruby-mode.el (ruby-mode-set-encoding): coding-system-to-mime-charset is not a standard function. [carbon-emacs:795] fix for the case that magic comment exists but coding system is absent. * misc/ruby-mode.el (ruby-mode): use write-contents-functions or write-contents-hooks for older versions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d1263ff544
commit
6a98d417f0
2 changed files with 34 additions and 12 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
Tue Apr 15 15:38:02 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* misc/ruby-mode.el (ruby-encoding-map): added shift-jis for older
|
||||||
|
versions.
|
||||||
|
|
||||||
|
* misc/ruby-mode.el (ruby-mode-set-encoding):
|
||||||
|
coding-system-to-mime-charset is not a standard function.
|
||||||
|
[carbon-emacs:795]
|
||||||
|
fix for the case that magic comment exists but coding system is
|
||||||
|
absent.
|
||||||
|
|
||||||
|
* misc/ruby-mode.el (ruby-mode): use write-contents-functions or
|
||||||
|
write-contents-hooks for older versions.
|
||||||
|
|
||||||
Tue Apr 15 07:21:21 2008 Tadayoshi Funaba <tadf@dotrb.org>
|
Tue Apr 15 07:21:21 2008 Tadayoshi Funaba <tadf@dotrb.org>
|
||||||
|
|
||||||
* complex.c (nucomp_div): [ruby-dev:34357]
|
* complex.c (nucomp_div): [ruby-dev:34357]
|
||||||
|
|
|
@ -162,7 +162,7 @@ Also ignores spaces after parenthesis when 'space."
|
||||||
"Default deep indent style."
|
"Default deep indent style."
|
||||||
:options '(t nil space) :group 'ruby)
|
:options '(t nil space) :group 'ruby)
|
||||||
|
|
||||||
(defcustom ruby-encoding-map '((shift_jis . cp932))
|
(defcustom ruby-encoding-map '((shift_jis . cp932) (shift-jis . cp932))
|
||||||
"Alist to map encoding name from emacs to ruby."
|
"Alist to map encoding name from emacs to ruby."
|
||||||
:group 'ruby)
|
:group 'ruby)
|
||||||
|
|
||||||
|
@ -242,11 +242,6 @@ Also ignores spaces after parenthesis when 'space."
|
||||||
(make-local-variable 'paragraph-ignore-fill-prefix)
|
(make-local-variable 'paragraph-ignore-fill-prefix)
|
||||||
(setq paragraph-ignore-fill-prefix t))
|
(setq paragraph-ignore-fill-prefix t))
|
||||||
|
|
||||||
(eval-when-compile
|
|
||||||
(unless (fboundp 'coding-system-to-mime-charset)
|
|
||||||
(defun coding-system-to-mime-charset (coding-system)
|
|
||||||
(coding-system-change-eol-conversion coding-system nil))))
|
|
||||||
|
|
||||||
(defun ruby-mode-set-encoding ()
|
(defun ruby-mode-set-encoding ()
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(widen)
|
(widen)
|
||||||
|
@ -254,9 +249,12 @@ Also ignores spaces after parenthesis when 'space."
|
||||||
(when (re-search-forward "[^\0-\177]" nil t)
|
(when (re-search-forward "[^\0-\177]" nil t)
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(let ((coding-system
|
(let ((coding-system
|
||||||
(coding-system-to-mime-charset
|
(or coding-system-for-write
|
||||||
(or coding-system-for-write
|
buffer-file-coding-system)))
|
||||||
buffer-file-coding-system))))
|
(if coding-system
|
||||||
|
(setq coding-system
|
||||||
|
(or (coding-system-get coding-system 'mime-charset)
|
||||||
|
(coding-system-change-eol-conversion coding-system nil))))
|
||||||
(setq coding-system
|
(setq coding-system
|
||||||
(if coding-system
|
(if coding-system
|
||||||
(symbol-name
|
(symbol-name
|
||||||
|
@ -265,10 +263,15 @@ Also ignores spaces after parenthesis when 'space."
|
||||||
coding-system))
|
coding-system))
|
||||||
"ascii-8bit"))
|
"ascii-8bit"))
|
||||||
(if (looking-at "^#![^\n]*ruby") (beginning-of-line 2))
|
(if (looking-at "^#![^\n]*ruby") (beginning-of-line 2))
|
||||||
(cond ((looking-at "\\s *#.*-\*-\\s *\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]+\\)")
|
(cond ((looking-at "\\s *#.*-\*-\\s *\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)\\s *\\(;\\|-\*-\\)")
|
||||||
(unless (string= (match-string 2) coding-system)
|
(unless (string= (match-string 2) coding-system)
|
||||||
(goto-char (match-beginning 2))
|
(goto-char (match-beginning 2))
|
||||||
(delete-region (point) (match-end 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)))
|
(insert coding-system)))
|
||||||
((looking-at "\\s *#.*coding\\s *[:=]"))
|
((looking-at "\\s *#.*coding\\s *[:=]"))
|
||||||
(t (insert "# -*- coding: " coding-system " -*-\n"))
|
(t (insert "# -*- coding: " coding-system " -*-\n"))
|
||||||
|
@ -296,8 +299,13 @@ The variable ruby-indent-level controls the amount of indentation.
|
||||||
(make-local-variable 'add-log-current-defun-function)
|
(make-local-variable 'add-log-current-defun-function)
|
||||||
(setq add-log-current-defun-function 'ruby-add-log-current-method)
|
(setq add-log-current-defun-function 'ruby-add-log-current-method)
|
||||||
|
|
||||||
(make-local-variable 'before-save-hook)
|
(add-hook
|
||||||
(add-hook 'before-save-hook 'ruby-mode-set-encoding)
|
(cond ((boundp 'before-save-hook)
|
||||||
|
(make-local-variable 'before-save-hook)
|
||||||
|
'before-save-hook)
|
||||||
|
((boundp 'write-contents-functions) 'write-contents-functions)
|
||||||
|
((boundp 'write-contents-hooks) 'write-contents-hooks))
|
||||||
|
'ruby-mode-set-encoding)
|
||||||
|
|
||||||
(run-mode-hooks 'ruby-mode-hook))
|
(run-mode-hooks 'ruby-mode-hook))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue