annotate lisp/mule/mule-misc.el @ 418:e804706bfb8c r21-2-17

Import from CVS: tag r21-2-17
author cvs
date Mon, 13 Aug 2007 11:23:13 +0200
parents 697ef44129c6
children 41dbb7a9d5f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1 ;; mule-misc.el --- Miscellaneous Mule functions.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
2
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
3 ;; Copyright (C) 1995,1999 Electrotechnical Laboratory, JAPAN.
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
4 ;; Licensed to the Free Software Foundation.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
5 ;; Copyright (C) 1992,93,94,95 Free Software Foundation, Inc.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
6 ;; Copyright (C) 1995 Amdahl Corporation.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
7 ;; Copyright (C) 1995 Sun Microsystems.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
8
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
10
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
14 ;; any later version.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
15
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
19 ;; General Public License for more details.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
20
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
25
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
26 ;;;
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
27 ;;; protect specified local variables from kill-all-local-variables
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
28 ;;;
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
29
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
30 (defvar self-insert-after-hook nil
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
31 "Hook to run when extended self insertion command exits. Should take
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
32 two arguments START and END corresponding to character position.")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
33
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
34 (make-variable-buffer-local 'self-insert-after-hook)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
35
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
36 (defun toggle-display-direction ()
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
37 (interactive)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
38 (setq display-direction (not display-direction))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
39 (if (interactive-p) (redraw-display)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
40
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
41 ;;;
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
42 ;;; Utility functions for Mule
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
43 ;;;
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
44
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
45 ;(defun string-to-char-list (str)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
46 ; (let ((len (length str))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
47 ; (idx 0)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
48 ; c l)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
49 ; (while (< idx len)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
50 ; (setq c (sref str idx))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
51 ; (setq idx (+ idx (charset-dimension (char-charset c))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
52 ; (setq l (cons c l)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
53 ; (nreverse l)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
54
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
55 (defun string-to-char-list (str)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
56 (mapcar 'identity str))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
57
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
58 (defun string-width (string)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
59 "Return number of columns STRING occupies when displayed.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
60 Uses the charset-columns attribute of the characters in STRING,
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
61 which may not accurately represent the actual display width when
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
62 using a window system."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
63 (let ((col 0)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
64 (len (length string))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
65 (i 0))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
66 (while (< i len)
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 398
diff changeset
67 (setq col (+ col (charset-columns (char-charset (aref string i)))))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
68 (setq i (1+ i)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
69 col))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
70
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
71 (defalias 'string-columns 'string-width)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
72 (make-obsolete 'string-columns 'string-width)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
73
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
74 (defun delete-text-in-column (from to)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
75 "Delete the text between column FROM and TO (exclusive) of the current line.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
76 Nil of FORM or TO means the current column.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
77
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
78 If there's a character across the borders, the character is replaced
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
79 with the same width of spaces before deleting."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
80 (save-excursion
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
81 (let (p1 p2)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
82 (if from
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
83 (progn
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
84 (setq p1 (move-to-column from))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
85 (if (> p1 from)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
86 (progn
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
87 (delete-char -1)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
88 (insert-char ? (- p1 (current-column)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
89 (forward-char (- from p1))))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
90 (setq p1 (point))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
91 (if to
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
92 (progn
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
93 (setq p2 (move-to-column to))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
94 (if (> p2 to)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
95 (progn
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
96 (delete-char -1)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
97 (insert-char ? (- p2 (current-column)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
98 (forward-char (- to p2))))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
99 (setq p2 (point))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
100 (delete-region p1 p2))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
101
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
102 ;; #### Someone translate this!!
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
103
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
104 (defun mc-normal-form-string (str)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
105 "文字列 STR の漢字標準形文字列を返す."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
106 (let ((i 0))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
107 (while (setq i (string-match "\n" str i))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
108 (if (and (<= 1 i) (< i (1- (length str)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
109 (< (aref str (1- i)) 128)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
110 (< (aref str (1+ i)) 128))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
111 (aset str i ? ))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
112 (setq i (1+ i)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
113 (if (string-match "\n" str 0)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
114 (let ((c 0) (i 0) new)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
115 (while (setq i (string-match "\n" str i))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
116 (setq i (1+ i))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
117 (setq c (1+ c)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
118 (setq new (make-string (- (length str) c) 0))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
119 (setq i 0 c 0)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
120 (while (< i (length str))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
121 (cond((not (= (aref str i) ?\n ))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
122 (aset new c (aref str i))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
123 (setq c (1+ c))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
124
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
125 (setq i (1+ i))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
126 )
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
127 new)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
128 str)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
129
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
130
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
131 (defun string-memq (str list)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
132 "Returns non-nil if STR is an element of LIST. Comparison done with string=.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
133 The value is actually the tail of LIST whose car is STR.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
134 If each element of LIST is not a string, it is converted to string
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
135 before comparison."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
136 (let (find elm)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
137 (while (and (not find) list)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
138 (setq elm (car list))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
139 (if (numberp elm) (setq elm (char-to-string elm)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
140 (if (string= str elm)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
141 (setq find list)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
142 (setq list (cdr list))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
143 find))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
144
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
145 (defun cancel-undo-boundary ()
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
146 "Cancel undo boundary."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
147 (if (and (consp buffer-undo-list)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
148 ;; if car is nil.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
149 (null (car buffer-undo-list)) )
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
150 (setq buffer-undo-list (cdr buffer-undo-list)) ))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
151
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
152
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
153 ;;; Common API emulation functions for GNU Emacs-merged Mule.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
154 ;;; As suggested by MORIOKA Tomohiko
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
155
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
156 ;; Following definition were imported from Emacs/mule-delta.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
157
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
158 ;; Function `truncate-string-to-width' was moved to mule-util.el.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
159
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
160 ;; end of imported definition
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
161
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
162
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
163 (defalias 'sref 'aref)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
164 (defalias 'map-char-concat 'mapcar)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
165 (defun char-bytes (character)
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 398
diff changeset
166 "Return number of length a CHARACTER occupies in a string or buffer.
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 398
diff changeset
167 It returns only 1 in XEmacs. It is for compatibility with MULE 2.3."
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
168 1)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
169 (defalias 'char-length 'char-bytes)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
170
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
171 (defun char-width (character)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
172 "Return number of columns a CHARACTER occupies when displayed."
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 398
diff changeset
173 (charset-columns (char-charset character)))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
174
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
175 (defalias 'char-columns 'char-width)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
176 (make-obsolete 'char-columns 'char-width)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
177
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
178 (defalias 'find-charset-string 'charsets-in-string)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
179 (defalias 'find-charset-region 'charsets-in-region)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
180
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
181 (defun find-non-ascii-charset-string (string)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
182 "Return a list of charsets in the STRING except ascii.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
183 It might be available for compatibility with Mule 2.3,
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
184 because its `find-charset-string' ignores ASCII charset."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
185 (delq 'ascii (charsets-in-string string)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
186
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
187 (defun find-non-ascii-charset-region (start end)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
188 "Return a list of charsets except ascii in the region between START and END.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
189 It might be available for compatibility with Mule 2.3,
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
190 because its `find-charset-string' ignores ASCII charset."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
191 (delq 'ascii (charsets-in-region start end)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
192
418
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
193 ;(defun split-char (char)
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
194 ; "Return list of charset and one or two position-codes of CHAR."
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
195 ; (let ((charset (char-charset char)))
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
196 ; (if (eq charset 'ascii)
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
197 ; (list charset (char-int char))
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
198 ; (let ((i 0)
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
199 ; (len (charset-dimension charset))
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
200 ; (code (if (integerp char)
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
201 ; char
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
202 ; (char-int char)))
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
203 ; dest)
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
204 ; (while (< i len)
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
205 ; (setq dest (cons (logand code 127) dest)
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
206 ; code (lsh code -7)
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
207 ; i (1+ i)))
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
208 ; (cons charset dest)
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
209 ; ))))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
210
418
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
211 (defun char-octet (ch &optional n)
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
212 "Return the octet numbered N (should be 0 or 1) of char CH.
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
213 N defaults to 0 if omitted."
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
214 (let ((split (split-char ch)))
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
215 (cond ((eq n 0)
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
216 (nth 1 split))
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
217 ((eq n 1)
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
218 (nth 2 split))
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
219 (t (error "n must be 0 or 1")))))
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
220 ;; Made obsolete June 15, 1999. Delete ASAP.
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
221 (make-obsolete 'char-octet "Use split-char")
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
222
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
223 ;(defun split-char-or-char-int (char)
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
224 ; "Return list of charset and one or two position-codes of CHAR.
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
225 ;CHAR must be character or integer."
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
226 ; (if (characterp char)
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
227 ; (split-char char)
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
228 ; (let ((c (int-char char)))
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
229 ; (if c
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
230 ; (split-char c)
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
231 ; (list 'ascii c)
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 412
diff changeset
232 ; ))))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
233
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
234
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
235 ;;; Commands
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
236
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
237 (defun set-buffer-process-coding-system (decoding encoding)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
238 "Set coding systems for the process associated with the current buffer.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
239 DECODING is the coding system to be used to decode input from the process,
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
240 ENCODING is the coding system to be used to encode output to the process.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
241
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
242 For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems]."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
243 (interactive
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
244 "zCoding-system for process input: \nzCoding-system for process output: ")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
245 (let ((proc (get-buffer-process (current-buffer))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
246 (if (null proc)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
247 (error "no process")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
248 (check-coding-system decoding)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
249 (check-coding-system encoding)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
250 (set-process-coding-system proc decoding encoding)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
251 (force-mode-line-update))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
252
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
253
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
254 ;;; Language environments
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
255
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
256 ;; (defvar current-language-environment nil)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
257
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
258 ;; (defvar language-environment-list nil)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
259
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
260 ;; (defun current-language-environment ()
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
261 ;; "Return the current language environment as a symbol.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
262 ;; Returns nil if `set-language-environment' has not been called."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
263 ;; current-language-environment)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
264
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
265 ;; (defun language-environment-list ()
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
266 ;; "Return a list of all currently defined language environments."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
267 ;; language-environment-list)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
268
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
269 ;; (defun language-environment-p (sym)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
270 ;; "True if SYM names a defined language environment."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
271 ;; (memq sym (language-environment-list)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
272
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
273 ;; (defun set-language-environment (env)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
274 ;; "Set the current language environment to ENV."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
275 ;; (interactive
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
276 ;; (list (intern (completing-read "Language environment: "
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
277 ;; obarray 'language-environment-p
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
278 ;; 'require-match))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
279 ;; (when (not (string= (charset-registry 'ascii) "iso8859-1"))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
280 ;; (set-charset-registry 'ascii "iso8859-1"))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
281 ;; (let ((func (get env 'set-lang-environ)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
282 ;; (if (not (null func))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
283 ;; (funcall func)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
284 ;; (setq current-language-environment env)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
285 ;; (if (featurep 'egg)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
286 ;; (egg-lang-switch-callback))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
287 ;; ;; (if (featurep 'quail)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
288 ;; ;; (quail-lang-switch-callback))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
289 ;; )
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
290
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
291 ;; (defun define-language-environment (env-sym doc-string enable-function)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
292 ;; "Define a new language environment, named by ENV-SYM.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
293 ;; DOC-STRING should be a string describing the environment.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
294 ;; ENABLE-FUNCTION should be a function of no arguments that will be called
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
295 ;; when the language environment is made current."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
296 ;; (put env-sym 'lang-environ-doc-string doc-string)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
297 ;; (put env-sym 'set-lang-environ enable-function)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
298 ;; (setq language-environment-list (cons env-sym language-environment-list)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
299
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
300 (defun define-egg-environment (env-sym doc-string enable-function)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
301 "Define a new language environment for egg, named by ENV-SYM.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
302 DOC-STRING should be a string describing the environment.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
303 ENABLE-FUNCTION should be a function of no arguments that will be called
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
304 when the language environment is made current."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
305 (put env-sym 'egg-environ-doc-string doc-string)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
306 (put env-sym 'set-egg-environ enable-function))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
307
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
308 ;; (defun define-quail-environment (env-sym doc-string enable-function)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
309 ;; "Define a new language environment for quail, named by ENV-SYM.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
310 ;; DOC-STRING should be a string describing the environment.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
311 ;; ENABLE-FUNCTION should be a function of no arguments that will be called
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
312 ;; when the language environment is made current."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
313 ;; (put env-sym 'quail-environ-doc-string doc-string)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
314 ;; (put env-sym 'set-quail-environ enable-function))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
315
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
316 ;;; mule-misc.el ends here