update keywords.
[elisp/apel.git] / poem-xfc.el
1 ;;; poem-xfc.el --- poem module for XEmacs with file coding; -*-byte-compile-dynamic: t;-*-
2
3 ;; Copyright (C) 1998 Free Software Foundation, Inc.
4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: emulation, compatibility, Mule
7
8 ;; This file is part of APEL (A Portable Emacs Library).
9
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
14
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 ;; General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Code:
26
27 (eval-when-compile
28   (require 'poe))
29 (require 'poem-20)
30
31
32 ;;; @ fix coding-system definition
33 ;;;
34
35 ;; Redefine if -{dos|mac|unix} is not found.
36 (or (find-coding-system 'raw-text-dos)
37     (copy-coding-system 'no-conversion-dos 'raw-text-dos))
38 (or (find-coding-system 'raw-text-mac)
39     (copy-coding-system 'no-conversion-mac 'raw-text-mac))
40 (or (find-coding-system 'raw-text-unix)
41     (copy-coding-system 'no-conversion-unix 'raw-text-unix))
42
43 ;;; @ without code-conversion
44 ;;;
45
46 (defun insert-file-contents-as-binary (filename
47                                        &optional visit beg end replace)
48   "Like `insert-file-contents', but only reads in the file literally.
49 A buffer may be modified in several ways after reading into the buffer,
50 to Emacs features such as format decoding, character code
51 conversion, find-file-hooks, automatic uncompression, etc.
52
53 This function ensures that none of these modifications will take place."
54   (let ((format-alist nil)
55         (after-insert-file-functions nil)
56         (coding-system-for-read 'binary)
57         (coding-system-for-write 'binary)
58         (jka-compr-compression-info-list nil)
59         (jam-zcat-filename-list nil)
60         (find-buffer-file-type-function
61          (if (fboundp 'find-buffer-file-type)
62              (symbol-function 'find-buffer-file-type)
63            nil)))
64     (unwind-protect
65         (progn
66           (fset 'find-buffer-file-type (lambda (filename) t))
67           (insert-file-contents filename visit beg end replace))
68       (if find-buffer-file-type-function
69           (fset 'find-buffer-file-type find-buffer-file-type-function)
70         (fmakunbound 'find-buffer-file-type)))))
71
72
73 ;;; @ buffer representation
74 ;;;
75
76 (defsubst-maybe set-buffer-multibyte (flag)
77   "Set the multibyte flag of the current buffer to FLAG.
78 If FLAG is t, this makes the buffer a multibyte buffer.
79 If FLAG is nil, this makes the buffer a single-byte buffer.
80 The buffer contents remain unchanged as a sequence of bytes
81 but the contents viewed as characters do change.
82 \[Emacs 20.3 emulating function]"
83   flag)
84
85 ;;; @ character set
86 ;;;
87
88 (put 'ascii 'charset-description "Character set of ASCII")
89 (put 'ascii 'charset-registry "ASCII")
90
91 (put 'latin-iso8859-1 'charset-description "Character set of ISO-8859-1")
92 (put 'latin-iso8859-1 'charset-registry "ISO8859-1")
93
94 (defun charset-description (charset)
95   "Return description of CHARSET."
96   (get charset 'charset-description))
97
98 (defun charset-registry (charset)
99   "Return registry name of CHARSET."
100   (get charset 'charset-registry))
101
102 (defun charset-width (charset)
103   "Return number of columns a CHARSET occupies when displayed."
104   1)
105
106 (defun charset-direction (charset)
107   "Return the direction of a character of CHARSET by
108   0 (left-to-right) or 1 (right-to-left)."
109   0)
110
111 (defun find-charset-string (str)
112   "Return a list of charsets in the string."
113   (if (string-match "[\200-\377]" str)
114       '(latin-iso8859-1)
115     ))
116
117 (defalias 'find-non-ascii-charset-string 'find-charset-string)
118
119 (defun find-charset-region (start end)
120   "Return a list of charsets in the region between START and END."
121   (if (save-excursion
122         (goto-char start)
123         (re-search-forward "[\200-\377]" end t))
124       '(latin-iso8859-1)
125     ))
126
127 (defalias 'find-non-ascii-charset-region 'find-charset-region)
128
129 ;;; @ string
130 ;;;
131
132 (defun-maybe string-to-int-list (str)
133   (mapcar #'char-int str))
134
135 (defalias 'looking-at-as-unibyte 'looking-at)
136
137
138 ;;; @ end
139 ;;;
140
141 (provide 'poem-xfc)
142
143 ;;; poem-xfc.el ends here