[前][次][番号順一覧][スレッド一覧]

ruby-changes:4535

From: ko1@a...
Date: Tue, 15 Apr 2008 15:38:31 +0900 (JST)
Subject: [ruby-changes:4535] nobu - Ruby:r16028 (trunk): * misc/ruby-mode.el (ruby-encoding-map): added shift-jis for older

nobu	2008-04-15 15:38:13 +0900 (Tue, 15 Apr 2008)

  New Revision: 16028

  Modified files:
    trunk/ChangeLog
    trunk/misc/ruby-mode.el

  Log:
    * 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.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/misc/ruby-mode.el?r1=16028&r2=16027&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16028&r2=16027&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 16027)
+++ ChangeLog	(revision 16028)
@@ -1,3 +1,17 @@
+Tue Apr 15 15:38:02 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@d...>
 
 	* complex.c (nucomp_div): [ruby-dev:34357]
Index: misc/ruby-mode.el
===================================================================
--- misc/ruby-mode.el	(revision 16027)
+++ misc/ruby-mode.el	(revision 16028)
@@ -162,7 +162,7 @@
   "Default deep indent style."
   :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."
   :group 'ruby)
 
@@ -242,11 +242,6 @@
   (make-local-variable 'paragraph-ignore-fill-prefix)
   (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 ()
   (save-excursion
     (widen)
@@ -254,9 +249,12 @@
     (when (re-search-forward "[^\0-\177]" nil t)
       (goto-char (point-min))
       (let ((coding-system
-	     (coding-system-to-mime-charset
-	      (or coding-system-for-write
-		  buffer-file-coding-system))))
+	     (or coding-system-for-write
+		 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
 	      (if coding-system
 		  (symbol-name
@@ -265,10 +263,15 @@
 		       coding-system))
 		"ascii-8bit"))
 	(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)
 		 (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 (insert "# -*- coding: " coding-system " -*-\n"))
@@ -296,8 +299,13 @@
   (make-local-variable 'add-log-current-defun-function)
   (setq add-log-current-defun-function 'ruby-add-log-current-method)
 
-  (make-local-variable 'before-save-hook)
-  (add-hook 'before-save-hook 'ruby-mode-set-encoding)
+  (add-hook
+   (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))
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]