annotate lisp/prim/case-table.el @ 20:859a2309aef8 r19-15b93

Import from CVS: tag r19-15b93
author cvs
date Mon, 13 Aug 2007 08:50:05 +0200
parents 0293115a14e9
children 8fc7fe29b841
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; case-table.el --- code to extend the character set and support case tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Keywords: i18n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Copyright (C) 1988, 1993 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
19 ;; along with XEmacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
20 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
21 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; Synched up with: Not synched with FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; Written by:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; TN/ETX/TX/UMG Howard Gayle UUCP : seismo!enea!erix!howard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; Telefonaktiebolaget L M Ericsson Phone: +46 8 719 55 65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; Ericsson Telecom Telex: 14910 ERIC S
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; S-126 25 Stockholm FAX : +46 8 719 64 82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; Sweden
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (defun describe-buffer-case-table ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 "Describe the case table of the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (let ((vector (make-vector 256 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (case-table (current-case-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (ch 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (with-displaying-help-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (set-buffer standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (while (< ch 256)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (cond ((/= ch (downcase ch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (insert (text-char-description ch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (indent-to 16)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (insert "uppercase, matches "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (text-char-description (downcase ch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ((/= ch (upcase ch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (insert (text-char-description ch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (indent-to 16)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (insert "lowercase, matches "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (text-char-description (upcase ch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; (insert (text-char-description ch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; (indent-to 16)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; (insert "case-invariant\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (setq ch (1+ ch))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (defun invert-case (count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 "Change the case of the character just after point and move over it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 With arg, applies to that many chars.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 Negative arg inverts characters before point but does not move."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (if (< count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (progn (setq count (min (1- (point)) (- count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (forward-char (- count))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (while (> count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (let ((ch (following-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (cond ((/= (upcase ch) ch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (insert (upcase ch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (delete-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ((/= (downcase ch) ch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (insert (downcase ch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (delete-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (forward-char 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (setq count (1- count))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (defun set-case-syntax-delims (l r table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 "Make characters L and R a matching pair of non-case-converting delimiters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 Sets the entries for L and R in standard-case-table,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 standard-syntax-table, and text-mode-syntax-table to indicate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 left and right delimiters."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (aset (car table) l l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (aset (car table) r r)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (modify-syntax-entry l (concat "(" (char-to-string r) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (standard-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (modify-syntax-entry l (concat "(" (char-to-string r) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 text-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (modify-syntax-entry r (concat ")" (char-to-string l) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (standard-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (modify-syntax-entry r (concat ")" (char-to-string l) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 text-mode-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (defun set-case-syntax-pair (uc lc table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 "Make characters UC and LC a pair of inter-case-converting letters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 Sets the entries for characters UC and LC in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 standard-case-table, standard-syntax-table, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 text-mode-syntax-table to indicate an (uppercase, lowercase)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 pair of letters."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (aset (car table) uc lc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (modify-syntax-entry lc "w " (standard-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (modify-syntax-entry lc "w " text-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (modify-syntax-entry uc "w " (standard-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (modify-syntax-entry uc "w " text-mode-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (defun set-case-syntax (c syntax table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 "Make characters C case-invariant with syntax SYNTAX.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 Sets the entries for character C in standard-case-table,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 standard-syntax-table, and text-mode-syntax-table to indicate this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 SYNTAX should be \" \", \"w\", \".\" or \"_\"."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (aset (car table) c c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (modify-syntax-entry c syntax (standard-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (modify-syntax-entry c syntax text-mode-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (provide 'case-table)