1 ;;; case-table.el --- code to extend the character set and support case tables.
3 ;; Copyright (C) 1988, 1994 Free Software Foundation, Inc.
5 ;; Author: Howard Gayle
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
29 ;; TN/ETX/TX/UMG Howard Gayle UUCP : seismo!enea!erix!howard
30 ;; Telefonaktiebolaget L M Ericsson Phone: +46 8 719 55 65
31 ;; Ericsson Telecom Telex: 14910 ERIC S
32 ;; S-126 25 Stockholm FAX : +46 8 719 64 82
37 (defvar set-case-syntax-offset
0)
39 (defvar set-case-syntax-set-multibyte nil
)
42 (defun describe-buffer-case-table ()
43 "Describe the case table of the current buffer."
45 (let ((description (make-char-table 'case-table
)))
47 (function (lambda (key value
)
50 (cond ((not (natnump value
))
52 ((/= key
(downcase key
))
53 (concat "uppercase, matches "
54 (char-to-string (downcase key
))))
55 ((/= key
(upcase key
))
56 (concat "lowercase, matches "
57 (char-to-string (upcase key
))))
58 (t "case-invariant")))))
61 (with-output-to-temp-buffer "*Help*"
62 (set-buffer standard-output
)
63 (describe-vector description
)
67 (defun copy-case-table (case-table)
68 (let ((copy (copy-sequence case-table
)))
69 ;; Clear out the extra slots so that they will be
70 ;; recomputed from the main (downcase) table.
71 (set-char-table-extra-slot copy
0 nil
)
72 (set-char-table-extra-slot copy
1 nil
)
73 (set-char-table-extra-slot copy
2 nil
)
76 (defsubst set-case-syntax-1
(char)
77 "Offset CHAR by `set-case-syntax-offset' if CHAR is a non-ASCII 8-bit char."
78 (if (and (>= char
128) (< char
256))
79 (+ char set-case-syntax-offset
)
83 (defun set-case-syntax-delims (l r table
)
84 "Make characters L and R a matching pair of non-case-converting delimiters.
85 This sets the entries for L and R in TABLE, which is a string
86 that will be used as the downcase part of a case table.
87 It also modifies `standard-syntax-table' to
88 indicate left and right delimiters."
89 (setq l
(set-case-syntax-1 l
))
90 (setq r
(set-case-syntax-1 r
))
93 ;; Clear out the extra slots so that they will be
94 ;; recomputed from the main (downcase) table.
95 (set-char-table-extra-slot table
0 nil
)
96 (set-char-table-extra-slot table
1 nil
)
97 (set-char-table-extra-slot table
2 nil
)
98 (modify-syntax-entry l
(concat "(" (char-to-string r
) " ")
99 (standard-syntax-table))
100 (modify-syntax-entry r
(concat ")" (char-to-string l
) " ")
101 (standard-syntax-table)))
104 (defun set-case-syntax-pair (uc lc table
)
105 "Make characters UC and LC a pair of inter-case-converting letters.
106 This sets the entries for characters UC and LC in TABLE, which is a string
107 that will be used as the downcase part of a case table.
108 It also modifies `standard-syntax-table' to give them the syntax of
110 (setq uc
(set-case-syntax-1 uc
))
111 (setq lc
(set-case-syntax-1 lc
))
114 (set-char-table-extra-slot table
0 nil
)
115 (set-char-table-extra-slot table
1 nil
)
116 (set-char-table-extra-slot table
2 nil
)
117 (modify-syntax-entry lc
"w " (standard-syntax-table))
118 (modify-syntax-entry uc
"w " (standard-syntax-table)))
121 (defun set-case-syntax (c syntax table
)
122 "Make character C case-invariant with syntax SYNTAX.
123 This sets the entry for character C in TABLE, which is a string
124 that will be used as the downcase part of a case table.
125 It also modifies `standard-syntax-table'.
126 SYNTAX should be \" \", \"w\", \".\" or \"_\"."
127 (setq c
(set-case-syntax-1 c
))
129 (set-char-table-extra-slot table
0 nil
)
130 (set-char-table-extra-slot table
1 nil
)
131 (set-char-table-extra-slot table
2 nil
)
132 (modify-syntax-entry c syntax
(standard-syntax-table)))
134 (provide 'case-table
)
136 ;;; case-table.el ends here