(remove_char_attribute): New function.
[chise/xemacs-chise.git-] / lisp / bytecomp.el
index 1ce8d27..50416c2 100644 (file)
@@ -3,7 +3,7 @@
 ;;; Copyright (C) 1985-1987, 1991-1994 Free Software Foundation, Inc.
 ;;; Copyright (C) 1996 Ben Wing.
 
-;; Author: Jamie Zawinski <jwz@netscape.com>
+;; Author: Jamie Zawinski <jwz@jwz.org>
 ;;     Hallvard Furuseth <hbf@ulrik.uio.no>
 ;; Keywords: internal
 
@@ -1751,24 +1751,69 @@ With argument, insert value in current buffer after the form."
   ;; Emacsen.
   (when (featurep 'mule)
     (defvar buffer-file-coding-system)
-    (if (save-excursion
-         (set-buffer byte-compile-inbuffer)
+    (let (ces)
+      (save-excursion
+       (set-buffer byte-compile-inbuffer)
+       (goto-char (point-min))
+       ;; mrb- There must be a better way than skip-chars-forward
+       (skip-chars-forward (concat (char-to-string 0) "-"
+                                   (char-to-string 255)))
+       (if (eq (point) (point-max))
+           (setq ces 'raw-text)
+         (goto-char (point-min))
+         (while (< (point)(point-max))
+           (cond ((eq (char-after) ?\;)
+                  (delete-region (point)(point-at-eol))
+                  (if (eq (char-after) ?\n)
+                      (delete-char 1)
+                    (forward-char))
+                  )
+                 ((eq (char-after) ?\?)
+                  (forward-char 2)
+                  )
+                 ((eq (char-after) ?\n)
+                  (forward-char)
+                  )
+                 ((eq (char-after) ?\")
+                  (forward-char)
+                  (while (and (< (point)(point-max))
+                              (not (when (eq (char-after) ?\")
+                                     (forward-char)
+                                     t)))
+                    (if (eq (char-after) ?\\)
+                        (forward-char 2)
+                      (forward-char)))
+                  )
+                 (t
+                  (forward-char))))
          (goto-char (point-min))
-         ;; mrb- There must be a better way than skip-chars-forward
          (skip-chars-forward (concat (char-to-string 0) "-"
                                      (char-to-string 255)))
-         (eq (point) (point-max)))
-       (setq buffer-file-coding-system 'raw-text)
-      (insert "(require 'mule)\n;;;###coding system: escape-quoted\n")
-      (setq buffer-file-coding-system 'escape-quoted)
-      ;; #### Lazy loading not yet implemented for MULE files
-      ;; mrb - Fix this someday.
-      (save-excursion
-       (set-buffer byte-compile-inbuffer)
-       (setq byte-compile-dynamic nil
-             byte-compile-dynamic-docstrings nil))
-      ;;(external-debugging-output (prin1-to-string (buffer-local-variables))))
-      ))
+         (setq ces
+               (if (eq (point) (point-max))
+                   (if (and (featurep 'utf-2000)
+                            (re-search-backward "\\\\u[0-9A-Fa-f]+" nil t))
+                       'utf-8-unix
+                     'raw-text)))))
+      (if (eq ces 'raw-text)
+         (setq buffer-file-coding-system 'raw-text)
+       (cond ((eq ces 'utf-8-unix)
+              (insert "(require 'mule)\n;;;###coding system: utf-8-unix\n")
+              (setq buffer-file-coding-system 'utf-8-unix)
+              )
+             (t
+              (insert "(require 'mule)\n;;;###coding system: escape-quoted\n")
+              (setq buffer-file-coding-system 'escape-quoted)
+              ))
+       ;; #### Lazy loading not yet implemented for MULE files
+       ;; mrb - Fix this someday.
+       (save-excursion
+         (set-buffer byte-compile-inbuffer)
+         (setq byte-compile-dynamic nil
+               byte-compile-dynamic-docstrings nil))
+        ;; (external-debugging-output
+        ;;  (prin1-to-string (buffer-local-variables)))
+       )))
   )