annotate lisp/prim/case-table.el @ 159:3bb7ccffb0c0 r20-3b6

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