annotate lisp/prim/case-table.el @ 28:1917ad0d78d7 r19-15b97

Import from CVS: tag r19-15b97
author cvs
date Mon, 13 Aug 2007 08:51:55 +0200
parents 8fc7fe29b841
children 3bb7ccffb0c0
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
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
20 ;; Free Software Foundation, 59 Temple Place - Suite 330,
16
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)
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
36 (let ((ch 0))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (with-displaying-help-buffer
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
38 (lambda ()
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
39 (set-buffer standard-output)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
40 (while (< ch 256)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
41 (cond ((/= ch (downcase ch))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
42 (insert (text-char-description ch))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
43 (indent-to 16)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
44 (insert "uppercase, matches "
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
45 (text-char-description (downcase ch))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
46 "\n"))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
47 ((/= ch (upcase ch))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
48 (insert (text-char-description ch))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
49 (indent-to 16)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
50 (insert "lowercase, matches "
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
51 (text-char-description (upcase ch))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
52 "\n"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; (insert (text-char-description ch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; (indent-to 16)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; (insert "case-invariant\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 )
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 16
diff changeset
58 (setq ch (1+ ch)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (defun invert-case (count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 "Change the case of the character just after point and move over it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 With arg, applies to that many chars.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 Negative arg inverts characters before point but does not move."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (if (< count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (progn (setq count (min (1- (point)) (- count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (forward-char (- count))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (while (> count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (let ((ch (following-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (cond ((/= (upcase ch) ch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (insert (upcase ch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (delete-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ((/= (downcase ch) ch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (insert (downcase ch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (delete-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (forward-char 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (setq count (1- count))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (defun set-case-syntax-delims (l r table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 "Make characters L and R a matching pair of non-case-converting delimiters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 Sets the entries for L and R in standard-case-table,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 standard-syntax-table, and text-mode-syntax-table to indicate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 left and right delimiters."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (aset (car table) l l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (aset (car table) r r)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (modify-syntax-entry l (concat "(" (char-to-string r) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (standard-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (modify-syntax-entry l (concat "(" (char-to-string r) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 text-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (modify-syntax-entry r (concat ")" (char-to-string l) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (standard-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (modify-syntax-entry r (concat ")" (char-to-string l) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 text-mode-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (defun set-case-syntax-pair (uc lc table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 "Make characters UC and LC a pair of inter-case-converting letters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 Sets the entries for characters UC and LC in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 standard-case-table, standard-syntax-table, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 text-mode-syntax-table to indicate an (uppercase, lowercase)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 pair of letters."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (aset (car table) uc lc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (modify-syntax-entry lc "w " (standard-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (modify-syntax-entry lc "w " text-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (modify-syntax-entry uc "w " (standard-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (modify-syntax-entry uc "w " text-mode-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (defun set-case-syntax (c syntax table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 "Make characters C case-invariant with syntax SYNTAX.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 Sets the entries for character C in standard-case-table,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 standard-syntax-table, and text-mode-syntax-table to indicate this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 SYNTAX should be \" \", \"w\", \".\" or \"_\"."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (aset (car table) c c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (modify-syntax-entry c syntax (standard-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (modify-syntax-entry c syntax text-mode-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (provide 'case-table)