Mercurial > emacs
comparison lisp/international/mule-util.el @ 88155:d7ddb3e565de
sync with trunk
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 16 Jan 2006 00:03:54 +0000 |
parents | 5701c670b676 |
children |
comparison
equal
deleted
inserted
replaced
88154:8ce476d3ba36 | 88155:d7ddb3e565de |
---|---|
1 ;;; mule-util.el --- utility functions for mulitilingual environment (mule) | 1 ;;; mule-util.el --- utility functions for mulitilingual environment (mule) |
2 | 2 |
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | 3 ;; Copyright (C) 1997, 1998, 2000, 2001, 2002, 2003, 2004 |
4 ;; Licensed to the Free Software Foundation. | 4 ;; Free Software Foundation, Inc. |
5 ;; Copyright (C) 1995, 1997, 1998, 1999, 2004 | |
6 ;; National Institute of Advanced Industrial Science and Technology (AIST) | |
7 ;; Registration Number H14PRO021 | |
5 | 8 |
6 ;; Keywords: mule, multilingual | 9 ;; Keywords: mule, multilingual |
7 | 10 |
8 ;; This file is part of GNU Emacs. | 11 ;; This file is part of GNU Emacs. |
9 | 12 |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 ;; GNU General Public License for more details. | 21 ;; GNU General Public License for more details. |
19 | 22 |
20 ;; You should have received a copy of the GNU General Public License | 23 ;; 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 | 24 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 ;; Boston, MA 02111-1307, USA. | 26 ;; Boston, MA 02110-1301, USA. |
24 | 27 |
25 ;;; Commentary: | 28 ;;; Commentary: |
26 | 29 |
27 ;;; Code: | 30 ;;; Code: |
28 | 31 |
58 ) | 61 ) |
59 | 62 |
60 ;;;###autoload | 63 ;;;###autoload |
61 (make-obsolete 'string-to-sequence | 64 (make-obsolete 'string-to-sequence |
62 "use `string-to-list' or `string-to-vector'." | 65 "use `string-to-list' or `string-to-vector'." |
63 "21.4") | 66 "22.1") |
64 | 67 |
65 ;;;###autoload | 68 ;;;###autoload |
66 (defsubst string-to-list (string) | 69 (defsubst string-to-list (string) |
67 "Return a list of characters in STRING." | 70 "Return a list of characters in STRING." |
68 (append string nil)) | 71 (append string nil)) |
205 ;; (if (consp ret) | 208 ;; (if (consp ret) |
206 ;; (format "error: %s: %s" (car ret) | 209 ;; (format "error: %s: %s" (car ret) |
207 ;; (prin1-to-string (cdr ret))) | 210 ;; (prin1-to-string (cdr ret))) |
208 ;; (prin1-to-string ret)))))) | 211 ;; (prin1-to-string ret)))))) |
209 | 212 |
210 ;;; For backward compatibility ... | |
211 ;;;###autoload | |
212 (defalias 'truncate-string 'truncate-string-to-width) | |
213 | |
214 ;;;###autoload | |
215 (make-obsolete 'truncate-string 'truncate-string-to-width "20.1") | |
216 | 213 |
217 ;;; Nested alist handler. Nested alist is alist whose elements are | 214 ;;; Nested alist handler. Nested alist is alist whose elements are |
218 ;;; also nested alist. | 215 ;;; also nested alist. |
219 | 216 |
220 ;;;###autoload | 217 ;;;###autoload |
312 (defun coding-system-translation-table-for-encode (coding-system) | 309 (defun coding-system-translation-table-for-encode (coding-system) |
313 "Return the value of CODING-SYSTEM's `translation-table-for-encode' property." | 310 "Return the value of CODING-SYSTEM's `translation-table-for-encode' property." |
314 (coding-system-get coding-system 'translation-table-for-encode)) | 311 (coding-system-get coding-system 'translation-table-for-encode)) |
315 | 312 |
316 ;;;###autoload | 313 ;;;###autoload |
317 (defun coding-system-equal (coding-system-1 coding-system-2) | |
318 "Return t if and only if CODING-SYSTEM-1 and CODING-SYSTEM-2 are identical. | |
319 Two coding systems are identical if two symbols are equal | |
320 or one is an alias of the other." | |
321 (or (eq coding-system-1 coding-system-2) | |
322 (and (equal (coding-system-spec coding-system-1) | |
323 (coding-system-spec coding-system-2)) | |
324 (let ((eol-type-1 (coding-system-eol-type coding-system-1)) | |
325 (eol-type-2 (coding-system-eol-type coding-system-2))) | |
326 (or (eq eol-type-1 eol-type-2) | |
327 (and (vectorp eol-type-1) (vectorp eol-type-2))))))) | |
328 | |
329 ;;;###autoload | |
330 (defmacro detect-coding-with-priority (from to priority-list) | 314 (defmacro detect-coding-with-priority (from to priority-list) |
331 "Detect a coding system of the text between FROM and TO with PRIORITY-LIST. | 315 "Detect a coding system of the text between FROM and TO with PRIORITY-LIST. |
332 PRIORITY-LIST is an alist of coding categories vs the corresponding | 316 PRIORITY-LIST is an alist of coding categories vs the corresponding |
333 coding systems ordered by priority." | 317 coding systems ordered by priority." |
334 `(unwind-protect | 318 `(unwind-protect |
337 ,@(mapcar (function (lambda (x) (list x x))) | 321 ,@(mapcar (function (lambda (x) (list x x))) |
338 coding-category-list)) | 322 coding-category-list)) |
339 (mapc (function (lambda (x) (set (car x) (cdr x)))) | 323 (mapc (function (lambda (x) (set (car x) (cdr x)))) |
340 prio-list) | 324 prio-list) |
341 (set-coding-priority (mapcar #'car prio-list)) | 325 (set-coding-priority (mapcar #'car prio-list)) |
326 ;; Changing the binding of a coding category requires this call. | |
327 (update-coding-systems-internal) | |
342 (detect-coding-region ,from ,to)) | 328 (detect-coding-region ,from ,to)) |
343 ;; We must restore the internal database. | 329 ;; We must restore the internal database. |
344 (set-coding-priority coding-category-list) | 330 (set-coding-priority coding-category-list) |
345 (update-coding-systems-internal))) | 331 (update-coding-systems-internal))) |
346 | 332 |
356 (mapcar (function (lambda (x) | 342 (mapcar (function (lambda (x) |
357 (cons (coding-system-get x 'coding-category) x))) | 343 (cons (coding-system-get x 'coding-category) x))) |
358 coding-priority)) | 344 coding-priority)) |
359 (detect-coding-region from to)))) | 345 (detect-coding-region from to)))) |
360 | 346 |
347 ;;;###autoload | |
348 (defun char-displayable-p (char) | |
349 "Return non-nil if we should be able to display CHAR. | |
350 On a multi-font display, the test is only whether there is an | |
351 appropriate font from the selected frame's fontset to display CHAR's | |
352 charset in general. Since fonts may be specified on a per-character | |
353 basis, this may not be accurate." | |
354 (cond ((< char 256) | |
355 ;; Single byte characters are always displayable. | |
356 t) | |
357 ((not enable-multibyte-characters) | |
358 ;; Maybe there's a font for it, but we can't put it in the buffer. | |
359 nil) | |
360 ((display-multi-font-p) | |
361 ;; On a window system, a character is displayable if we have | |
362 ;; a font for that character in the default face of the | |
363 ;; currently selected frame. | |
364 (car (internal-char-font nil char))) | |
365 (t | |
366 (let ((coding (terminal-coding-system))) | |
367 (if coding | |
368 (let ((safe-chars (coding-system-get coding 'safe-chars)) | |
369 (safe-charsets (coding-system-get coding 'safe-charsets))) | |
370 (or (and safe-chars | |
371 (aref safe-chars char)) | |
372 (and safe-charsets | |
373 (memq (char-charset char) safe-charsets))))))))) | |
361 | 374 |
362 (provide 'mule-util) | 375 (provide 'mule-util) |
363 | 376 |
364 ;; Local Variables: | 377 ;; Local Variables: |
365 ;; coding: iso-2022-7bit | 378 ;; coding: iso-2022-7bit |
366 ;; End: | 379 ;; End: |
367 | 380 |
381 ;; arch-tag: 5bdb52b6-a3a5-4529-b7a0-37d01b0e570b | |
368 ;;; mule-util.el ends here | 382 ;;; mule-util.el ends here |